@@ -89,8 +89,13 @@ import System.Process (callProcess)
89
89
90
90
import Data.Tagged (Tagged (.. ))
91
91
import 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 )
93
95
import Test.Tasty.Options
96
+ import Test.Tasty.Runners
97
+
98
+ import System.IO.Silently
94
99
95
100
import qualified Data.ByteString as BS
96
101
import Data.Maybe (fromJust )
@@ -112,23 +117,43 @@ main = do
112
117
callProcess " cabal" [" update" ]
113
118
defaultMainWithIngredients
114
119
(defaultIngredients ++ [includingOptions projectConfigOptionDescriptions])
115
- ( withProjectConfig $ \ config ->
116
- testGroup
120
+ ( localOption ( NumThreads 1 ) $ withProjectConfig $ \ config ->
121
+ sequentialTestGroup
117
122
" Integration tests (internal)"
123
+ AllFinish
118
124
(tests config)
119
125
)
120
126
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
+
121
146
tests :: ProjectConfig -> [TestTree ]
122
147
tests config =
123
148
-- TODO: tests for:
124
149
-- \* normal success
125
150
-- \* dry-run tests with changes
126
- [ testGroup " Discovery and planning" $
151
+ [ sequentialTestGroup " Discovery and planning" AllFinish $
127
152
[ testCase " no package" (testExceptionInFindingPackage config)
128
153
, testCase " no package2" (testExceptionInFindingPackage2 config)
129
154
, testCase " proj conf1" (testExceptionInProjectConfig config)
130
155
]
131
- , testGroup " Target selectors" $
156
+ , sequentialTestGroup " Target selectors" AllFinish $
132
157
[ testCaseSteps " valid" testTargetSelectors
133
158
, testCase " bad syntax" testTargetSelectorBadSyntax
134
159
, testCaseSteps " ambiguous syntax" testTargetSelectorAmbiguous
@@ -145,7 +170,7 @@ tests config =
145
170
, testCaseSteps " problems (bench)" (testTargetProblemsBench config)
146
171
, testCaseSteps " problems (haddock)" (testTargetProblemsHaddock config)
147
172
]
148
- , testGroup " Exceptions during building (local inplace)" $
173
+ , sequentialTestGroup " Exceptions during building (local inplace)" AllFinish $
149
174
[ testCase " configure" (testExceptionInConfigureStep config)
150
175
, testCase " build" (testExceptionInBuildStep config)
151
176
-- , testCase "register" testExceptionInRegisterStep
@@ -154,7 +179,7 @@ tests config =
154
179
-- TODO: need to check we can build sub-libs, foreign libs and exes
155
180
-- components for non-local packages / packages in the store.
156
181
157
- testGroup " Successful builds" $
182
+ sequentialTestGroup " Successful builds" AllFinish $
158
183
[ testCaseSteps " Setup script styles" (testSetupScriptStyles config)
159
184
, testCase " keep-going" (testBuildKeepGoing config)
160
185
]
@@ -164,19 +189,20 @@ tests config =
164
189
else
165
190
[ testCase " local tarball" (testBuildLocalTarball config)
166
191
]
167
- , testGroup " Regression tests" $
192
+ , sequentialTestGroup " Regression tests" AllFinish $
168
193
[ testCase " issue #3324" (testRegressionIssue3324 config)
169
194
, testCase " program options scope all" (testProgramOptionsAll config)
170
195
, testCase " program options scope local" (testProgramOptionsLocal config)
171
196
, testCase " program options scope specific" (testProgramOptionsSpecific config)
172
197
]
173
- , testGroup " Flag tests" $
198
+ , sequentialTestGroup " Flag tests" AllFinish $
174
199
[ testCase " Test Nix Flag" testNixFlags
175
200
, testCase " Test Config options for commented options" testConfigOptionComments
176
201
, testCase " Test Ignore Project Flag" testIgnoreProjectFlag
177
202
]
178
- , testGroup
203
+ , sequentialTestGroup
179
204
" haddock-project"
205
+ AllFinish
180
206
[ testCase " dependencies" (testHaddockProjectDependencies config)
181
207
]
182
208
]
0 commit comments