Fix broken test output due to ANSI_RESET
This is a similar issue to #27921 (closed):
Go's test output assumes that any verbose logs printed are terminated with new lines. This allows Go test parsers (both used in external tools, and by Go's own test2json
) to parse lines expected to start with === RUN
and --- PASS
.
Unfortunately, the build logger's Println
, Infoln
etc. functions use ANSI colouring in the following way:
- ANSI Color
- Message
- New Line (\n)
- ANSI Reset
\033[31;1mERROR: Job failed (system failure): build fail
\033[0;m
This breaks Go's test output, such that it's easy to have this situation:
=== RUN TestArtifactDownloadRunFailure
\033[0KRunning with gitlab-runner development version (HEAD)
\033[0;m\033[31;1mERROR: Job failed (system failure): build fail
\033[0;m--- PASS: TestArtifactDownloadRunFailure (0.00s)
Here, --- PASS
cannot be parsed correctly.
Proposal
I propose that we have a cleaner approach, and keep both start and reset sequences on a single line, by resetting and then placing the terminting \n
. This allows anything parsing line-by-line to not encounter these sequences.
\033[31;1mERROR: Job failed (system failure): build fail\033[0;m
\033[31;1mANOTHER: line\033[0;m