haskell-language-server/test/functional/Definition.hs
Luke Lau cdf50a6312
Add GitHub Actions CI for testing (#504)
* Add GitHub workflow for testing

* Add HLS_TEST_EXE env var to control which exe to test

* Pass -j1 flag to tasty when running tests on GitHub

* Enable stack in GitHub CI

* Update cabal

* Add HLS_WRAPPER_TEST_EXE

* Fix cache restore keys

* Try force language server to use utf8 locale

* Use patched hie-bios

* Remove debug print

* Lets find out what the windows locale encoding is

* Give up trying to fix the locale

* Add comment for -j1
2020-10-19 14:16:17 +01:00

70 lines
3.0 KiB
Haskell

module Definition (tests) where
import Control.Lens
import Control.Monad.IO.Class
import Language.Haskell.LSP.Test
import Language.Haskell.LSP.Types
import Language.Haskell.LSP.Types.Lens
import System.Directory
import Test.Hls.Util
import Test.Tasty
import Test.Tasty.ExpectedFailure (ignoreTestBecause)
import Test.Tasty.HUnit
tests :: TestTree
tests = testGroup "definitions" [
ignoreTestBecause "Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/References.hs" $
testCase "goto's symbols" $ runSession hlsCommand fullCaps "test/testdata" $ do
doc <- openDoc "References.hs" "haskell"
defs <- getDefinitions doc (Position 7 8)
let expRange = Range (Position 4 0) (Position 4 3)
liftIO $ defs @?= [Location (doc ^. uri) expRange]
-- -----------------------------------
, ignoreTestBecause "Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
testCase "goto's imported modules" $ runSession hlsCommand fullCaps "test/testdata/definition" $ do
doc <- openDoc "Foo.hs" "haskell"
defs <- getDefinitions doc (Position 2 8)
liftIO $ do
fp <- canonicalizePath "test/testdata/definition/Bar.hs"
defs @?= [Location (filePathToUri fp) zeroRange]
, ignoreTestBecause "Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
testCase "goto's exported modules" $ runSession hlsCommand fullCaps "test/testdata/definition" $ do
doc <- openDoc "Foo.hs" "haskell"
defs <- getDefinitions doc (Position 0 15)
liftIO $ do
fp <- canonicalizePath "test/testdata/definition/Bar.hs"
defs @?= [Location (filePathToUri fp) zeroRange]
, ignoreTestBecause "Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
testCase "goto's imported modules that are loaded" $ runSession hlsCommand fullCaps "test/testdata/definition" $ do
doc <- openDoc "Foo.hs" "haskell"
_ <- openDoc "Bar.hs" "haskell"
defs <- getDefinitions doc (Position 2 8)
liftIO $ do
fp <- canonicalizePath "test/testdata/definition/Bar.hs"
defs @?= [Location (filePathToUri fp) zeroRange]
, ignoreTestBecause "Broken: file:///Users/jwindsor/src/haskell-language-server/test/testdata/Bar.hs" $
testCase "goto's imported modules that are loaded, and then closed" $
runSession hlsCommand fullCaps "test/testdata/definition" $ do
doc <- openDoc "Foo.hs" "haskell"
otherDoc <- openDoc "Bar.hs" "haskell"
closeDoc otherDoc
defs <- getDefinitions doc (Position 2 8)
_ <- waitForDiagnostics
liftIO $ putStrLn "D"
liftIO $ do
fp <- canonicalizePath "test/testdata/definition/Bar.hs"
defs @?= [Location (filePathToUri fp) zeroRange]
liftIO $ putStrLn "E" -- AZ
noDiagnostics
]
zeroRange :: Range
zeroRange = Range (Position 0 0) (Position 0 0)