diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-08-25 18:09:40 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-08-25 18:35:52 +0200 |
| commit | b515ae37932b800b69df3ded320e4b673ee23cea (patch) | |
| tree | c9b9bf005a3d7416528f0a797ffff2d7a7808cfb /src/Run.hs | |
| parent | ec493e03b0415f43968c0a04598ada3272a0f0cf (diff) | |
Retport summary of test execution
Changelog: Added `--report` command-line option to print summary of passed/failed tests.
Diffstat (limited to 'src/Run.hs')
| -rw-r--r-- | src/Run.hs | 41 |
1 files changed, 35 insertions, 6 deletions
@@ -1,5 +1,7 @@ module Run ( module Run.Monad, + Report(..), + TestName, textTestName, runTests, runTest, @@ -58,17 +60,44 @@ import Test import Test.Builtins -runTests :: Output -> TestOptions -> GlobalDefs -> [ Test ] -> IO Bool +data Report = Report + { reportTotalCount :: Int + , reportPassedCount :: Int + , reportSkippedCount :: Int + , reportFailedCount :: Int + , reportFailedList :: [ TestName ] + } + +reportPassed :: Report -> Report +reportPassed r = r + { reportTotalCount = reportTotalCount r + 1 + , reportPassedCount = reportPassedCount r + 1 + } + +reportFailed :: TestName -> Report -> Report +reportFailed tname r = r + { reportTotalCount = reportTotalCount r + 1 + , reportFailedCount = reportFailedCount r + 1 + , reportFailedList = tname : reportFailedList r + } + +runTests :: Output -> TestOptions -> GlobalDefs -> [ Test ] -> IO Report runTests out opts gdefs tests = do go $ concat $ replicate (optRepeat opts) tests where go (t : ts) = do runTest out opts gdefs t >>= \case - True -> go ts - False - | optKeepGoing opts -> go ts >> return False - | otherwise -> return False - go [] = return True + True -> reportPassed <$> go ts + False -> reportFailed (testName t) <$> if + | optKeepGoing opts -> go ts + | otherwise -> go [] + go [] = return Report + { reportTotalCount = 0 + , reportPassedCount = 0 + , reportSkippedCount = 0 + , reportFailedCount = 0 + , reportFailedList = [] + } runTest :: Output -> TestOptions -> GlobalDefs -> Test -> IO Bool |