From: Luke Lau Date: Sat, 20 Jul 2019 19:51:41 +0000 (+0100) Subject: Don't use exitServer in Replay X-Git-Tag: 0.6.1.0~2^2~6^2 X-Git-Url: http://git.lukelau.me/?p=lsp-test.git;a=commitdiff_plain;h=f0a961503e19c2d281c3d6319df1096f5bf6cfcf Don't use exitServer in Replay It's not needed since the captured session should contain it anyway --- diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 016abc2..1b2e7ba 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -37,9 +37,8 @@ module Language.Haskell.LSP.Test , module Language.Haskell.LSP.Test.Parsing -- * Utilities -- | Quick helper functions for common tasks. - -- ** Lifecycle + -- ** Initialization , initializeResponse - , exitServer -- ** Documents , openDoc , openDoc' @@ -138,7 +137,6 @@ runSessionWithConfig :: SessionConfig -- ^ Configuration options for the session -> Session a -- ^ The session to run. -> IO a runSessionWithConfig config serverExe caps rootDir session = do - pid <- getCurrentProcessID absRootDir <- canonicalizePath rootDir @@ -168,6 +166,10 @@ runSessionWithConfig config serverExe caps rootDir session = do result <- session return result where + -- | Asks the server to shutdown and exit politely + exitServer :: Session () + exitServer = request_ Shutdown (Nothing :: Maybe Value) >> sendNotification Exit ExitParams + -- | Listens to the server output until the shutdown ack, -- makes sure it matches the record and signals any semaphores listenServer :: Handle -> SessionContext -> IO () @@ -575,7 +577,3 @@ getCodeLenses tId = do rsp <- request TextDocumentCodeLens (CodeLensParams tId) :: Session CodeLensResponse case getResponseResult rsp of List res -> pure res - --- | Exit the server after request its shutdown -exitServer :: Session() -exitServer = request_ Shutdown (Nothing :: Maybe Value) >> sendNotification Exit ExitParams diff --git a/src/Language/Haskell/LSP/Test/Replay.hs b/src/Language/Haskell/LSP/Test/Replay.hs index b20eb08..ac55e9e 100644 --- a/src/Language/Haskell/LSP/Test/Replay.hs +++ b/src/Language/Haskell/LSP/Test/Replay.hs @@ -66,7 +66,7 @@ replaySession serverExe sessionDir = do def fullCaps sessionDir - exitServer + (return ()) -- No finalizer cleanup (sendMessages clientMsgs reqSema rspSema) takeMVar passSema killThread sessionThread diff --git a/src/Language/Haskell/LSP/Test/Session.hs b/src/Language/Haskell/LSP/Test/Session.hs index bbfdf38..4d75d1d 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -198,7 +198,6 @@ runSessionWithHandles :: Handle -- ^ Server in -> Session a -> IO a runSessionWithHandles serverIn serverOut serverProc serverHandler config caps rootDir exitServer session = do - absRootDir <- canonicalizePath rootDir hSetBuffering serverIn NoBuffering