summaryrefslogtreecommitdiff
path: root/src/Output.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-01-14 20:02:29 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2026-01-14 20:02:29 +0100
commit379d88e72a66eb876dfdf452d79081f5e4277979 (patch)
tree8f8ca97d960f994df450cf73d1c4c810d93d8e1a /src/Output.hs
parentea8109cef731b2c876b9effa759763bf59d878aa (diff)
Print test names in verbose output
Changelog: Verbose output now includes test names.
Diffstat (limited to 'src/Output.hs')
-rw-r--r--src/Output.hs78
1 files changed, 50 insertions, 28 deletions
diff --git a/src/Output.hs b/src/Output.hs
index 2cddabf..1201d72 100644
--- a/src/Output.hs
+++ b/src/Output.hs
@@ -50,7 +50,9 @@ data OutputStyle
deriving (Eq)
data OutputType
- = OutputChildStdout
+ = OutputGlobalInfo
+ | OutputGlobalError
+ | OutputChildStdout
| OutputChildStderr
| OutputChildStdin
| OutputChildExec
@@ -82,39 +84,50 @@ resetOutputTime Output {..} = do
modifyMVar_ outStartedAt . const $ getTime Monotonic
outColor :: OutputType -> Text
-outColor OutputChildStdout = T.pack "0"
-outColor OutputChildStderr = T.pack "31"
-outColor OutputChildStdin = T.pack "0"
-outColor OutputChildExec = T.pack "33"
-outColor OutputChildInfo = T.pack "0"
-outColor OutputChildFail = T.pack "31"
-outColor OutputMatch = T.pack "32"
-outColor OutputMatchFail {} = T.pack "31"
-outColor OutputIgnored = "90"
-outColor OutputError = T.pack "31"
-outColor OutputAlways = "0"
-outColor OutputTestRaw = "0"
+outColor = \case
+ OutputGlobalInfo -> "0"
+ OutputGlobalError -> "31"
+ OutputChildStdout -> "0"
+ OutputChildStderr -> "31"
+ OutputChildStdin -> "0"
+ OutputChildExec -> "33"
+ OutputChildInfo -> "0"
+ OutputChildFail -> "31"
+ OutputMatch -> "32"
+ OutputMatchFail {} -> "31"
+ OutputIgnored -> "90"
+ OutputError -> "31"
+ OutputAlways -> "0"
+ OutputTestRaw -> "0"
outSign :: OutputType -> Text
-outSign OutputChildStdout = " "
-outSign OutputChildStderr = T.pack "!"
-outSign OutputChildStdin = T.empty
-outSign OutputChildExec = "*"
-outSign OutputChildInfo = T.pack "."
-outSign OutputChildFail = T.pack "!!"
-outSign OutputMatch = T.pack "+"
-outSign OutputMatchFail {} = T.pack "/"
-outSign OutputIgnored = "-"
-outSign OutputError = T.pack "!!"
-outSign OutputAlways = T.empty
-outSign OutputTestRaw = T.empty
+outSign = \case
+ OutputGlobalInfo -> ""
+ OutputGlobalError -> ""
+ OutputChildStdout -> " "
+ OutputChildStderr -> "!"
+ OutputChildStdin -> T.empty
+ OutputChildExec -> "*"
+ OutputChildInfo -> "."
+ OutputChildFail -> "!!"
+ OutputMatch -> "+"
+ OutputMatchFail {} -> "/"
+ OutputIgnored -> "-"
+ OutputError -> "!!"
+ OutputAlways -> T.empty
+ OutputTestRaw -> T.empty
outArr :: OutputType -> Text
-outArr OutputChildStdin = "<"
-outArr _ = ">"
+outArr = \case
+ OutputGlobalInfo -> ""
+ OutputGlobalError -> ""
+ OutputChildStdin -> "<"
+ _ -> ">"
outTestLabel :: OutputType -> Text
outTestLabel = \case
+ OutputGlobalInfo -> "global-info"
+ OutputGlobalError -> "global-error"
OutputChildStdout -> "child-stdout"
OutputChildStderr -> "child-stderr"
OutputChildStdin -> "child-stdin"
@@ -130,6 +143,7 @@ outTestLabel = \case
printWhenQuiet :: OutputType -> Bool
printWhenQuiet = \case
+ OutputGlobalError -> True
OutputChildStderr -> True
OutputChildFail -> True
OutputMatchFail {} -> True
@@ -137,6 +151,12 @@ printWhenQuiet = \case
OutputAlways -> True
_ -> False
+includeTestTime :: OutputType -> Bool
+includeTestTime = \case
+ OutputGlobalInfo -> False
+ OutputGlobalError -> False
+ _ -> True
+
ioWithOutput :: MonadOutput m => (Output -> IO a) -> m a
ioWithOutput act = liftIO . act =<< getOutput
@@ -155,7 +175,9 @@ outLine otype prompt line = ioWithOutput $ \out ->
withMVar (outState out) $ \st -> do
forM_ (normalOutputLines otype line) $ \line' -> do
outPrint st $ TL.fromChunks $ concat
- [ [ T.pack $ printf "[% 2d.%03d] " (nsecs `quot` 1000000000) ((nsecs `quot` 1000000) `rem` 1000) ]
+ [ if includeTestTime otype
+ then [ T.pack $ printf "[% 2d.%03d] " (nsecs `quot` 1000000000) ((nsecs `quot` 1000000) `rem` 1000) ]
+ else []
, if outUseColor (outConfig out)
then [ T.pack "\ESC[", outColor otype, T.pack "m" ]
else []