Output colorized logs from pg_prove
Is your feature request related to a problem? Please describe. Small quality of life feature request – would be great to have pg_prove logs passed through with colors (should be the default behavior of pg_prove). Otherwise with many tests, it's a bit difficult to follow the structure.
Describe the solution you'd like Colorised logs.
Describe alternatives you've considered N/A
Additional context Platform test: Mac OS latest CLI
@sweatybridge, any chance this could be fixed? Just adding -t option to docker run would fix this – I'd be fine if it was even an optional flag, but don't want to inherit another very long package script ideally for such a simple thing.
Current behavior – takes way too much time to read and locate failing tests (and even worse when multiple tests are failing and there's more plans that are failing):
Yes please!!!
@lauri865 as a temporary workaround i managed to create an awk script to colorise the output, the results look much better:
Use the script like this:
supabase db test 2>&1 | awk -f colorize-pgtap-output.awk
[!WARNING] The "2>&1" bit is important as pg_prove is writing on stderr!
The script:
BEGIN {
# ANSI color codes
RED="\033[31m";
GREEN="\033[32m";
YELLOW="\033[33m";
GRAY="\033[90m";
BOLD="\033[1m";
RESET="\033[0m";
}
/Dubious|Failed|error|exit 1|Result: FAIL/ {
print RED $0 RESET;
next;
}
# Match any line containing ERROR: (PostgreSQL error messages)
/ERROR:/ {
print RED $0 RESET;
next;
}
# Match DETAIL: and CONTEXT: lines that are part of PostgreSQL error messages
/DETAIL:|CONTEXT:/ {
print RED $0 RESET;
next;
}
/ok$/ {
print GREEN $0 RESET;
next;
}
/\.\.\.+/ {
test = $1;
result = $NF;
if (result == "ok") {
printf "%s %s %s\n", test, GRAY RESET, GREEN result RESET;
} else {
printf "%s %s %s\n", RED test RESET, GRAY RESET, RED result RESET;
}
next;
}
/Test Summary Report|-------------------/ {
print YELLOW BOLD $0 RESET;
next;
}
/\(Wstat:.*/ {
sub(/^[[:space:]]+/, "");
filename = $1;
print YELLOW " " RED filename RESET YELLOW $2 $3 $4 $5 $6 RESET;
next;
}
/^Files=|^Result:/ {
if ($0 ~ /FAIL/) {
print RED BOLD $0 RESET;
} else {
print YELLOW $0 RESET;
}
next;
}
/Try rerunning/ {
print YELLOW $0 RESET;
next;
}
{
print;
}