Add ignoreLogNotifications config option
[lsp-test.git] / test / Test.hs
index 75e16283b49895b6dae4eee1737c7dc92a5acf50..dc770d9205efc21e22147660380470316ed371a1 100644 (file)
@@ -91,7 +91,9 @@ main = hspec $ do
                 getDocumentSymbols doc
                 -- should now timeout
                 skipManyTill anyMessage message :: Session ApplyWorkspaceEditRequest
-        in sesh `shouldThrow` (== Timeout)
+            isTimeout (Timeout _) = True
+            isTimeout _ = False
+        in sesh `shouldThrow` isTimeout
 
 
     describe "SessionException" $ do
@@ -118,7 +120,7 @@ main = hspec $ do
               selector _ = False
               sesh = do
                 doc <- openDoc "Desktop/simple.hs" "haskell"
-                sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc)
+                sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc Nothing)
                 skipMany anyNotification
                 message :: Session RenameResponse -- the wrong type
             in runSession "hie" fullCaps "test/data/renamePass" sesh
@@ -154,7 +156,7 @@ main = hspec $ do
         let args = toJSON $ AOP (doc ^. uri)
                                 (Position 1 14)
                                 "Redundant bracket"
-            reqParams = ExecuteCommandParams "applyrefact:applyOne" (Just (List [args]))
+            reqParams = ExecuteCommandParams "applyrefact:applyOne" (Just (List [args])) Nothing
         request_ WorkspaceExecuteCommand reqParams
 
         editReq <- message :: Session ApplyWorkspaceEditRequest
@@ -177,7 +179,7 @@ main = hspec $ do
         let args = toJSON $ AOP (doc ^. uri)
                                 (Position 1 14)
                                 "Redundant bracket"
-            reqParams = ExecuteCommandParams "applyrefact:applyOne" (Just (List [args]))
+            reqParams = ExecuteCommandParams "applyrefact:applyOne" (Just (List [args])) Nothing
         request_ WorkspaceExecuteCommand reqParams
         contents <- getDocumentEdit doc
         liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42\n"
@@ -238,7 +240,8 @@ main = hspec $ do
       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 +276,10 @@ main = hspec $ do
   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
@@ -330,6 +333,12 @@ main = hspec $ do
           pred _ = False
       void $ satisfy pred
 
+  describe "ignoreLogNotifications" $
+    it "works" $
+      runSessionWithConfig (defaultConfig { ignoreLogNotifications = True }) "hie"  fullCaps "test/data" $ do
+        openDoc "Format.hs" "haskell"
+        void publishDiagnosticsNotification
+
 mkRange sl sc el ec = Range (Position sl sc) (Position el ec)
 
 didChangeCaps :: ClientCapabilities