@@ -28,15 +28,20 @@ module Test.Hls.Util
28
28
, inspectCodeAction
29
29
, inspectCommand
30
30
, inspectDiagnostic
31
+ -- * Mark tests as broken for various reasons.
31
32
, knownBrokenOnWindows
32
33
, knownBrokenForGhcVersions
34
+ , knownIssueInEnv
33
35
, knownBrokenInEnv
34
36
, onlyWorkForGhcVersions
37
+ -- * Setup test-suite state
35
38
, setupBuildToolFiles
39
+ -- * Diagnostics helpers
36
40
, SymbolLocation
37
41
, waitForDiagnosticsFrom
38
42
, waitForDiagnosticsFromSource
39
43
, waitForDiagnosticsFromSourceWithTimeout
44
+ -- * Working directory modifications
40
45
, withCurrentDirectoryInTmp
41
46
, withCurrentDirectoryInTmp'
42
47
, withCanonicalTempDir
@@ -115,7 +120,19 @@ files =
115
120
-- , "./test/testdata/wErrorTest/"
116
121
]
117
122
118
- data EnvSpec = HostOS OS | GhcVer GhcVersion
123
+ -- | Why is the test broken?
124
+ --
125
+ -- Are they broken for the given spec or are we just ignoring the test
126
+ -- because the test doesn't make sense in the Environment.
127
+ data IssueSolution
128
+ = Broken
129
+ -- ^ Mark a test as known broken, expecting the test to be fixed eventually.
130
+ | Ignore
131
+ -- ^ Mark a test as ignored, because the test doesn't make sense in the
132
+ -- associated environment.
133
+ deriving (Show )
134
+
135
+ data EnvSpec = HostOS OS | GhcVer GhcVersion | Specific OS GhcVersion
119
136
deriving (Show , Eq )
120
137
121
138
matchesCurrentEnv :: EnvSpec -> Bool
@@ -131,11 +148,18 @@ hostOS
131
148
| isMac = MacOS
132
149
| otherwise = Linux
133
150
151
+ -- | Mark the given TestTree as having a known issue if /any/ of environmental
152
+ -- spec matches the current environment.
153
+ knownIssueInEnv :: IssueSolution -> [EnvSpec ] -> String -> TestTree -> TestTree
154
+ knownIssueInEnv issueSolution envSpecs reason
155
+ | any matchesCurrentEnv envSpecs = case issueSolution of
156
+ Broken -> expectFailBecause reason
157
+ Ignore -> ignoreTestBecause reason
158
+ | otherwise = id
159
+
134
160
-- | Mark as broken if /any/ of environmental spec mathces the current environment.
135
161
knownBrokenInEnv :: [EnvSpec ] -> String -> TestTree -> TestTree
136
- knownBrokenInEnv envSpecs reason
137
- | any matchesCurrentEnv envSpecs = expectFailBecause reason
138
- | otherwise = id
162
+ knownBrokenInEnv = knownIssueInEnv Broken
139
163
140
164
knownBrokenOnWindows :: String -> TestTree -> TestTree
141
165
knownBrokenOnWindows = knownBrokenInEnv [HostOS Windows ]
0 commit comments