summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-08-29 15:04:54 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2026-09-01 20:17:41 +0200
commit14d66fe918b9101c31ce3d77f37ec753b7e79813 (patch)
treeee4786028ed21a51a88c7bb7587c28dec9e68ff9
parent7451433718f49cc3eadf7ab0f896fad987e19883 (diff)
Use color formatting for summary report
-rw-r--r--src/Main.hs27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 9eff874..253c1e8 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -1,6 +1,7 @@
module Main (main) where
import Control.Monad
+import Control.Monad.Reader
import Data.Char
import Data.Maybe
@@ -24,6 +25,7 @@ import Parser.Core
import Process
import Run.Builtins
import TestMode
+import TextFormat
import Version
data CmdlineOptions = CmdlineOptions
@@ -215,12 +217,25 @@ main = do
Report {..} <- runTests out topts lmGlobalDefs tests
- when (optReport opts) $ do
- putStrLn $ "Total: " <> show reportTotalCount
- putStrLn $ "Passed: " <> show reportPassedCount
- putStrLn $ "Failed: " <> show reportFailedCount
- forM_ reportFailedList $ \tname -> do
- putStrLn $ T.unpack $ textTestName tname
+ when (optReport opts) $ flip runReaderT out $ do
+ outLineF OutputGlobalInfo Nothing $ "Total: " <> plainText (T.pack (show reportTotalCount))
+ outLineF OutputGlobalInfo Nothing $ mconcat
+ [ "Passed: "
+ , withStyle (if (reportPassedCount > 0) then setForegroundColor Green noStyle else noStyle) $
+ plainText $ T.pack $ show reportPassedCount
+ ]
+ outLineF OutputGlobalInfo Nothing $ mconcat
+ [ "Failed: "
+ , withStyle (if (reportFailedCount > 0) then setForegroundColor Red noStyle else noStyle) $
+ plainText (T.pack (show reportFailedCount))
+ ]
+ when (reportFailedCount > 0) $ do
+ outLine OutputGlobalInfo Nothing ""
+ outLineF OutputGlobalInfo Nothing $ withStyle (setForegroundColor BrightRed noStyle) $ "Failing tests:"
+ forM_ reportFailedList $ \tname -> do
+ outLineF OutputGlobalInfo Nothing $
+ withStyle (setForegroundColor Red noStyle) $
+ plainText $ textTestName tname
when (reportFailedCount > 0) exitFailure