Skip to content

Commit 796b292

Browse files
authored
Fix hls-call-hierarchy-plugin tests (#2888)
* Wait for kick done * Enable test on Windows * Wait for kick done
1 parent 8a5c7fc commit 796b292

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ jobs:
214214
name: Test hls-explicit-imports-plugin test suite
215215
run: cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS" || cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-explicit-imports-plugin --test-options="$TEST_OPTS"
216216

217-
- if: matrix.test && matrix.os != 'windows-latest'
217+
- if: matrix.test
218218
name: Test hls-call-hierarchy-plugin test suite
219219
run: cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS" || cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-call-hierarchy-plugin --test-options="$TEST_OPTS"
220220

plugins/hls-call-hierarchy-plugin/test/Main.hs

+15-6
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ incomingCallsTests =
197197
testCase "xdata unavailable" $
198198
runSessionWithServer plugin testDataDir $ do
199199
doc <- createDoc "A.hs" "haskell" $ T.unlines ["a=3", "b=a"]
200+
waitForKickDone
200201
[item] <- Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc 1 0)
201202
let expected = [CallHierarchyIncomingCall item (List [mkRange 1 2 1 3])]
202203
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc 0 0) >>=
@@ -321,6 +322,7 @@ outgoingCallsTests =
321322
testCase "xdata unavailable" $ withTempDir $ \dir ->
322323
runSessionWithServer plugin dir $ do
323324
doc <- createDoc "A.hs" "haskell" $ T.unlines ["a=3", "b=a"]
325+
waitForKickDone
324326
[item] <- Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc 0 1)
325327
let expected = [CallHierarchyOutgoingCall item (List [mkRange 1 2 1 3])]
326328
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc 1 0) >>=
@@ -424,6 +426,7 @@ incomingCallTestCase :: T.Text -> Int -> Int -> [(Int, Int)] -> [Range] -> Asser
424426
incomingCallTestCase contents queryX queryY positions ranges = withTempDir $ \dir ->
425427
runSessionWithServer plugin dir $ do
426428
doc <- createDoc "A.hs" "haskell" contents
429+
waitForKickDone
427430
items <- concatMapM (\((x, y), range) ->
428431
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc x y)
429432
<&> map (, range)
@@ -443,9 +446,11 @@ incomingCallMultiFileTestCase :: FilePath -> Int -> Int -> M.Map FilePath [((Int
443446
incomingCallMultiFileTestCase filepath queryX queryY mp =
444447
runSessionWithServer plugin testDataDir $ do
445448
doc <- openDoc filepath "haskell"
446-
items <- fmap concat $ sequence $ M.elems $ M.mapWithKey (\fp pr ->
447-
openDoc fp "haskell" >>= \p ->
448-
concatMapM (\((x, y), range) ->
449+
waitForKickDone
450+
items <- fmap concat $ sequence $ M.elems $ M.mapWithKey (\fp pr -> do
451+
p <- openDoc fp "haskell"
452+
waitForKickDone
453+
concatMapM (\((x, y), range) ->
449454
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam p x y)
450455
<&> map (, range)
451456
) pr) mp
@@ -463,6 +468,7 @@ outgoingCallTestCase :: T.Text -> Int -> Int -> [(Int, Int)] -> [Range] -> Asser
463468
outgoingCallTestCase contents queryX queryY positions ranges = withTempDir $ \dir ->
464469
runSessionWithServer plugin dir $ do
465470
doc <- createDoc "A.hs" "haskell" contents
471+
waitForKickDone
466472
items <- concatMapM (\((x, y), range) ->
467473
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc x y)
468474
<&> map (, range)
@@ -481,9 +487,11 @@ outgoingCallMultiFileTestCase :: FilePath -> Int -> Int -> M.Map FilePath [((Int
481487
outgoingCallMultiFileTestCase filepath queryX queryY mp =
482488
runSessionWithServer plugin testDataDir $ do
483489
doc <- openDoc filepath "haskell"
484-
items <- fmap concat $ sequence $ M.elems $ M.mapWithKey (\fp pr ->
485-
openDoc fp "haskell" >>= \p ->
486-
concatMapM (\((x, y), range) ->
490+
waitForKickDone
491+
items <- fmap concat $ sequence $ M.elems $ M.mapWithKey (\fp pr -> do
492+
p <- openDoc fp "haskell"
493+
waitForKickDone
494+
concatMapM (\((x, y), range) ->
487495
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam p x y)
488496
<&> map (, range)
489497
) pr) mp
@@ -500,6 +508,7 @@ oneCaseWithCreate :: T.Text -> Int -> Int -> (Uri -> CallHierarchyItem) -> Asser
500508
oneCaseWithCreate contents queryX queryY expected = withTempDir $ \dir ->
501509
runSessionWithServer plugin dir $ do
502510
doc <- createDoc "A.hs" "haskell" contents
511+
waitForKickDone
503512
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc queryX queryY) >>=
504513
\case
505514
[item] -> liftIO $ item @?= expected (doc ^. L.uri)

0 commit comments

Comments
 (0)