Skip to content

Commit ee9614b

Browse files
committed
Add edit flaky stale diagnostic test
1 parent 20727f2 commit ee9614b

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

ghcide-test/exe/DiagnosticTests.hs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import Development.IDE.Test (diagnostic,
1515
expectDiagnostics,
1616
expectDiagnosticsWithTags,
1717
expectNoMoreDiagnostics,
18-
flushMessages, waitForAction)
18+
flushMessages, waitForAction,
19+
waitForBuildQueue)
1920
import Development.IDE.Types.Location
2021
import qualified Language.LSP.Protocol.Lens as L
2122
import Language.LSP.Protocol.Message
@@ -54,6 +55,20 @@ tests = testGroup "diagnostics"
5455
}
5556
changeDoc doc [change]
5657
expectDiagnostics [("Testing.hs", [])]
58+
, testWithDummyPluginEmpty "rapid edits then save does not strand a stale diagnostic" $ do
59+
let v rhs = T.unlines ["module Testing where", "foo :: Int", "foo = " <> rhs]
60+
whole rhs = TextDocumentContentChangeEvent . InR . TextDocumentContentChangeWholeDocument $ v rhs
61+
doc <- createDoc "Testing.hs" "haskell" (v "()")
62+
expectDiagnostics [("Testing.hs", [(DiagnosticSeverity_Error, (2, 6), "Couldn't match expected type 'Int' with actual type '()'", Just "GHC-83865")])]
63+
changeDoc doc [whole "()"]
64+
changeDoc doc [whole "'a'"]
65+
changeDoc doc [whole "True"]
66+
changeDoc doc [whole "0"]
67+
sendNotification SMethod_TextDocumentDidSave (DidSaveTextDocumentParams doc Nothing)
68+
waitForBuildQueue
69+
liftIO $ sleep 0.2
70+
flushMessages
71+
expectCurrentDiagnostics doc []
5772
, testWithDummyPluginEmpty "introduce syntax error" $ do
5873
let content = T.unlines [ "module Testing where" ]
5974
doc <- createDoc "Testing.hs" "haskell" content

0 commit comments

Comments
 (0)