From: Luke Lau Date: Thu, 6 Dec 2018 22:09:57 +0000 (+0000) Subject: Merge branch 'master' into travis-windows X-Git-Url: http://git.lukelau.me/?a=commitdiff_plain;h=d9e5c22f6c996a74ac8a4daca0e64003798a723d;hp=fb298fd04d74cbff4e09b38d11a41c816b9672b5;p=lsp-test.git Merge branch 'master' into travis-windows --- diff --git a/.travis.yml b/.travis.yml index 8b89afd..4d0f052 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,12 +37,12 @@ before_install: - git init - git remote add origin https://github.com/haskell/haskell-ide-engine.git - git pull origin master - - git checkout ed512e250b8699d212417191064e5fbbc0ecdac8 + - git checkout 1a5640f4790bde364dcd0a61617c5ca5b85b145a - git submodule init - git submodule sync - git submodule update --init - - stack --no-terminal --skip-ghc-check -j2 install - - stack exec hoogle generate + - stack --no-terminal --skip-ghc-check -j2 install --stack-yaml=stack-8.6.2.yaml + - stack exec hoogle generate --stack-yaml=stack-8.6.2.yaml - cd $TRAVIS_BUILD_DIR - npm update - npm i -g javascript-typescript-langserver diff --git a/src/Language/Haskell/LSP/Test/Decoding.hs b/src/Language/Haskell/LSP/Test/Decoding.hs index b3929ab..7756734 100644 --- a/src/Language/Haskell/LSP/Test/Decoding.hs +++ b/src/Language/Haskell/LSP/Test/Decoding.hs @@ -13,6 +13,7 @@ import Language.Haskell.LSP.Types import Language.Haskell.LSP.Types.Lens hiding ( error ) import Language.Haskell.LSP.Messages +import Language.Haskell.LSP.Test.Exceptions import qualified Data.HashMap.Strict as HM getAllMessages :: Handle -> IO [B.ByteString] @@ -49,7 +50,7 @@ getHeaders h = do let (name, val) = span (/= ':') l if null val then return [] else ((name, drop 2 val) :) <$> getHeaders h where eofHandler e - | isEOFError e = error "Language Server unexpectedly terminated" + | isEOFError e = throw UnexpectedServerTermination | otherwise = throw e type RequestMap = HM.HashMap LspId ClientMethod diff --git a/src/Language/Haskell/LSP/Test/Exceptions.hs b/src/Language/Haskell/LSP/Test/Exceptions.hs index e1e281f..b1e0635 100644 --- a/src/Language/Haskell/LSP/Test/Exceptions.hs +++ b/src/Language/Haskell/LSP/Test/Exceptions.hs @@ -17,6 +17,7 @@ data SessionException = Timeout | UnexpectedDiagnostics | IncorrectApplyEditRequest String | UnexpectedResponseError LspIdRsp ResponseError + | UnexpectedServerTermination deriving Eq instance Exception SessionException @@ -42,6 +43,7 @@ instance Show SessionException where ++ msgStr show (UnexpectedResponseError lid e) = "Received an exepected error in a response for id " ++ show lid ++ ":\n" ++ show e + show UnexpectedServerTermination = "Language server unexpectedly terminated" -- | A predicate that matches on any 'SessionException' anySessionException :: SessionException -> Bool diff --git a/src/Language/Haskell/LSP/Test/Session.hs b/src/Language/Haskell/LSP/Test/Session.hs index a153cba..700d9cc 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -201,9 +201,12 @@ runSessionWithHandles serverIn serverOut serverHandler config caps rootDir sessi messageChan <- newChan initRsp <- newEmptyMVar + mainThreadId <- myThreadId + let context = SessionContext serverIn absRootDir messageChan reqMap initRsp config caps initState = SessionState (IdInt 0) mempty mempty 0 False Nothing - launchServerHandler = forkIO $ void $ serverHandler serverOut context + launchServerHandler = forkIO $ catch (serverHandler serverOut context) + (throwTo mainThreadId :: SessionException -> IO ()) (result, _) <- bracket launchServerHandler killThread $ const $ runSession context initState session @@ -332,3 +335,4 @@ logMsg t msg = do | otherwise = Cyan showPretty = B.unpack . encodePretty +