File tree 3 files changed +14
-4
lines changed
hls-test-utils/src/Test/Hls
3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ module Test.Hls.Util
36
36
, inspectCodeAction
37
37
, inspectCommand
38
38
, inspectDiagnostic
39
+ , inspectDiagnosticAny
39
40
, waitForDiagnosticsFrom
40
41
, waitForDiagnosticsFromSource
41
42
, waitForDiagnosticsFromSourceWithTimeout
@@ -247,6 +248,10 @@ inspectDiagnostic :: [Diagnostic] -> [T.Text] -> IO Diagnostic
247
248
inspectDiagnostic diags s = onMatch diags (\ ca -> all (`T.isInfixOf` (ca ^. L. message)) s) err
248
249
where err = " expected diagnostic matching '" ++ show s ++ " ' but did not find one"
249
250
251
+ inspectDiagnosticAny :: [Diagnostic ] -> [T. Text ] -> IO Diagnostic
252
+ inspectDiagnosticAny diags s = onMatch diags (\ ca -> any (`T.isInfixOf` (ca ^. L. message)) s) err
253
+ where err = " expected diagnostic matching one of'" ++ show s ++ " ' but did not find one"
254
+
250
255
expectDiagnostic :: [Diagnostic ] -> [T. Text ] -> IO ()
251
256
expectDiagnostic diags s = void $ inspectDiagnostic diags s
252
257
Original file line number Diff line number Diff line change @@ -249,10 +249,12 @@ cabalRules recorder plId = do
249
249
let warningDiags = fmap (Diagnostics. warningDiagnostic file) pWarnings
250
250
case pm of
251
251
Left (_cabalVersion, pErrorNE) -> do
252
- let regex :: T. Text
252
+ let regexUnknownCabalBefore310 :: T. Text
253
253
-- We don't support the cabal version, this should not be an error, as the
254
254
-- user did not do anything wrong. Instead we cast it to a warning
255
- regex = " Unsupported cabal-version [0-9]+.[0-9]*"
255
+ regexUnknownCabalBefore310 = " Unsupported cabal-version [0-9]+.[0-9]*"
256
+ regexUnknownCabalVersion :: T. Text
257
+ regexUnknownCabalVersion = " Unsupported cabal format version in cabal-version field: [0-9]+.[0-9]+"
256
258
unsupportedCabalHelpText = unlines
257
259
[ " The used `cabal-version` is not fully supported by this `HLS` binary."
258
260
, " Either the `cabal-version` is unknown, or too new for this executable."
@@ -267,7 +269,10 @@ cabalRules recorder plId = do
267
269
NE. toList $
268
270
NE. map
269
271
( \ pe@ (PError pos text) ->
270
- if text =~ regex
272
+ if any (text =~ )
273
+ [ regexUnknownCabalBefore310
274
+ , regexUnknownCabalVersion
275
+ ]
271
276
then Diagnostics. warningDiagnostic file (Syntax. PWarning Syntax. PWTOther pos $
272
277
unlines
273
278
[ text
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ pluginTests =
110
110
, runCabalTestCaseSession " Publishes Diagnostics on unsupported cabal version as Warning" " " $ do
111
111
_ <- openDoc " unsupportedVersion.cabal" " cabal"
112
112
diags <- cabalCaptureKick
113
- unknownVersionDiag <- liftIO $ inspectDiagnostic diags [" Unsupported cabal-version 99999.0" ]
113
+ unknownVersionDiag <- liftIO $ inspectDiagnosticAny diags [" Unsupported cabal-version 99999.0 " , " Unsupported cabal format version in cabal-version field: 99999.0" ]
114
114
liftIO $ do
115
115
length diags @?= 1
116
116
unknownVersionDiag ^. L. range @?= Range (Position 0 0 ) (Position 1 0 )
You can’t perform that action at this time.
0 commit comments