commit: 1a418edfe55b3810fa29f369422f9155ec306d23
parent b19215fbc3035ab37a093da219f8cdfc8e6128c9
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 13 Jun 2024 11:57:03 +0200
test-cmd/tap.sh: Fix TAP output syntax
Diffstat:
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/test-cmd/tap.sh b/test-cmd/tap.sh
@@ -12,15 +12,23 @@ err=0
t ()
{
count=$((count+1))
- out="$("${target?}" $2 2>&1)"
+ # Append a final slash so sh(1) doesn't trims final newlines
+ out="$("${target?}" $2 2>&1;r=$?;echo -n /;exit $r)"
ret="$?"
+ out="${out%/}"
if [ "$?" != 0 ]; then
- printf 'not ok %s - %s\n' "$count $1" "$out"
+ printf 'not ok %d - %s\n' "$count" "$1"
+ echo "$out" | sed -e 's;^;# ;'
+ err=1
elif [ "$out" != "$3" ]; then
- printf 'not ok %s - (%s != %s)\n' "$count $1" "$out" "$3"
+ printf 'not ok %d - %s\n' "$count" "$1"
+ printf '# == Expected ==\n'
+ echo "$3" | sed -e 's;^;# ;'
+ printf '# == Got ==\n'
+ echo "$out" | sed -e 's;^;# ;'
err=1
else
- printf 'ok %s\n' "$count $1"
+ printf 'ok %d - %s\n' "$count" "$1"
fi
}