Merge branch 'master' into github-actions
[lsp-test.git] / test / Test.hs
index 342d889f464d73ce9435c56148bc428c5a7844ae..ed8c6b5f5f0c6ce0e8d2b88fd8bbe40bcf0f7efb 100644 (file)
@@ -16,7 +16,7 @@ import           Control.Monad
 import           Control.Lens hiding (List)
 import           GHC.Generics
 import           Language.Haskell.LSP.Messages
-import           Language.Haskell.LSP.Test
+import           Language.Haskell.LSP.Test hiding (runSession)
 import           Language.Haskell.LSP.Test.Replay
 import           Language.Haskell.LSP.Types
 import           Language.Haskell.LSP.Types.Lens as LSP hiding
@@ -27,6 +27,8 @@ import           System.Timeout
 {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-}
 {-# ANN module ("HLint: ignore Unnecessary hiding" :: String) #-}
 
+runSession = runSessionWithConfig (defaultConfig { logStdErr = True })
+
 main = hspec $ do
   describe "Session" $ do
     it "fails a test" $
@@ -44,7 +46,7 @@ main = hspec $ do
 
     describe "withTimeout" $ do
       it "times out" $
-        let sesh = runSession "hie" fullCaps "test/data/renamePass" $ do
+        let sesh = runSession "hie -d --bios-verbose" fullCaps "test/data/renamePass" $ do
                     openDoc "Desktop/simple.hs" "haskell"
                     -- won't receive a request - will timeout
                     -- incoming logging requests shouldn't increase the
@@ -91,7 +93,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
@@ -331,6 +335,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