diff options
Diffstat (limited to '')
-rwxr-xr-x | aux/tests-lib.sh | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/aux/tests-lib.sh b/aux/tests-lib.sh index e075974..0be4e6f 100755 --- a/aux/tests-lib.sh +++ b/aux/tests-lib.sh @@ -1,13 +1,23 @@ #!/bin/sh +end="\033[0m" +red="\033[0;31m" +green="\033[0;32m" +yellow="\033[0;33m" + OUT= ERR= STATUS= +ERROR() { + # shellcheck disable=2059 + printf "${red}ERROR${end}" +} + assert_status() { if [ "$STATUS" != "$1" ]; then - printf '\nERR: Bad status.\n\nexpected: %s\ngot: %s\n' \ - "$1" "$STATUS" >&2 + printf '\n%s: Bad status.\n\nexpected: %s\ngot: %s\n' \ + "$(ERROR)" "$1" "$STATUS" >&2 exit 1 fi } @@ -22,8 +32,8 @@ assert_usage() { assert_empty_stream() { if [ -s "$2" ]; then - printf '\nERR: Expected %s (%s) to be empty, but has content:\n%s\n' \ - "$1" "$2" "$(cat "$2")" >&2 + printf '\n%s: Expected %s (%s) to be empty, but has content:\n%s\n' \ + "$(ERROR)" "$1" "$2" "$(cat "$2")" >&2 exit 1 fi } @@ -85,9 +95,10 @@ assert_fgrep_stderr() { } testing() { - printf 'testing: %s...' "$1" >&2 + printf "${yellow}testing${end}: %s..." "$1" >&2 } test_ok() { - printf ' OK.\n' >&2 + # shellcheck disable=2059 + printf " ${green}OK${end}.\n" >&2 } |