packages feed

lsp-test 0.2.1.0 → 0.3.0.0

raw patch · 7 files changed

+40/−24 lines, 7 filesdep ~basedep ~haskell-lsp

Dependency ranges changed: base, haskell-lsp

Files

lsp-test.cabal view
@@ -1,5 +1,5 @@ name:                lsp-test-version:             0.2.1.0+version:             0.3.0.0 synopsis:            Functional test framework for LSP servers. description:   A test framework for writing tests against @@ -36,7 +36,7 @@                      , parser-combinators:Control.Applicative.Combinators   default-language:    Haskell2010   build-depends:       base >= 4.7 && < 5-                     , haskell-lsp >= 0.6+                     , haskell-lsp >= 0.7                      , aeson                      , aeson-pretty                      , ansi-terminal@@ -78,7 +78,7 @@   build-depends:       base >= 4.7 && < 5                      , hspec                      , lens-                     , haskell-lsp+                     , haskell-lsp >= 0.7                      , lsp-test                      , data-default                      , aeson
src/Language/Haskell/LSP/Test.hs view
@@ -23,7 +23,7 @@   , runSessionWithConfig   , SessionConfig(..)   , defaultConfig-  , module Language.Haskell.LSP.Types.Capabilities+  , C.fullCaps   -- ** Exceptions   , module Language.Haskell.LSP.Test.Exceptions   , withTimeout@@ -91,9 +91,10 @@ import qualified Data.HashMap.Strict as HashMap import qualified Data.Map as Map import Data.Maybe-import Language.Haskell.LSP.Types hiding (id, capabilities, message)+import Language.Haskell.LSP.Types hiding+  (id, capabilities, message, executeCommand, applyEdit, rename) import qualified Language.Haskell.LSP.Types as LSP-import Language.Haskell.LSP.Types.Capabilities+import qualified Language.Haskell.LSP.Types.Capabilities as C import Language.Haskell.LSP.Messages import Language.Haskell.LSP.VFS import Language.Haskell.LSP.Test.Compat@@ -116,7 +117,7 @@ -- >       params = TextDocumentPositionParams doc -- >   hover <- request TextDocumentHover params runSession :: String -- ^ The command to run the server.-           -> ClientCapabilities -- ^ The capabilities that the client should declare.+           -> 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@@ -125,7 +126,7 @@ -- | Starts a new sesion with a custom configuration. runSessionWithConfig :: SessionConfig -- ^ Configuration options for the session.                      -> String -- ^ The command to run the server.-                     -> ClientCapabilities -- ^ The capabilities that the client should declare.+                     -> 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@@ -139,6 +140,7 @@                                           Nothing                                           caps                                           (Just TraceOff)+                                          Nothing   withServer serverExe (logStdErr config) $ \serverIn serverOut _ ->     runSessionWithHandles serverIn serverOut listenServer config caps rootDir $ do @@ -441,9 +443,9 @@   caps <- asks sessionCapabilities    let supportsDocChanges = fromMaybe False $ do-        let ClientCapabilities mWorkspace _ _ = caps-        WorkspaceClientCapabilities _ mEdit _ _ _ _ _ _ <- mWorkspace-        WorkspaceEditClientCapabilities mDocChanges <- mEdit+        let C.ClientCapabilities mWorkspace _ _ = caps+        C.WorkspaceClientCapabilities _ mEdit _ _ _ _ _ _ <- mWorkspace+        C.WorkspaceEditClientCapabilities mDocChanges <- mEdit         mDocChanges    let wEdit = if supportsDocChanges
src/Language/Haskell/LSP/Test/Exceptions.hs view
@@ -3,6 +3,7 @@ import Control.Exception import Language.Haskell.LSP.Messages import Language.Haskell.LSP.Types+import Data.Aeson import Data.Aeson.Encode.Pretty import Data.Algorithm.Diff import Data.Algorithm.DiffOutput@@ -34,6 +35,7 @@     in "Replay is out of order:\n" ++        -- Print json so its a bit easier to update the session logs        "Received from server:\n" ++ B.unpack (encodePretty received) ++ "\n" +++       "Raw from server:\n" ++ B.unpack (encode received) ++ "\n" ++        "Expected one of:\n" ++ unlines (map showExp expected')   show UnexpectedDiagnostics = "Unexpectedly received diagnostics from the server."   show (IncorrectApplyEditRequest msgStr) = "ApplyEditRequest didn't contain document, instead received:\n"
src/Language/Haskell/LSP/Test/Messages.hs view
@@ -81,6 +81,11 @@     (RspDocumentLink             m) -> response m     (RspDocumentLinkResolve      m) -> response m     (RspWillSaveWaitUntil        m) -> response m+    (RspTypeDefinition           m) -> response m+    (RspImplementation           m) -> response m+    (RspDocumentColor            m) -> response m+    (RspColorPresentation        m) -> response m+    (RspFoldingRange             m) -> response m     (NotPublishDiagnostics       m) -> notification m     (NotLogMessage               m) -> notification m     (NotShowMessage              m) -> notification m@@ -117,6 +122,11 @@  (ReqDocumentLink             m) -> request m  (ReqDocumentLinkResolve      m) -> request m  (ReqWillSaveWaitUntil        m) -> request m+ (ReqImplementation           m) -> request m+ (ReqTypeDefinition           m) -> request m+ (ReqDocumentColor            m) -> request m+ (ReqColorPresentation        m) -> request m+ (ReqFoldingRange             m) -> request m  (RspApplyWorkspaceEdit       m) -> response m  (RspFromClient               m) -> response m  (NotInitialized              m) -> notification m@@ -129,4 +139,5 @@  (NotWillSaveTextDocument     m) -> notification m  (NotDidSaveTextDocument      m) -> notification m  (NotDidChangeWatchedFiles    m) -> notification m+ (NotDidChangeWorkspaceFolders m) -> notification m  (UnknownFromClientMessage    m) -> error $ "Unknown message sent from client: " ++ show m
src/Language/Haskell/LSP/Test/Replay.hs view
@@ -20,6 +20,7 @@ import           Control.Lens hiding (List) import           Control.Monad import           System.FilePath+import           System.IO import           Language.Haskell.LSP.Test import           Language.Haskell.LSP.Test.Files import           Language.Haskell.LSP.Test.Decoding@@ -27,7 +28,6 @@ import           Language.Haskell.LSP.Test.Server import           Language.Haskell.LSP.Test.Session - -- | Replays a captured client output and  -- makes sure it matches up with an expected response. -- The session directory should have a captured session file in it@@ -133,15 +133,15 @@ isNotification (NotCancelRequestFromServer _) = True isNotification _                              = False --- listenServer :: [FromServerMessage]---              -> RequestMap---              -> MVar LspId---              -> MVar LspIdRsp---              -> MVar ()---              -> ThreadId---              -> Handle---              -> SessionContext---              -> IO ()+listenServer :: [FromServerMessage]+             -> RequestMap+             -> MVar LspId+             -> MVar LspIdRsp+             -> MVar ()+             -> ThreadId+             -> Handle+             -> SessionContext+             -> IO () listenServer [] _ _ _ passSema _ _ _ = putMVar passSema () listenServer expectedMsgs reqMap reqSema rspSema passSema mainThreadId serverOut ctx = do 
src/Language/Haskell/LSP/Test/Session.hs view
@@ -78,7 +78,7 @@  -- | The configuration used in 'Language.Haskell.LSP.Test.runSession'. defaultConfig :: SessionConfig-defaultConfig = SessionConfig 60 False True True+defaultConfig = SessionConfig 60 False False True  instance Default SessionConfig where   def = defaultConfig
test/Test.hs view
@@ -18,7 +18,8 @@ import           Language.Haskell.LSP.Messages import           Language.Haskell.LSP.Test import           Language.Haskell.LSP.Test.Replay-import           Language.Haskell.LSP.Types as LSP hiding (capabilities, message)+import           Language.Haskell.LSP.Types as LSP hiding (capabilities, message, rename, applyEdit)+import           Language.Haskell.LSP.Types.Capabilities as LSP import           System.Timeout  {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-}@@ -206,7 +207,7 @@       liftIO $ do         mainSymbol ^. name `shouldBe` "main"         mainSymbol ^. kind `shouldBe` SkFunction-        mainSymbol ^. range `shouldBe` Range (Position 3 0) (Position 3 4)+        mainSymbol ^. range `shouldBe` Range (Position 3 0) (Position 5 30)    describe "applyEdit" $ do     it "increments the version" $ runSession "hie --lsp" docChangesCaps "test/data/renamePass" $ do