@@ -27,7 +27,7 @@ import Data.ByteString.Lazy (ByteString)
27
27
import Data.Default (def )
28
28
import qualified Data.Text as T
29
29
import Development.IDE (IdeState , hDuplicateTo' ,
30
- noLogging )
30
+ )
31
31
import Development.IDE.Main
32
32
import qualified Development.IDE.Main as Ghcide
33
33
import qualified Development.IDE.Plugin.HLS.GhcIde as Ghcide
@@ -98,7 +98,7 @@ runSessionWithServer' ::
98
98
FilePath ->
99
99
Session a ->
100
100
IO a
101
- runSessionWithServer' plugin conf sconf caps root s = silenceStderr $ do
101
+ runSessionWithServer' plugin conf sconf caps root s = do
102
102
(inR, inW) <- createPipe
103
103
(outR, outW) <- createPipe
104
104
-- 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
110
110
{ argsHandleIn = pure inR,
111
111
argsHandleOut = pure outW,
112
112
argsDefaultHlsConfig = conf,
113
- argsLogger = pure noLogging,
114
113
argsIdeOptions = \ config sessionLoader ->
115
114
let ideOptions = (argsIdeOptions def config sessionLoader) {optTesting = IdeTesting True }
116
115
in ideOptions {optShakeOptions = (optShakeOptions ideOptions) {shakeThreads = 2 }},
117
116
argsHlsPlugins = pluginDescToIdePlugins $ plugin ++ Ghcide. descriptors
118
117
}
119
118
120
- x <-
121
- runSessionWithHandles inW outR sconf caps root s
122
- `finally` setCurrentDirectory cwd
119
+ x <- runSessionWithHandles inW outR sconf caps root s
123
120
timeout 3 (wait server) >>= \ case
124
121
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
126
128
pure x
0 commit comments