packages feed

lsp-test 0.14.0.3 → 0.14.1.0

raw patch · 5 files changed

+34/−14 lines, 5 filesdep +exceptionsdep ~lspdep ~lsp-typesPVP ok

version bump matches the API change (PVP)

Dependencies added: exceptions

Dependency ranges changed: lsp, lsp-types

API changes (from Hackage documentation)

+ Language.LSP.Test: runSessionWithConfigCustomProcess :: (CreateProcess -> CreateProcess) -> SessionConfig -> String -> ClientCapabilities -> FilePath -> Session a -> IO a
+ Language.LSP.Test: runSessionWithHandles' :: Maybe ProcessHandle -> Handle -> Handle -> SessionConfig -> ClientCapabilities -> FilePath -> Session a -> IO a

Files

ChangeLog.md view
@@ -1,5 +1,11 @@ # Revision history for lsp-test +## 0.14.1.0++* Compatibility with new `lsp-types` major version.+* Export `runSessionWithConfigCustomProcess` to allow modifying the CreateProcess used to start a server+* Add `MonadThrow` instance for `Session`+ ## 0.14.0.3  * Compatibility with new `lsp-types` major version.
lsp-test.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                lsp-test-version:             0.14.0.3+version:             0.14.1.0 synopsis:            Functional test framework for LSP servers. description:   A test framework for writing tests against@@ -36,8 +36,8 @@                      , parser-combinators:Control.Applicative.Combinators   default-language:    Haskell2010   build-depends:       base >= 4.10 && < 5-                     , lsp-types == 1.5.*-                     , lsp == 1.5.*+                     , lsp-types == 1.5.* || == 1.6.*+                     , lsp == 1.5.* || == 1.6.*                      , aeson                      , time                      , aeson-pretty@@ -51,6 +51,7 @@                      , data-default                      , Diff >= 0.3                      , directory+                     , exceptions                      , filepath                      , Glob >= 0.9 && < 0.11                      , lens@@ -83,7 +84,7 @@   build-depends:       base >= 4.10 && < 5                      , hspec                      , lens-                     , lsp == 1.5.*+                     , lsp == 1.6.*                      , lsp-test                      , data-default                      , aeson@@ -101,7 +102,7 @@   main-is:             FuncTest.hs   hs-source-dirs:      func-test   type:                exitcode-stdio-1.0-  build-depends:       base +  build-depends:       base                      , lsp-test                      , lsp                      , process
src/Language/LSP/Test.hs view
@@ -25,7 +25,9 @@     Session   , runSession   , runSessionWithConfig+  , runSessionWithConfigCustomProcess   , runSessionWithHandles+  , runSessionWithHandles'   -- ** Config   , SessionConfig(..)   , defaultConfig@@ -132,7 +134,7 @@ import System.IO import System.Directory import System.FilePath-import System.Process (ProcessHandle)+import System.Process (ProcessHandle, CreateProcess) import qualified System.FilePath.Glob as Glob import Control.Monad.State (execState) @@ -158,9 +160,19 @@                      -> FilePath -- ^ The filepath to the root directory for the session.                      -> Session a -- ^ The session to run.                      -> IO a-runSessionWithConfig config' serverExe caps rootDir session = do+runSessionWithConfig = runSessionWithConfigCustomProcess id++-- | Starts a new session with a custom configuration and server 'CreateProcess'.+runSessionWithConfigCustomProcess :: (CreateProcess -> CreateProcess) -- ^ Tweak the 'CreateProcess' used to start the server.+                                  -> SessionConfig -- ^ Configuration options for the session.+                                  -> String -- ^ The command to run the server.+                                  -> C.ClientCapabilities -- ^ The capabilities that the client should declare.+                                  -> FilePath -- ^ The filepath to the root directory for the session.+                                  -> Session a -- ^ The session to run.+                                  -> IO a+runSessionWithConfigCustomProcess modifyCreateProcess config' serverExe caps rootDir session = do   config <- envOverrideConfig config'-  withServer serverExe (logStdErr config) $ \serverIn serverOut serverProc ->+  withServer serverExe (logStdErr config) modifyCreateProcess $ \serverIn serverOut serverProc ->     runSessionWithHandles' (Just serverProc) serverIn serverOut config caps rootDir session  -- | Starts a new session, using the specified handles to communicate with the@@ -769,7 +781,7 @@ getSemanticTokens doc = do   let params = SemanticTokensParams Nothing Nothing doc   rsp <- request STextDocumentSemanticTokensFull params-  pure $ getResponseResult rsp +  pure $ getResponseResult rsp  -- | Returns a list of capabilities that the server has requested to /dynamically/ -- register during the 'Session'.
src/Language/LSP/Test/Server.hs view
@@ -6,13 +6,13 @@ import System.IO import System.Process hiding (withCreateProcess) -withServer :: String -> Bool -> (Handle -> Handle -> ProcessHandle -> IO a) -> IO a-withServer serverExe logStdErr f = do+withServer :: String -> Bool -> (CreateProcess -> CreateProcess) -> (Handle -> Handle -> ProcessHandle -> IO a) -> IO a+withServer serverExe logStdErr modifyCreateProcess f = do   -- TODO Probably should just change runServer to accept   -- separate command and arguments   let cmd:args = words serverExe       createProc = (proc cmd args) { std_in = CreatePipe, std_out = CreatePipe, std_err = CreatePipe }-  withCreateProcess createProc $ \(Just serverIn) (Just serverOut) (Just serverErr) serverProc -> do+  withCreateProcess (modifyCreateProcess createProc) $ \(Just serverIn) (Just serverOut) (Just serverErr) serverProc -> do     -- Need to continuously consume to stderr else it gets blocked     -- Can't pass NoStream either to std_err     hSetBuffering serverErr NoBuffering
src/Language/LSP/Test/Session.hs view
@@ -40,8 +40,9 @@ import Control.Exception import Control.Lens hiding (List, Empty) import Control.Monad-import Control.Monad.IO.Class+import Control.Monad.Catch (MonadThrow) import Control.Monad.Except+import Control.Monad.IO.Class #if __GLASGOW_HASKELL__ == 806 import Control.Monad.Fail #endif@@ -92,7 +93,7 @@ -- 'Language.LSP.Test.sendNotification'.  newtype Session a = Session (ConduitParser FromServerMessage (StateT SessionState (ReaderT SessionContext IO)) a)-  deriving (Functor, Applicative, Monad, MonadIO, Alternative)+  deriving (Functor, Applicative, Monad, MonadIO, Alternative, MonadThrow)  #if __GLASGOW_HASKELL__ >= 806 instance MonadFail Session where