lsp-test 0.8.0.0 → 0.8.1.0
raw patch · 6 files changed
+30/−20 lines, 6 filesdep ~containersdep ~haskell-lspdep ~processPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: containers, haskell-lsp, process
API changes (from Hackage documentation)
Files
- ChangeLog.md +5/−0
- README.md +3/−0
- lsp-test.cabal +5/−5
- src/Language/Haskell/LSP/Test.hs +6/−6
- src/Language/Haskell/LSP/Test/Session.hs +7/−6
- test/Test.hs +4/−3
ChangeLog.md view
@@ -1,5 +1,10 @@ # Revision history for lsp-test +## 0.8.1.0 -- 2019-11-17++* Update to haskell-lsp-0.18.0.0 (@mpickering, @alanz)+* Tests now require hie-bios based hie+ ## 0.8.0.0 -- 2019-10-18 * Make `Session` a newtype
README.md view
@@ -46,3 +46,6 @@ `npm i -g javascript-typescript-langserver` Then run the tests with `stack test` or `cabal new-test`.++## Troubleshooting+Seeing funny stuff when running lsp-test via stack? If your server is built upon Haskell tooling, [keep in mind that stack sets some environment variables related to GHC, and you may want to unset them.](https://github.com/alanz/haskell-ide-engine/blob/bfb16324d396da71000ef81d51acbebbdaa854ab/test/utils/TestUtils.hs#L290-L298)
lsp-test.cabal view
@@ -1,5 +1,5 @@ name: lsp-test-version: 0.8.0.0+version: 0.8.1.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.10 && < 5- , haskell-lsp == 0.17.*+ , haskell-lsp == 0.18.* , aeson , aeson-pretty , ansi-terminal@@ -44,7 +44,7 @@ , bytestring , conduit , conduit-parse == 0.2.*- , containers+ , containers >= 0.5.9 , data-default , Diff , directory@@ -52,7 +52,7 @@ , lens , mtl , parser-combinators- , process+ , process >= 1.6 , rope-utf16-splay , text , transformers@@ -79,7 +79,7 @@ build-depends: base >= 4.10 && < 5 , hspec , lens- , haskell-lsp == 0.17.*+ , haskell-lsp == 0.18.* , lsp-test , data-default , aeson
src/Language/Haskell/LSP/Test.hs view
@@ -188,7 +188,7 @@ documentContents :: TextDocumentIdentifier -> Session T.Text documentContents doc = do vfs <- vfs <$> get- let file = vfs Map.! toNormalizedUri (doc ^. uri)+ let file = vfsMap vfs Map.! toNormalizedUri (doc ^. uri) return $ Rope.toText $ Language.Haskell.LSP.VFS._text file -- | Parses an ApplyEditRequest, checks that it is for the passed document@@ -273,7 +273,7 @@ n :: DidOpenTextDocumentNotification n = NotificationMessage "2.0" TextDocumentDidOpen params' oldVFS <- vfs <$> get- newVFS <- liftIO $ openVFS oldVFS n+ let (newVFS,_) = openVFS oldVFS n modify (\s -> s { vfs = newVFS }) sendMessage n @@ -283,7 +283,7 @@ n :: DidCloseTextDocumentNotification n = NotificationMessage "2.0" TextDocumentDidClose params' oldVFS <- vfs <$> get- newVFS <- liftIO $ closeVFS oldVFS n+ let (newVFS,_) = closeVFS oldVFS n modify (\s -> s { vfs = newVFS }) sendMessage n @@ -292,7 +292,7 @@ n :: DidChangeTextDocumentNotification n = NotificationMessage "2.0" TextDocumentDidChange params' oldVFS <- vfs <$> get- newVFS <- liftIO $ changeFromClientVFS oldVFS n+ let (newVFS,_) = changeFromClientVFS oldVFS n modify (\s -> s { vfs = newVFS }) sendMessage n @@ -449,10 +449,10 @@ -- | Adds the current version to the document, as tracked by the session. getVersionedDoc :: TextDocumentIdentifier -> Session VersionedTextDocumentIdentifier getVersionedDoc (TextDocumentIdentifier uri) = do- fs <- vfs <$> get+ fs <- vfsMap . vfs <$> get let ver = case fs Map.!? toNormalizedUri uri of- Just (VirtualFile v _ _) -> Just v+ Just (VirtualFile v _) -> Just v _ -> Nothing return (VersionedTextDocumentIdentifier uri ver)
src/Language/Haskell/LSP/Test/Session.hs view
@@ -220,8 +220,9 @@ mainThreadId <- myThreadId let context = SessionContext serverIn absRootDir messageChan reqMap initRsp config caps- initState = SessionState (IdInt 0) mempty mempty 0 False Nothing- runSession' = runSession context initState+ initState vfs = SessionState (IdInt 0) vfs+ mempty 0 False Nothing+ runSession' ses = initVFS $ \vfs -> runSession context (initState vfs) ses errorHandler = throwTo mainThreadId :: SessionException -> IO() serverListenerLauncher =@@ -280,8 +281,8 @@ forM_ bumpedVersions $ \(VersionedTextDocumentIdentifier uri v) -> modify $ \s -> let oldVFS = vfs s- update (VirtualFile oldV t mf) = VirtualFile (fromMaybe oldV v) t mf- newVFS = Map.adjust update (toNormalizedUri uri) oldVFS+ update (VirtualFile oldV t) = VirtualFile (fromMaybe oldV v) t+ newVFS = updateVFS (Map.adjust update (toNormalizedUri uri)) oldVFS in s { vfs = newVFS } where checkIfNeedsOpened uri = do@@ -289,7 +290,7 @@ ctx <- ask -- if its not open, open it- unless (toNormalizedUri uri `Map.member` oldVFS) $ do+ unless (toNormalizedUri uri `Map.member` (vfsMap oldVFS)) $ do let fp = fromJust $ uriToFilePath uri contents <- liftIO $ T.readFile fp let item = TextDocumentItem (filePathToUri fp) "" 0 contents@@ -297,7 +298,7 @@ liftIO $ B.hPut (serverIn ctx) $ addHeader (encode msg) modifyM $ \s -> do- newVFS <- liftIO $ openVFS (vfs s) msg+ let (newVFS,_) = openVFS (vfs s) msg return $ s { vfs = newVFS } getParams (TextDocumentEdit docId (List edits)) =
test/Test.hs view
@@ -238,7 +238,8 @@ noDiagnostics noDiagnostics - item:_ <- getCompletions doc (Position 5 5)+ comps <- getCompletions doc (Position 5 5)+ let item = head (filter (\x -> x ^. label == "interactWithUser") comps) liftIO $ do item ^. label `shouldBe` "interactWithUser" item ^. kind `shouldBe` Just CiFunction@@ -273,10 +274,10 @@ describe "waitForDiagnosticsSource" $ it "works" $ runSession "hie" fullCaps "test/data" $ do openDoc "Error.hs" "haskell"- [diag] <- waitForDiagnosticsSource "ghcmod"+ [diag] <- waitForDiagnosticsSource "bios" liftIO $ do diag ^. severity `shouldBe` Just DsError- diag ^. source `shouldBe` Just "ghcmod"+ diag ^. source `shouldBe` Just "bios" describe "rename" $ it "works" $ runSession "hie" fullCaps "test/data" $ do