aboutsummaryrefslogtreecommitdiff
path: root/aux/tests-lib.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-06-22 12:12:10 -0300
committerEuAndreh <eu@euandre.org>2021-06-22 12:12:59 -0300
commit95a32d0d88783b880e67660865a0b3f69c705c25 (patch)
tree019868ced924432bde7f1be3d216c82ea3d3d346 /aux/tests-lib.sh
parenttests/cli-opts.sh: Add test_langs (diff)
downloadgit-permalink-95a32d0d88783b880e67660865a0b3f69c705c25.tar.gz
git-permalink-95a32d0d88783b880e67660865a0b3f69c705c25.tar.xz
aux/tests-lib.sh: Use colours on test output
Diffstat (limited to '')
-rwxr-xr-xaux/tests-lib.sh23
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
}