Skip to content

Commit e1e57d0

Browse files
committed
Cancel the server action when timeout
1 parent b40d923 commit e1e57d0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

hls-test-utils/src/Test/Hls.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE LambdaCase #-}
12
module Test.Hls
23
( module Test.Tasty.HUnit,
34
module Test.Tasty,
@@ -19,7 +20,7 @@ module Test.Hls
1920
where
2021

2122
import Control.Applicative.Combinators
22-
import Control.Concurrent.Async (async, wait)
23+
import Control.Concurrent.Async (async, cancel, wait)
2324
import Control.Exception.Base
2425
import Control.Monad.IO.Class
2526
import Data.ByteString.Lazy (ByteString)
@@ -119,6 +120,7 @@ runSessionWithServer' plugin conf sconf caps root s = silenceStderr $ do
119120
x <-
120121
runSessionWithHandles inW outR sconf caps root s
121122
`finally` setCurrentDirectory cwd
122-
wait server
123-
sleep 0.3
123+
timeout 3 (wait server) >>= \case
124+
Just () -> pure ()
125+
Nothing -> putStrLn "Server does not exit on time, canceling the async task..." >> cancel server
124126
pure x

0 commit comments

Comments
 (0)