xref: /freebsd/sys/contrib/openzfs/scripts/zfs-tests-color.sh (revision c03c5b1c80914ec656fbee84539355d1fad68bf9)
1#!/bin/sh
2# A large mass of sed for coloring zfs-tests.sh output
3# Version 2, thanks to наб.
4# Just pipe zfs-tests.sh output into this, and watch.
5
6exec "$(command -v gsed || echo sed)" \
7	-e 's/\] \[PASS\]$/] [\x1b[92mPASS\x1b[0m]/' \
8	-e 's/\] \[FAIL\]$/] [\x1b[1;91mFAIL\x1b[0m]/' \
9	-e 's/\] \[KILLED\]$/] [\x1b[1;101mKILLED\x1b[0m]/' \
10	-e 's/\] \[SKIP\]$/] [\x1b[1mSKIP\x1b[0m]/' \
11	-e 's/\] \[RERAN\]$/] [\x1b[1;93mRERAN\x1b[0m]/' \
12	-e 's/^\(PASS\W\)/\x1b[92m\1\x1b[0m/' \
13	-e 's/^\(FAIL\W\)/\x1b[1;91m\1\x1b[0m/' \
14	-e 's/^\(KILLED\W\)/\x1b[1;101m\1\x1b[0m/' \
15	-e 's/^\(SKIP\W\)/\x1b[1m\1\x1b[0m/' \
16	-e 's/^\(RERAN\W\)/\x1b[1;93m\1\x1b[0m/' \
17	-e 's/^Tests with result\(.\+\)PASS\(.\+\)$/Tests with result\1\x1b[92mPASS\x1b[0m\2/' \
18	-e 's/^\(\W\+\)\(KILLED\)\(\W\)/\1\x1b[1;101m\2\x1b[0m\3/g' \
19	-e 's/^\(\W\+\)\(FAIL\)\(\W\)/\1\x1b[1;91m\2\x1b[0m\3/g' \
20	-e 's/^\(\W\+\)\(RERUN\)\(\W\)/\1\x1b[1;93m\2\x1b[0m\3/g' \
21	-e 's/^\(\W\+\)\(SKIP\)\(\W\)/\1\x1b[1m\2\x1b[0m\3/g' \
22	-e 's/expected \(PASS\))$/expected \x1b[92m\1\x1b[0m)/' \
23	-e 's/expected \(KILLED\))$/expected \x1b[1;101m\1\x1b[0m)/' \
24	-e 's/expected \(FAIL\))$/expected \x1b[1;91m\1\x1b[0m)/' \
25	-e 's/expected \(RERUN\))$/expected \x1b[1;93m\1\x1b[0m)/' \
26	-e 's/expected \(SKIP\))$/expected \x1b[1m\1\x1b[0m)/' \
27	-e 's/^Test\( ([[:alnum:] ]\+)\)\?: \(.\+\) (run as \(.\+\)) \[\([0-9]\+:[0-9]\+\)\] \[\(.\+\)\]$/\x1b[1mTest\1: \x1b[0m\2 (run as \x1b[1m\3\x1b[0m) [\x1b[1m\4\x1b[0m\] [\5\]/'
28