haskell-language-server/test/wrapper/Main.hs
Luke Lau 9d3d0e6f13 Accept the legacy "languageServerHaskell" config name
This also requires a bump to lsp-test to fix a test, and drops the
trick that the wrapper tests used to find the wrapper executable since
it was just confusing
2020-07-27 15:11:10 +01:00

33 lines
1012 B
Haskell

import Data.List
import Data.Char
import Test.Hls.Util
import Test.Tasty
import Test.Tasty.HUnit
import System.Process
main :: IO ()
main = do
flushStackEnvironment
defaultMain $
testGroup "haskell-language-server-wrapper" [projectGhcVersionTests]
projectGhcVersionTests :: TestTree
projectGhcVersionTests = testGroup "--project-ghc-version"
[ testCase "stack with ghc 8.10.1" $
testDir "test/wrapper/testdata/stack-8.10.1" "8.10.1"
, testCase "stack with ghc 8.8.3" $
testDir "test/wrapper/testdata/stack-8.8.3" "8.8.3"
, testCase "cabal with global ghc" $ do
ghcVer <- trim <$> readProcess "ghc" ["--numeric-version"] ""
testDir "test/wrapper/testdata/cabal-cur-ver" ghcVer
]
testDir :: FilePath -> String -> Assertion
testDir dir expectedVer =
withCurrentDirectoryInTmp dir $ do
actualVer <- trim <$> readProcess "haskell-language-server-wrapper" ["--project-ghc-version"] ""
actualVer @?= expectedVer
trim :: String -> String
trim = dropWhileEnd isSpace