Skip to content

Commit

Permalink
Exit with failure when tests fail (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
414owen committed Feb 17, 2024
1 parent 1aa96db commit f2289f7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
5 changes: 1 addition & 4 deletions tests/DListProperties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
--------------------------------------------------------------------------------

-- | QuickCheck property tests for DList.
module DListProperties (test) where
module DListProperties (properties) where

--------------------------------------------------------------------------------

Expand Down Expand Up @@ -189,6 +189,3 @@ properties =
("Semigroup stimes", property prop_Semigroup_stimes)
#endif
]

test :: IO ()
test = quickCheckLabeledProperties properties
5 changes: 1 addition & 4 deletions tests/DNonEmptyProperties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
--------------------------------------------------------------------------------

-- | QuickCheck property tests for DNonEmpty.
module DNonEmptyProperties (test) where
module DNonEmptyProperties (properties) where

--------------------------------------------------------------------------------

Expand Down Expand Up @@ -104,6 +104,3 @@ properties =
("fromList", property prop_fromList),
("Semigroup <>", property prop_Semigroup_append)
]

test :: IO ()
test = quickCheckLabeledProperties properties
10 changes: 8 additions & 2 deletions tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ import qualified DListProperties
import qualified DNonEmptyProperties
#endif
import qualified OverloadedStrings
import QuickCheckUtil (quickCheckLabeledProperties)
import Control.Monad (unless)
import Test.QuickCheck (isSuccess)
import System.Exit (exitFailure)

--------------------------------------------------------------------------------

main :: IO ()
main = do
DListProperties.test
result <- quickCheckLabeledProperties $
DListProperties.properties
-- CPP: GHC >= 8 for DNonEmpty
#if __GLASGOW_HASKELL__ >= 800
DNonEmptyProperties.test
++ DNonEmptyProperties.properties
#endif
OverloadedStrings.test
unless (isSuccess result) exitFailure
4 changes: 2 additions & 2 deletions tests/QuickCheckUtil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ eqOn c f g x = c x ==> f x == g x

--------------------------------------------------------------------------------

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

--------------------------------------------------------------------------------

Expand Down

0 comments on commit f2289f7

Please sign in to comment.