Skip to content

Commit 4fa0129

Browse files
committed
Emit error assertion when session timeout
1 parent 146c104 commit 4fa0129

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

test/functional/FunctionalCodeAction.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ hlintTests = testGroup "hlint suggestions" [
142142
expectNoMoreDiagnostics 3 doc "hlint"
143143
]
144144
where
145-
runHlintSession subdir = runSession hlsCommand fullCaps $ "test/testdata/hlint" </> subdir
145+
runHlintSession :: FilePath -> Session a -> IO a
146+
runHlintSession subdir =
147+
failIfSessionTimeout . runSession hlsCommand fullCaps ("test/testdata/hlint" </> subdir)
146148

147149
noHlintDiagnostics :: [Diagnostic] -> Assertion
148150
noHlintDiagnostics diags =

test/utils/Test/Hls/Util.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
{-# LANGUAGE CPP, OverloadedStrings, NamedFieldPuns #-}
1+
{-# LANGUAGE CPP, OverloadedStrings, NamedFieldPuns, MultiParamTypeClasses #-}
22
module Test.Hls.Util
33
(
44
codeActionSupportCaps
55
, dummyLspFuncs
66
, expectCodeAction
77
, expectDiagnostic
88
, expectNoMoreDiagnostics
9+
, failIfSessionTimeout
910
, flushStackEnvironment
1011
, fromAction
1112
, fromCommand
@@ -31,6 +32,7 @@ module Test.Hls.Util
3132
)
3233
where
3334

35+
import Control.Exception (throwIO, catch)
3436
import Control.Monad
3537
import Control.Monad.IO.Class
3638
import Control.Applicative.Combinators (skipManyTill, (<|>))
@@ -415,3 +417,9 @@ waitForDiagnosticsFromSourceWithTimeout timeout document source = do
415417
| otherwise = Nothing
416418

417419
ignoreOthers = void Test.anyMessage >> handleMessages
420+
421+
failIfSessionTimeout :: IO a -> IO a
422+
failIfSessionTimeout action = action `catch` errorHandler
423+
where errorHandler :: Test.SessionException -> IO a
424+
errorHandler e@(Test.Timeout _) = assertFailure $ show e
425+
errorHandler e = throwIO e

0 commit comments

Comments
 (0)