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
{-# 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" $
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
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
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
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
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"
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
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
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