Skip to content

Commit 5e54300

Browse files
committed
cabal plugin
1 parent 4a830e6 commit 5e54300

File tree

2 files changed

+6
-1
lines changed
  • hls-test-utils/src/Test/Hls
  • plugins/hls-cabal-plugin/test

2 files changed

+6
-1
lines changed

hls-test-utils/src/Test/Hls/Util.hs

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module Test.Hls.Util
3636
, inspectCodeAction
3737
, inspectCommand
3838
, inspectDiagnostic
39+
, inspectDiagnosticAny
3940
, waitForDiagnosticsFrom
4041
, waitForDiagnosticsFromSource
4142
, waitForDiagnosticsFromSourceWithTimeout
@@ -247,6 +248,10 @@ inspectDiagnostic :: [Diagnostic] -> [T.Text] -> IO Diagnostic
247248
inspectDiagnostic diags s = onMatch diags (\ca -> all (`T.isInfixOf` (ca ^. L.message)) s) err
248249
where err = "expected diagnostic matching '" ++ show s ++ "' but did not find one"
249250

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+
250255
expectDiagnostic :: [Diagnostic] -> [T.Text] -> IO ()
251256
expectDiagnostic diags s = void $ inspectDiagnostic diags s
252257

plugins/hls-cabal-plugin/test/Main.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pluginTests =
110110
, runCabalTestCaseSession "Publishes Diagnostics on unsupported cabal version as Warning" "" $ do
111111
_ <- openDoc "unsupportedVersion.cabal" "cabal"
112112
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"]
114114
liftIO $ do
115115
length diags @?= 1
116116
unknownVersionDiag ^. L.range @?= Range (Position 0 0) (Position 1 0)

0 commit comments

Comments
 (0)