Skip to content

Commit c2694e8

Browse files
committed
test: Set nonzero exitcode when tests fail
* Create a single list of quickcheck properties * Test the result of the quickcehck run * Exit with appropriate status code
1 parent 700b979 commit c2694e8

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

tests/DListProperties.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
--------------------------------------------------------------------------------
2121

2222
-- | QuickCheck property tests for DList.
23-
module DListProperties (test) where
23+
module DListProperties (properties) where
2424

2525
--------------------------------------------------------------------------------
2626

@@ -183,6 +183,3 @@ properties =
183183
("Semigroup stimes", property prop_Semigroup_stimes)
184184
#endif
185185
]
186-
187-
test :: IO ()
188-
test = quickCheckLabeledProperties properties

tests/DNonEmptyProperties.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
--------------------------------------------------------------------------------
99

1010
-- | QuickCheck property tests for DNonEmpty.
11-
module DNonEmptyProperties (test) where
11+
module DNonEmptyProperties (properties) where
1212

1313
--------------------------------------------------------------------------------
1414

@@ -104,6 +104,3 @@ properties =
104104
("fromList", property prop_fromList),
105105
("Semigroup <>", property prop_Semigroup_append)
106106
]
107-
108-
test :: IO ()
109-
test = quickCheckLabeledProperties properties

tests/Main.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ import qualified DListProperties
1818
import qualified DNonEmptyProperties
1919
#endif
2020
import qualified OverloadedStrings
21+
import QuickCheckUtil (quickCheckLabeledProperties)
22+
import Control.Monad (unless)
23+
import Test.QuickCheck (isSuccess)
24+
import System.Exit (exitFailure)
2125

2226
--------------------------------------------------------------------------------
2327

2428
main :: IO ()
2529
main = do
26-
DListProperties.test
27-
-- CPP: GHC >= 8 for DNonEmpty
30+
OverloadedStrings.test
31+
result <- quickCheckLabeledProperties $
32+
DListProperties.properties
33+
-- CPP: GHC >= 8 for DNonEmpty
2834
#if __GLASGOW_HASKELL__ >= 800
29-
DNonEmptyProperties.test
35+
++ DNonEmptyProperties.properties
3036
#endif
31-
OverloadedStrings.test
37+
unless (isSuccess result) exitFailure

tests/QuickCheckUtil.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ eqOn c f g x = c x ==> f x == g x
3737

3838
--------------------------------------------------------------------------------
3939

40-
quickCheckLabeledProperties :: [(String, Property)] -> IO ()
41-
quickCheckLabeledProperties = quickCheck . conjoin . map (uncurry label)
40+
quickCheckLabeledProperties :: [(String, Property)] -> IO Result
41+
quickCheckLabeledProperties = quickCheckResult . conjoin . map (uncurry label)
4242

4343
--------------------------------------------------------------------------------
4444

0 commit comments

Comments
 (0)