@@ -89,8 +89,13 @@ import System.Process (callProcess)
8989
9090import Data.Tagged (Tagged (.. ))
9191import Test.Tasty
92- import Test.Tasty.HUnit
92+ import Test.Tasty.ExpectedFailure
93+ import Test.Tasty.HUnit hiding (testCase )
94+ import qualified Test.Tasty.HUnit as T (testCase )
9395import Test.Tasty.Options
96+ import Test.Tasty.Runners
97+
98+ import System.IO.Silently
9499
95100import qualified Data.ByteString as BS
96101import Data.Maybe (fromJust )
@@ -112,23 +117,43 @@ main = do
112117 callProcess " cabal" [" update" ]
113118 defaultMainWithIngredients
114119 (defaultIngredients ++ [includingOptions projectConfigOptionDescriptions])
115- ( withProjectConfig $ \ config ->
116- testGroup
120+ ( localOption ( NumThreads 1 ) $ withProjectConfig $ \ config ->
121+ sequentialTestGroup
117122 " Integration tests (internal)"
123+ AllFinish
118124 (tests config)
119125 )
120126
127+ -- Tests are run silently, unless they fail. Firstly because it is annoying to
128+ -- see lots of stderr from your unit tests. Secondly because this output
129+ -- leaks into the result of github actions (#8419)
130+ --
131+ -- Note that this capture is safe to use as the testsuite runs sequentially.
132+ silentTest :: TestTree -> TestTree
133+ silentTest = wrapTest silentHelper
134+ where
135+ silentHelper t = do
136+ (out, res) <- hCapture [stderr] t
137+
138+ return $
139+ if not (resultSuccessful res)
140+ then res{resultDescription = resultDescription res <> " \n Captured output:\n " <> out}
141+ else res
142+
143+ testCase :: String -> Assertion -> TestTree
144+ testCase desc action = (T. testCase desc action)
145+
121146tests :: ProjectConfig -> [TestTree ]
122147tests config =
123148 -- TODO: tests for:
124149 -- \* normal success
125150 -- \* dry-run tests with changes
126- [ testGroup " Discovery and planning" $
151+ [ sequentialTestGroup " Discovery and planning" AllFinish $
127152 [ testCase " no package" (testExceptionInFindingPackage config)
128153 , testCase " no package2" (testExceptionInFindingPackage2 config)
129154 , testCase " proj conf1" (testExceptionInProjectConfig config)
130155 ]
131- , testGroup " Target selectors" $
156+ , sequentialTestGroup " Target selectors" AllFinish $
132157 [ testCaseSteps " valid" testTargetSelectors
133158 , testCase " bad syntax" testTargetSelectorBadSyntax
134159 , testCaseSteps " ambiguous syntax" testTargetSelectorAmbiguous
@@ -145,7 +170,7 @@ tests config =
145170 , testCaseSteps " problems (bench)" (testTargetProblemsBench config)
146171 , testCaseSteps " problems (haddock)" (testTargetProblemsHaddock config)
147172 ]
148- , testGroup " Exceptions during building (local inplace)" $
173+ , sequentialTestGroup " Exceptions during building (local inplace)" AllFinish $
149174 [ testCase " configure" (testExceptionInConfigureStep config)
150175 , testCase " build" (testExceptionInBuildStep config)
151176 -- , testCase "register" testExceptionInRegisterStep
@@ -154,7 +179,7 @@ tests config =
154179 -- TODO: need to check we can build sub-libs, foreign libs and exes
155180 -- components for non-local packages / packages in the store.
156181
157- testGroup " Successful builds" $
182+ sequentialTestGroup " Successful builds" AllFinish $
158183 [ testCaseSteps " Setup script styles" (testSetupScriptStyles config)
159184 , testCase " keep-going" (testBuildKeepGoing config)
160185 ]
@@ -164,19 +189,20 @@ tests config =
164189 else
165190 [ testCase " local tarball" (testBuildLocalTarball config)
166191 ]
167- , testGroup " Regression tests" $
192+ , sequentialTestGroup " Regression tests" AllFinish $
168193 [ testCase " issue #3324" (testRegressionIssue3324 config)
169194 , testCase " program options scope all" (testProgramOptionsAll config)
170195 , testCase " program options scope local" (testProgramOptionsLocal config)
171196 , testCase " program options scope specific" (testProgramOptionsSpecific config)
172197 ]
173- , testGroup " Flag tests" $
198+ , sequentialTestGroup " Flag tests" AllFinish $
174199 [ testCase " Test Nix Flag" testNixFlags
175200 , testCase " Test Config options for commented options" testConfigOptionComments
176201 , testCase " Test Ignore Project Flag" testIgnoreProjectFlag
177202 ]
178- , testGroup
203+ , sequentialTestGroup
179204 " haddock-project"
205+ AllFinish
180206 [ testCase " dependencies" (testHaddockProjectDependencies config)
181207 ]
182208 ]
0 commit comments