Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use simpler ‘\r’ instead of cursor manipulation escape sequences #393

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions core/Test/Tasty/Ingredients/ConsoleReporter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ buildTestOutput opts tree =
name
(replicate postNamePadding ' ')

resultPosition = length testNamePadded

printTestName = do
putStr testNamePadded
hFlush stdout
Expand All @@ -171,11 +169,11 @@ buildTestOutput opts tree =
("", pct) -> printf "%.0f%% " pct
(txt, 0.0) -> printf "%s" txt
(txt, pct) -> printf "%s: %.0f%% " txt pct
setCursorColumn resultPosition
infoOk msg
-- A new progress message may be shorter than the previous one
-- so we must clean until the end of the line
clearFromCursorToLineEnd
-- so we must clean whole line and print anew.
putChar '\r'
putStr testNamePadded
infoOk msg
hFlush stdout

printTestResult result = do
Expand All @@ -191,8 +189,8 @@ buildTestOutput opts tree =
time = resultTime result

when getAnsiTricks $ do
setCursorColumn resultPosition
clearFromCursorToLineEnd
putChar '\r'
putStr testNamePadded

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