Skip to content

Improve hls class plugin test #4059

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 1 commit into from
Feb 8, 2024
Merged
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
6 changes: 3 additions & 3 deletions plugins/hls-class-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ codeLensTests = testGroup
, testCase "Do not construct error action!, Ticket3942one" $ do
runSessionWithServer def classPlugin testDataDir $ do
doc <- openDoc "Ticket3942one.hs" "haskell"
_ <- waitForDiagnosticsFromSource doc (T.unpack sourceTypecheck)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is rather weird. I don't know why it isn't just a slight variant of waitForDiagnostics that adds an extra predicate...

_ <- waitForDiagnosticsFrom doc
lens <- getAllCodeActions doc
-- should switch to `liftIO $ length lens @?= 2, when Ticket3942 is entirely fixed`
-- current fix is just to make sure the code does not throw an exception that would mess up
Expand Down Expand Up @@ -165,7 +165,7 @@ goldenCodeLens title path idx =
goldenWithClass ::TestName -> FilePath -> FilePath -> ([CodeAction] -> Session ()) -> TestTree
goldenWithClass title path desc act =
goldenWithHaskellDoc def classPlugin title testDataDir path (desc <.> "expected") "hs" $ \doc -> do
_ <- waitForDiagnosticsFromSource doc (T.unpack sourceTypecheck)
_ <- waitForDiagnosticsFrom doc
actions <- concatMap (^.. _CACodeAction) <$> getAllCodeActions doc
act actions
void $ skipManyTill anyMessage (getDocumentEdit doc)
Expand All @@ -175,7 +175,7 @@ expectCodeActionsAvailable title path actionTitles =
testCase title $ do
runSessionWithServer def classPlugin testDataDir $ do
doc <- openDoc (path <.> "hs") "haskell"
_ <- waitForDiagnosticsFromSource doc (T.unpack sourceTypecheck)
_ <- waitForDiagnosticsFrom doc
caResults <- getAllCodeActions doc
liftIO $ map (^? _CACodeAction . L.title) caResults
@?= expectedActions
Expand Down