@@ -27,7 +27,7 @@ import Data.ByteString.Lazy (ByteString)
2727import Data.Default (def )
2828import qualified Data.Text as T
2929import Development.IDE (IdeState , hDuplicateTo' ,
30- noLogging )
30+ )
3131import Development.IDE.Main
3232import qualified Development.IDE.Main as Ghcide
3333import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide
@@ -98,7 +98,7 @@ runSessionWithServer' ::
9898 FilePath ->
9999 Session a ->
100100 IO a
101- runSessionWithServer' plugin conf sconf caps root s = silenceStderr $ do
101+ runSessionWithServer' plugin conf sconf caps root s = do
102102 (inR, inW) <- createPipe
103103 (outR, outW) <- createPipe
104104 -- restore cwd after running the session; otherwise the path to test data will be invalid
@@ -110,17 +110,19 @@ runSessionWithServer' plugin conf sconf caps root s = silenceStderr $ do
110110 { argsHandleIn = pure inR,
111111 argsHandleOut = pure outW,
112112 argsDefaultHlsConfig = conf,
113- argsLogger = pure noLogging,
114113 argsIdeOptions = \ config sessionLoader ->
115114 let ideOptions = (argsIdeOptions def config sessionLoader) {optTesting = IdeTesting True }
116115 in ideOptions {optShakeOptions = (optShakeOptions ideOptions) {shakeThreads = 2 }},
117116 argsHlsPlugins = pluginDescToIdePlugins $ plugin ++ Ghcide. descriptors
118117 }
119118
120- x <-
121- runSessionWithHandles inW outR sconf caps root s
122- `finally` setCurrentDirectory cwd
119+ x <- runSessionWithHandles inW outR sconf caps root s
123120 timeout 3 (wait server) >>= \ case
124121 Just () -> pure ()
125- Nothing -> putStrLn " Server does not exit on time, canceling the async task..." >> cancel server
122+ Nothing -> do
123+ putStrLn " Server does not exit in 3s, canceling the async task..."
124+ (t, _) <- duration $ cancel server
125+ putStrLn $ " Finishing canceling (took " <> showDuration t <> " s)"
126+ setCurrentDirectory cwd
127+ sleep 0.05
126128 pure x
0 commit comments