Skip to content

Commit 2a05e7e

Browse files
committed
Make testIde more like Test.Hls.runSessionWithServer'
1 parent c772829 commit 2a05e7e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

ghcide/test/exe/Main.hs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5362,13 +5362,23 @@ testIde arguments session = do
53625362
config <- getConfigFromEnv
53635363
(hInRead, hInWrite) <- createPipe
53645364
(hOutRead, hOutWrite) <- createPipe
5365-
let server = IDE.defaultMain arguments
5365+
server <- async $ IDE.defaultMain arguments
53665366
{ IDE.argsHandleIn = pure hInRead
53675367
, IDE.argsHandleOut = pure hOutWrite
5368+
, IDE.argsIdeOptions = \config sessionLoader ->
5369+
let ideOptions = (argsIdeOptions def config sessionLoader) {optTesting = IdeTesting True}
5370+
in ideOptions {optShakeOptions = (optShakeOptions ideOptions) {shakeThreads = 2}}
53685371
}
53695372

5370-
withAsync server $ \_ ->
5371-
runSessionWithHandles hInWrite hOutRead config lspTestCaps "." session
5373+
runSessionWithHandles hInWrite hOutRead config lspTestCaps "." session
5374+
5375+
hClose inw
5376+
timeout 3 (wait server) >>= \case
5377+
Just () -> pure ()
5378+
Nothing -> do
5379+
putStrLn "Server does not exit in 3s, canceling the async task..."
5380+
(t, _) <- duration $ cancel server
5381+
putStrLn $ "Finishing canceling (took " <> showDuration t <> "s)"
53725382

53735383
positionMappingTests :: TestTree
53745384
positionMappingTests =

0 commit comments

Comments
 (0)