Skip to content

Commit 3db418e

Browse files
Increase robustness of tests by skipping extraneous messages.
1 parent bb1e22b commit 3db418e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/functional/FunctionalCodeAction.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ hlintTests = testGroup "hlint suggestions" [
6464

6565
executeCodeAction (fromJust redId)
6666

67-
contents <- getDocumentEdit doc
67+
contents <- skipManyTill anyMessage $ getDocumentEdit doc
6868
liftIO $ contents @?= "main = undefined\nfoo x = x\n"
6969

7070
, testCase "falls back to pre 3.8 code actions" $ runSession hlsCommand noLiteralCaps "test/testdata/hlint" $ do
@@ -77,7 +77,7 @@ hlintTests = testGroup "hlint suggestions" [
7777

7878
executeCommand etaReduce
7979

80-
contents <- skipManyTill publishDiagnosticsNotification $ getDocumentEdit doc
80+
contents <- skipManyTill anyMessage $ getDocumentEdit doc
8181
liftIO $ contents @?= "main = undefined\nfoo = id\n"
8282

8383
, testCase "changing configuration enables or disables hlint diagnostics" $ runSession hlsCommand fullCaps "test/testdata/hlint" $ do
@@ -214,7 +214,7 @@ packageTests = testGroup "add package suggestions" [
214214

215215
executeCodeAction action
216216

217-
contents <- getDocumentEdit . TextDocumentIdentifier =<< getDocUri "add-package-test.cabal"
217+
contents <- skipManyTill anyMessage $ getDocumentEdit . TextDocumentIdentifier =<< getDocUri "add-package-test.cabal"
218218
liftIO $
219219
any (\l -> "text -any" `T.isSuffixOf` l || "text : {} -any" `T.isSuffixOf` l) (T.lines contents) @? "Contains text package"
220220

@@ -243,7 +243,7 @@ packageTests = testGroup "add package suggestions" [
243243

244244
executeCodeAction action
245245

246-
contents <- getDocumentEdit . TextDocumentIdentifier =<< getDocUri "package.yaml"
246+
contents <- skipManyTill anyMessage $ getDocumentEdit . TextDocumentIdentifier =<< getDocUri "package.yaml"
247247
liftIO $ do
248248
"zlib" `T.isSuffixOf` (T.lines contents !! 3) @? "Contains zlib"
249249
"zlib" `T.isSuffixOf` (T.lines contents !! 21) @? "Does not contain zlib in unrelated component"
@@ -415,7 +415,7 @@ unusedTermTests = testGroup "unused term code actions" [
415415
--
416416
-- executeCodeAction $ head cas
417417
--
418-
-- edit <- getDocumentEdit doc
418+
-- edit <- skipManyTill anyMessage $ getDocumentEdit doc
419419
--
420420
-- let expected = [ "{-# OPTIONS_GHC -Wall #-}"
421421
-- , "module UnusedTerm () where"

0 commit comments

Comments
 (0)