Skip to content

Commit

Permalink
A tweak to the formatting which should make no difference, but which …
Browse files Browse the repository at this point in the history
…seems to fix the way the bold-green text sometimes does not tuen off.
  • Loading branch information
jphmrst committed Sep 29, 2023
1 parent 2b93393 commit 17b1159
Showing 1 changed file with 42 additions and 29 deletions.
71 changes: 42 additions & 29 deletions src/Test/TLT/Report.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,26 @@ report (TLTopts showPasses exitAfterFailDisplay) trs =
tests = totalTestCount trs
in do report' "" trs
if fails > 0
then do boldRed
then do boldIntense
redText
putStrLn $
"Found " ++ show fails ++ " error"
++ (if fails > 1 then "s" else "")
++ " in " ++ show tests ++ " tests; exiting"
mediumBlack
mediumIntense
blackText
mediumIntense
blackText
when exitAfterFailDisplay exitFailure
else do boldGreen
else do boldIntense
greenText
putStrLn $ show tests ++ " test"
++ (if tests > 1 then "s" else "")
++ " passing."
mediumBlack
mediumIntense
blackText
mediumIntense
blackText
where report' ind trs = forM_ trs $ \ tr ->
when (failCount tr > 0 || showPasses) $
case tr of
Expand All @@ -81,39 +89,44 @@ report (TLTopts showPasses exitAfterFailDisplay) trs =
putStrLn $ ind ++ "- " ++ s ++ ":"
report' (" " ++ ind) trs'

-- |Command to set an ANSI terminal to boldface black.
boldBlack = setSGR [
SetColor Foreground Vivid Black, SetConsoleIntensity BoldIntensity ]
-- |Command to set an ANSI terminal to boldface red.
boldRed = setSGR [
SetColor Foreground Vivid Red, SetConsoleIntensity BoldIntensity ]
-- |Command to set an ANSI terminal to boldface green.
boldGreen = setSGR [
SetColor Foreground Vivid Green, SetConsoleIntensity BoldIntensity ]
-- |Command to set an ANSI terminal to medium-weight.
mediumIntense :: IO ()
mediumIntense = setSGR [ SetConsoleIntensity NormalIntensity ]

-- |Command to set an ANSI terminal to medium-weight red.
mediumRed = setSGR [
SetColor Foreground Vivid Red, SetConsoleIntensity NormalIntensity ]
-- |Command to set an ANSI terminal to medium-weight green.
mediumGreen = setSGR [
SetColor Foreground Vivid Green, SetConsoleIntensity NormalIntensity ]
-- |Command to set an ANSI terminal to medium-weight blue.
mediumBlue = setSGR [
SetColor Foreground Vivid Blue, SetConsoleIntensity NormalIntensity ]
-- |Command to set an ANSI terminal to medium-weight black.
mediumBlack = setSGR [
SetColor Foreground Vivid Black, SetConsoleIntensity NormalIntensity ]
-- |Command to set an ANSI terminal to bold-weight.
boldIntense :: IO ()
boldIntense = setSGR [ SetConsoleIntensity BoldIntensity ]

-- |Command to set an ANSI terminal to a black foreground.
blackText :: IO ()
blackText = setSGR [ SetColor Foreground Vivid Black ]

-- |Command to set an ANSI terminal to a red foreground.
redText :: IO ()
redText = setSGR [ SetColor Foreground Vivid Red ]

-- |Command to set an ANSI terminal to a blue foreground.
blueText :: IO ()
blueText = setSGR [ SetColor Foreground Vivid Blue ]

-- |Command to set an ANSI terminal to a green foreground.
greenText :: IO ()
greenText = setSGR [ SetColor Foreground Vivid Green ]

-- |Command to set an ANSI terminal to the standard TLT weight and
-- color for a passing test.
greenPass = do
mediumBlue
mediumIntense
blueText
putStr "Pass"
mediumBlack
mediumIntense
blackText

-- |Command to set an ANSI terminal to the standard TLT weight and
-- color for a failing test.
redFail = do
boldRed
boldIntense
redText
putStr "FAIL"
mediumBlack
mediumIntense
blackText

0 comments on commit 17b1159

Please sign in to comment.