diff options
author | EuAndreh <eu@euandre.org> | 2021-06-26 21:48:18 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-06-26 21:49:20 -0300 |
commit | 59f34fe49527fc697bd86145aa974076c83eb404 (patch) | |
tree | ee4748e63d034b86e50b78724d5812cd7e001681 /aux/tests-lib.sh | |
parent | aux/utils.sh: Remove unused file (diff) | |
download | remembering-59f34fe49527fc697bd86145aa974076c83eb404.tar.gz remembering-59f34fe49527fc697bd86145aa974076c83eb404.tar.xz |
aux/: Update, adapt Makefile accordingly
Diffstat (limited to '')
-rwxr-xr-x | aux/tests-lib.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/aux/tests-lib.sh b/aux/tests-lib.sh index 007282a..a3ce7dc 100755 --- a/aux/tests-lib.sh +++ b/aux/tests-lib.sh @@ -5,6 +5,7 @@ red="\033[0;31m" green="\033[0;32m" yellow="\033[0;33m" +N= OUT= ERR= STATUS= @@ -14,10 +15,15 @@ ERROR() { printf "${red}ERROR${end}" } +print_debug_info() { + printf 'LINENO: %s\nOUT: %s\nERR: %s\n' "$N" "$OUT" "$ERR" >&2 +} + assert_status() { if [ "$STATUS" != "$1" ]; then printf '\n%s: Bad status.\n\nexpected: %s\ngot: %s\n' \ "$(ERROR)" "$1" "$STATUS" >&2 + print_debug_info exit 1 fi } @@ -26,6 +32,7 @@ assert_usage() { if ! grep -Fq 'Usage' "$1"; then echo 'Expected to find "Usage" text, it was missing:' >&2 cat "$1" >&2 + print_debug_info exit 1 fi } @@ -34,6 +41,7 @@ assert_empty_stream() { if [ -s "$2" ]; then printf '\n%s: Expected %s (%s) to be empty, but has content:\n%s\n' \ "$(ERROR)" "$1" "$2" "$(cat "$2")" >&2 + print_debug_info exit 1 fi } @@ -50,6 +58,7 @@ assert_stream() { if [ "$(cat "$2")" != "$3" ]; then printf '\nERR: Bad %s (%s)\n\nexpected: %s\ngot: %s\n' \ "$1" "$2" "$3" "$(cat "$2")" >&2 + print_debug_info exit 1 fi } @@ -66,6 +75,7 @@ assert_grep_stream() { if ! grep -qE "$3" "$2"; then printf '\nERR: Bad %s (%s)\n\ngrepping: %s\nin:\n%s\n' \ "$1" "$2" "$3" "$(cat "$2")" >&2 + print_debug_info exit 1 fi } @@ -82,6 +92,7 @@ assert_fgrep_stream() { if ! grep -Fq -- "$3" "$2"; then printf '\nERR: Bad %s (%s)\n\ngrepping: %s\nin:\n%s\n' \ "$1" "$2" "$3" "$(cat "$2")" >&2 + print_debug_info exit 1 fi } |