Skip to content

Commit

Permalink
Fix hls-call-hierarchy-plugin tests (#2888)
Browse files Browse the repository at this point in the history
* Wait for kick done

* Enable test on Windows

* Wait for kick done
  • Loading branch information
July541 authored May 5, 2022
1 parent 8a5c7fc commit 796b292
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
name: Test hls-explicit-imports-plugin test suite
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"

- if: matrix.test && matrix.os != 'windows-latest'
- if: matrix.test
name: Test hls-call-hierarchy-plugin test suite
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"

Expand Down
21 changes: 15 additions & 6 deletions plugins/hls-call-hierarchy-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ incomingCallsTests =
testCase "xdata unavailable" $
runSessionWithServer plugin testDataDir $ do
doc <- createDoc "A.hs" "haskell" $ T.unlines ["a=3", "b=a"]
waitForKickDone
[item] <- Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc 1 0)
let expected = [CallHierarchyIncomingCall item (List [mkRange 1 2 1 3])]
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc 0 0) >>=
Expand Down Expand Up @@ -321,6 +322,7 @@ outgoingCallsTests =
testCase "xdata unavailable" $ withTempDir $ \dir ->
runSessionWithServer plugin dir $ do
doc <- createDoc "A.hs" "haskell" $ T.unlines ["a=3", "b=a"]
waitForKickDone
[item] <- Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc 0 1)
let expected = [CallHierarchyOutgoingCall item (List [mkRange 1 2 1 3])]
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc 1 0) >>=
Expand Down Expand Up @@ -424,6 +426,7 @@ incomingCallTestCase :: T.Text -> Int -> Int -> [(Int, Int)] -> [Range] -> Asser
incomingCallTestCase contents queryX queryY positions ranges = withTempDir $ \dir ->
runSessionWithServer plugin dir $ do
doc <- createDoc "A.hs" "haskell" contents
waitForKickDone
items <- concatMapM (\((x, y), range) ->
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc x y)
<&> map (, range)
Expand All @@ -443,9 +446,11 @@ incomingCallMultiFileTestCase :: FilePath -> Int -> Int -> M.Map FilePath [((Int
incomingCallMultiFileTestCase filepath queryX queryY mp =
runSessionWithServer plugin testDataDir $ do
doc <- openDoc filepath "haskell"
items <- fmap concat $ sequence $ M.elems $ M.mapWithKey (\fp pr ->
openDoc fp "haskell" >>= \p ->
concatMapM (\((x, y), range) ->
waitForKickDone
items <- fmap concat $ sequence $ M.elems $ M.mapWithKey (\fp pr -> do
p <- openDoc fp "haskell"
waitForKickDone
concatMapM (\((x, y), range) ->
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam p x y)
<&> map (, range)
) pr) mp
Expand All @@ -463,6 +468,7 @@ outgoingCallTestCase :: T.Text -> Int -> Int -> [(Int, Int)] -> [Range] -> Asser
outgoingCallTestCase contents queryX queryY positions ranges = withTempDir $ \dir ->
runSessionWithServer plugin dir $ do
doc <- createDoc "A.hs" "haskell" contents
waitForKickDone
items <- concatMapM (\((x, y), range) ->
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc x y)
<&> map (, range)
Expand All @@ -481,9 +487,11 @@ outgoingCallMultiFileTestCase :: FilePath -> Int -> Int -> M.Map FilePath [((Int
outgoingCallMultiFileTestCase filepath queryX queryY mp =
runSessionWithServer plugin testDataDir $ do
doc <- openDoc filepath "haskell"
items <- fmap concat $ sequence $ M.elems $ M.mapWithKey (\fp pr ->
openDoc fp "haskell" >>= \p ->
concatMapM (\((x, y), range) ->
waitForKickDone
items <- fmap concat $ sequence $ M.elems $ M.mapWithKey (\fp pr -> do
p <- openDoc fp "haskell"
waitForKickDone
concatMapM (\((x, y), range) ->
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam p x y)
<&> map (, range)
) pr) mp
Expand All @@ -500,6 +508,7 @@ oneCaseWithCreate :: T.Text -> Int -> Int -> (Uri -> CallHierarchyItem) -> Asser
oneCaseWithCreate contents queryX queryY expected = withTempDir $ \dir ->
runSessionWithServer plugin dir $ do
doc <- createDoc "A.hs" "haskell" contents
waitForKickDone
Test.prepareCallHierarchy (mkPrepareCallHierarchyParam doc queryX queryY) >>=
\case
[item] -> liftIO $ item @?= expected (doc ^. L.uri)
Expand Down

0 comments on commit 796b292

Please sign in to comment.