@@ -138,8 +138,7 @@ import Development.IDE.Types.Logger (Logger (Logger),
138
138
WithPriority (WithPriority , priority ),
139
139
cfilter ,
140
140
cmapWithPrio ,
141
- makeDefaultStderrRecorder ,
142
- toCologActionWithPrio )
141
+ makeDefaultStderrRecorder )
143
142
import qualified FuzzySearch
144
143
import GHC.Stack (emptyCallStack )
145
144
import qualified HieDbRetry
@@ -151,12 +150,11 @@ import Language.LSP.Types.Lens (didChangeWatchedFiles
151
150
import qualified Language.LSP.Types.Lens as L
152
151
import qualified Progress
153
152
import System.Time.Extra
154
- import qualified Test.QuickCheck.Monadic as MonadicQuickCheck
155
- import Test.QuickCheck.Monadic (forAllM , monadicIO )
156
153
import Test.Tasty
157
154
import Test.Tasty.ExpectedFailure
158
155
import Test.Tasty.HUnit
159
156
import Test.Tasty.Ingredients.Rerun
157
+ import Test.Tasty.Runners as Runners
160
158
import Test.Tasty.QuickCheck
161
159
import Text.Printf (printf )
162
160
import Text.Regex.TDFA ((=~) )
@@ -2084,7 +2082,6 @@ completionDocTests =
2084
2082
test doc (Position 1 7 ) " id" (Just $ T. length expected) [expected]
2085
2083
]
2086
2084
where
2087
- brokenForGhc9 = knownBrokenFor (BrokenForGHC [GHC90 , GHC92 , GHC94 , GHC96 ]) " Completion doc doesn't support ghc9"
2088
2085
brokenForWinGhc9 = knownBrokenFor (BrokenSpecific Windows [GHC90 , GHC92 ]) " Extern doc doesn't support Windows for ghc9.2"
2089
2086
-- https://gitlab.haskell.org/ghc/ghc/-/issues/20903
2090
2087
brokenForMacGhc9 = knownBrokenFor (BrokenSpecific MacOS [GHC90 , GHC92 , GHC94 , GHC96 ]) " Extern doc doesn't support MacOS for ghc9"
@@ -2373,7 +2370,7 @@ knownBrokenForGhcVersions ghcVers = knownBrokenFor (BrokenForGHC ghcVers)
2373
2370
2374
2371
data BrokenOS = Linux | MacOS | Windows deriving (Show )
2375
2372
2376
- data IssueSolution = Broken | Ignore deriving (Show )
2373
+ data IssueSolution = Broken | Ignore | Flaky deriving (Show )
2377
2374
2378
2375
data BrokenTarget =
2379
2376
BrokenSpecific BrokenOS [GhcVersion ]
@@ -2392,6 +2389,14 @@ ignoreFor = knownIssueFor Ignore
2392
2389
knownBrokenFor :: BrokenTarget -> String -> TestTree -> TestTree
2393
2390
knownBrokenFor = knownIssueFor Broken
2394
2391
2392
+ -- | Mark test as flaky for a specific target
2393
+ knownFlakyFor :: BrokenTarget -> String -> TestTree -> TestTree
2394
+ knownFlakyFor = knownIssueFor Flaky
2395
+
2396
+ -- | Mark test as flaky for all GHC versions
2397
+ knownFlaky :: String -> TestTree -> TestTree
2398
+ knownFlaky = knownIssueFor Flaky (BrokenForGHC [minBound .. maxBound ])
2399
+
2395
2400
-- | Deal with `IssueSolution` for specific OS and GHC.
2396
2401
knownIssueFor :: IssueSolution -> BrokenTarget -> String -> TestTree -> TestTree
2397
2402
knownIssueFor solution = go . \ case
@@ -2409,8 +2414,30 @@ knownIssueFor solution = go . \case
2409
2414
go True = case solution of
2410
2415
Broken -> expectFailBecause
2411
2416
Ignore -> ignoreTestBecause
2417
+ Flaky -> knownFlakyBecause
2412
2418
go False = \ _ -> id
2413
2419
2420
+ -- | The test can no longer fail and is marked as flaky.
2421
+ -- Flaky tests are tests that sometimes fail but sometimes also succeed.
2422
+ -- Ideally, such test cases should not exist at all, but at least in this codebase,
2423
+ -- the reality is, that we do have a number of flaky test cases.
2424
+ --
2425
+ -- The code is basically copy-pasted from 'tasty-expected-failure' and if this
2426
+ -- function proves useful in practice, we will upstream it.
2427
+ knownFlakyBecause :: String -> TestTree -> TestTree
2428
+ knownFlakyBecause info = wrapTest (fmap change)
2429
+ where
2430
+ change r
2431
+ | resultSuccessful r
2432
+ = r { resultDescription = resultDescription r <> " (flaky testcase: " <> info <> " )"
2433
+ , resultShortDescription = resultShortDescription r <> " (flaky testcase)"
2434
+ }
2435
+ | otherwise
2436
+ = r { resultOutcome = Runners. Success
2437
+ , resultDescription = resultDescription r <> " (failed flaky testcase failed: " <> info <> " )"
2438
+ , resultShortDescription = resultShortDescription r <> " (failed flaky testcase)"
2439
+ }
2440
+
2414
2441
data Expect
2415
2442
= ExpectRange Range -- Both gotoDef and hover should report this range
2416
2443
| ExpectLocation Location
0 commit comments