Skip to content

Fix hls-call-hierarchy-plugin tests #2888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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