Skip to content

Commit

Permalink
Add line wrap disablement to ConsoleReporter
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundnoble committed Nov 13, 2024
1 parent 7efa34a commit 9240df9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ packages:
quickcheck
smallcheck

source-repository-package
type: git
location: https://github.com/kadena-io/ansi-terminal
tag: 2953f3b6361ec85c92c6449b8f540bcf84d1cf00
subdir: ansi-terminal

if os(wasi)
-- https://github.com/haskellari/splitmix/pull/73
source-repository-package
Expand Down
10 changes: 10 additions & 0 deletions core/Test/Tasty/Ingredients/ConsoleReporter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ buildTestOutput opts tree =
(replicate postNamePadding ' ')

printTestName = do
when getAnsiTricks $
disableLineWrap
putStr testNamePadded
when getAnsiTricks $
enableLineWrap
hFlush stdout

printTestProgress progress
Expand All @@ -173,8 +177,12 @@ buildTestOutput opts tree =
-- A new progress message may be shorter than the previous one
-- so we must clean whole line and print anew.
clearLine
-- We must ensure the line doesn't wrap, otherwise the wrong
-- line will be cleared later.
disableLineWrap
putStr testNamePadded
infoOk msg
enableLineWrap
hFlush stdout

printTestResult result = do
Expand All @@ -192,7 +200,9 @@ buildTestOutput opts tree =
when getAnsiTricks $ do
putChar '\r'
clearLine
disableLineWrap
putStr testNamePadded
enableLineWrap

printFn (resultShortDescription result)
when (floor (time * 1e6) >= minDurationMicros) $
Expand Down

0 comments on commit 9240df9

Please sign in to comment.