@@ -47,7 +47,7 @@ type Cursor = (Int, Int)
47
47
cursorPosition :: Cursor -> Position
48
48
cursorPosition (line, col) = Position line col
49
49
50
- requireDiagnostic :: List Diagnostic -> (DiagnosticSeverity , Cursor , T. Text , Maybe DiagnosticTag ) -> Assertion
50
+ requireDiagnostic :: HasCallStack => List Diagnostic -> (DiagnosticSeverity , Cursor , T. Text , Maybe DiagnosticTag ) -> Assertion
51
51
requireDiagnostic actuals expected@ (severity, cursor, expectedMsg, expectedTag) = do
52
52
unless (any match actuals) $
53
53
assertFailure $
@@ -69,7 +69,7 @@ requireDiagnostic actuals expected@(severity, cursor, expectedMsg, expectedTag)
69
69
70
70
-- | wait for @timeout@ seconds and report an assertion failure
71
71
-- if any diagnostic messages arrive in that period
72
- expectNoMoreDiagnostics :: Seconds -> Session ()
72
+ expectNoMoreDiagnostics :: HasCallStack => Seconds -> Session ()
73
73
expectNoMoreDiagnostics timeout =
74
74
expectMessages STextDocumentPublishDiagnostics timeout $ \ diagsNot -> do
75
75
let fileUri = diagsNot ^. params . uri
@@ -109,23 +109,23 @@ flushMessages = do
109
109
--
110
110
-- Rather than trying to assert the absence of diagnostics, introduce an
111
111
-- expected diagnostic (e.g. a redundant import) and assert the singleton diagnostic.
112
- expectDiagnostics :: [(FilePath , [(DiagnosticSeverity , Cursor , T. Text )])] -> Session ()
112
+ expectDiagnostics :: HasCallStack => [(FilePath , [(DiagnosticSeverity , Cursor , T. Text )])] -> Session ()
113
113
expectDiagnostics
114
114
= expectDiagnosticsWithTags
115
115
. map (second (map (\ (ds, c, t) -> (ds, c, t, Nothing ))))
116
116
117
117
unwrapDiagnostic :: NotificationMessage TextDocumentPublishDiagnostics -> (Uri , List Diagnostic )
118
118
unwrapDiagnostic diagsNot = (diagsNot^. params. uri, diagsNot^. params. diagnostics)
119
119
120
- expectDiagnosticsWithTags :: [(String , [(DiagnosticSeverity , Cursor , T. Text , Maybe DiagnosticTag )])] -> Session ()
120
+ expectDiagnosticsWithTags :: HasCallStack => [(String , [(DiagnosticSeverity , Cursor , T. Text , Maybe DiagnosticTag )])] -> Session ()
121
121
expectDiagnosticsWithTags expected = do
122
122
let f = getDocUri >=> liftIO . canonicalizeUri >=> pure . toNormalizedUri
123
123
next = unwrapDiagnostic <$> skipManyTill anyMessage diagnostic
124
124
expected' <- Map. fromListWith (<>) <$> traverseOf (traverse . _1) f expected
125
125
expectDiagnosticsWithTags' next expected'
126
126
127
127
expectDiagnosticsWithTags' ::
128
- MonadIO m =>
128
+ ( HasCallStack , MonadIO m ) =>
129
129
m (Uri , List Diagnostic ) ->
130
130
Map. Map NormalizedUri [(DiagnosticSeverity , Cursor , T. Text , Maybe DiagnosticTag )] ->
131
131
m ()
@@ -165,12 +165,12 @@ expectDiagnosticsWithTags' next expected = go expected
165
165
<> show actual
166
166
go $ Map. delete canonUri m
167
167
168
- expectCurrentDiagnostics :: TextDocumentIdentifier -> [(DiagnosticSeverity , Cursor , T. Text )] -> Session ()
168
+ expectCurrentDiagnostics :: HasCallStack => TextDocumentIdentifier -> [(DiagnosticSeverity , Cursor , T. Text )] -> Session ()
169
169
expectCurrentDiagnostics doc expected = do
170
170
diags <- getCurrentDiagnostics doc
171
171
checkDiagnosticsForDoc doc expected diags
172
172
173
- checkDiagnosticsForDoc :: TextDocumentIdentifier -> [(DiagnosticSeverity , Cursor , T. Text )] -> [Diagnostic ] -> Session ()
173
+ checkDiagnosticsForDoc :: HasCallStack => TextDocumentIdentifier -> [(DiagnosticSeverity , Cursor , T. Text )] -> [Diagnostic ] -> Session ()
174
174
checkDiagnosticsForDoc TextDocumentIdentifier {_uri} expected obtained = do
175
175
let expected' = Map. fromList [(nuri, map (\ (ds, c, t) -> (ds, c, t, Nothing )) expected)]
176
176
nuri = toNormalizedUri _uri
0 commit comments