X-Git-Url: http://git.lukelau.me/?p=opengl.git;a=blobdiff_plain;f=test%2FTest.hs;h=3c53aec67dd292859abc0285e939da6d3d3d532f;hp=c8d6072f6ec386a88185937e2091dbaac12ab32d;hb=bd6901688e6c9d8332fea161260d32666885f9ed;hpb=493d20ada6e48a8987e00a5ec92a1b31fe3c9b8c diff --git a/test/Test.hs b/test/Test.hs index c8d6072..3c53aec 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -64,31 +64,35 @@ main = hspec $ do return () in sesh `shouldThrow` anySessionException - it "don't throw when no time out" $ runSessionWithConfig (def {timeout = 10}) "hie --lsp" "test/data/renamePass" $ do + it "don't throw when no time out" $ runSessionWithConfig (def {timeout = 5}) "hie --lsp" "test/data/renamePass" $ do loggingNotification - liftIO $ threadDelay 5 + liftIO $ threadDelay 10 + _ <- openDoc "Desktop/simple.hs" "haskell" + return () it "throw when there's an unexpected message" $ - let msgExc (UnexpectedMessageException "Publish diagnostics notification" (NotLogMessage _)) = True - msgExc _ = False - in runSession "hie --lsp" "test/data/renamePass" publishDiagnosticsNotification `shouldThrow` msgExc + let selector (UnexpectedMessageException "Publish diagnostics notification" (NotLogMessage _)) = True + selector _ = False + in runSession "hie --lsp" "test/data/renamePass" publishDiagnosticsNotification `shouldThrow` selector it "throw when there's an unexpected message 2" $ - let msgExc (UnexpectedMessageException "Response" (NotPublishDiagnostics _)) = True - msgExc _ = False + let selector (UnexpectedMessageException "Response" (NotPublishDiagnostics _)) = True + selector _ = False sesh = do doc <- openDoc "Desktop/simple.hs" "haskell" sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc) skipMany anyNotification response :: Session RenameResponse -- the wrong type in runSession "hie --lsp" "test/data/renamePass" sesh - `shouldThrow` msgExc + `shouldThrow` selector describe "replay session" $ do it "passes a test" $ - replaySession "hie --lsp" "test/data/renamePass" `shouldReturn` True + replaySession "hie --lsp" "test/data/renamePass" it "fails a test" $ - replaySession "hie --lsp" "test/data/renameFail" `shouldReturn` False + let selector (ReplayOutOfOrderException _ _) = True + selector _ = False + in replaySession "hie --lsp" "test/data/renameFail" `shouldThrow` selector describe "manual javascript session" $ it "passes a test" $