X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=test%2FTest.hs;h=a639e38dbb1dd222bc5b202a513623d0a3b53f97;hb=7d0ddb8022d9cccc68a99008dd55c1d39ddda3e7;hp=e24b1e1c75d333f2327ac273bdcf2d7d9d8e127e;hpb=37aa4a22ec691b45bbd1cd0dd23d70e90a0c4e40;p=lsp-test.git diff --git a/test/Test.hs b/test/Test.hs index e24b1e1..a639e38 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -1,15 +1,50 @@ +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE OverloadedStrings #-} import Test.Hspec -import Language.Haskell.LSP.Test.Recorded +import Data.Maybe +import Control.Monad.IO.Class +import Control.Lens hiding (List) +import Language.Haskell.LSP.Test +import Language.Haskell.LSP.Test.Replay +import Language.Haskell.LSP.Types +import ParsingTests -main = hspec $ - describe "Replay" $ do +main = hspec $ do + describe "manual session" $ do it "passes a test" $ - replay "test/recordings/renamePass/client.log" - "test/recordings/renamePass/server.log" - "test/recordings/renamePass" - `shouldReturn` True + runSession "hie --lsp" "test/recordings/renamePass" $ do + doc <- openDoc "Desktop/simple.hs" "haskell" + + skipMany loggingNotification + + diagsNot <- notification :: Session PublishDiagnosticsNotification + + liftIO $ diagsNot ^. params . diagnostics `shouldBe` List [] + + sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc) + + rspSymbols <- response :: Session DocumentSymbolsResponse + + liftIO $ do + let (List symbols) = fromJust (rspSymbols ^. result) + mainSymbol = head symbols + mainSymbol ^. name `shouldBe` "main" + mainSymbol ^. kind `shouldBe` SkFunction + mainSymbol ^. location . range `shouldBe` Range (Position 3 0) (Position 3 4) + mainSymbol ^. containerName `shouldBe` Nothing + it "fails a test" $ - replay "test/recordings/documentSymbolFail/client.log" - "test/recordings/documentSymbolFail/server.log" - "test/recordings/documentSymbolFail" - `shouldReturn` False + -- TODO: Catch the exception in haskell-lsp-test and provide nicer output + let session = runSession "hie --lsp" "test/recordings/renamePass" $ do + openDoc "Desktop/simple.hs" "haskell" + skipMany loggingNotification + anyRequest + in session `shouldThrow` anyException + + describe "replay session" $ do + it "passes a test" $ + replaySession "hie --lsp" "test/recordings/renamePass" `shouldReturn` True + it "fails a test" $ + replaySession "hie --lsp" "test/recordings/renameFail" `shouldReturn` False + + parsingSpec