Skip to content

Commit bdf8532

Browse files
committed
Multi component test suite: replace delays with waits
1 parent ddfb36c commit bdf8532

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

ghcide/test/exe/Main.hs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5493,12 +5493,10 @@ simpleMultiTest :: TestTree
54935493
simpleMultiTest = testCase "simple-multi-test" $ withLongTimeout $ runWithExtraFiles "multi" $ \dir -> do
54945494
let aPath = dir </> "a/A.hs"
54955495
bPath = dir </> "b/B.hs"
5496-
aSource <- liftIO $ readFileUtf8 aPath
5497-
adoc <- createDoc aPath "haskell" aSource
5496+
adoc <- openDoc aPath "haskell"
5497+
bdoc <- openDoc bPath "haskell"
54985498
WaitForIdeRuleResult {..} <- waitForAction "TypeCheck" adoc
54995499
liftIO $ assertBool "A should typecheck" ideResultSuccess
5500-
bSource <- liftIO $ readFileUtf8 bPath
5501-
bdoc <- createDoc bPath "haskell" bSource
55025500
WaitForIdeRuleResult {..} <- waitForAction "TypeCheck" bdoc
55035501
liftIO $ assertBool "B should typecheck" ideResultSuccess
55045502
locs <- getDefinitions bdoc (Position 2 7)
@@ -5511,15 +5509,14 @@ simpleMultiTest2 :: TestTree
55115509
simpleMultiTest2 = testCase "simple-multi-test2" $ runWithExtraFiles "multi" $ \dir -> do
55125510
let aPath = dir </> "a/A.hs"
55135511
bPath = dir </> "b/B.hs"
5514-
bSource <- liftIO $ readFileUtf8 bPath
5515-
bdoc <- createDoc bPath "haskell" bSource
5516-
expectNoMoreDiagnostics 10
5517-
aSource <- liftIO $ readFileUtf8 aPath
5518-
(TextDocumentIdentifier adoc) <- createDoc aPath "haskell" aSource
5519-
-- Need to have some delay here or the test fails
5520-
expectNoMoreDiagnostics 10
5512+
bdoc <- openDoc bPath "haskell"
5513+
WaitForIdeRuleResult {} <- waitForAction "TypeCheck" bdoc
5514+
adoc@(TextDocumentIdentifier auri) <- openDoc aPath "haskell"
5515+
WaitForIdeRuleResult {} <- waitForAction "TypeCheck" adoc
55215516
locs <- getDefinitions bdoc (Position 2 7)
5522-
let fooL = mkL adoc 2 0 2 3
5517+
let fooL = mkL auri 2 0 2 3
5518+
checkDefs locs (pure [fooL])
5519+
expectNoMoreDiagnostics 0.5
55235520
checkDefs locs (pure [fooL])
55245521
expectNoMoreDiagnostics 0.5
55255522

0 commit comments

Comments
 (0)