X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=t%2Ftap.sh;h=00530027795577e8cd9d51c46b297e34461f5b4c;hb=c9b5db2d4b9c4691bbcc2c61a47c4fc279eb057b;hp=23c52997190d8f127cab8a8384f828d92bcf50f2;hpb=b876033bd42f1924f9f4e85189b88b1741d568cd;p=zpackage diff --git a/t/tap.sh b/t/tap.sh index 23c5299..0053002 100755 --- a/t/tap.sh +++ b/t/tap.sh @@ -7,12 +7,40 @@ tryrun() { note="$@" program=$1 shift - $program "$@" - if [ $? -ne 0 ]; then + $program "$@" > test.out 2>&1 + tap_return_value=$? + if [ $tap_return_value -ne 0 ]; then printf 'not '; fi tn=$((tn + 1)) printf 'ok %d - %s %s\n' $tn $program "$*" + if [ $tap_return_value -ne 0 ]; then + cat test.out | diagstdin + fi + return $tap_return_value +} + +require() { + note="$*" + program=$1 + shift + $program "$@" > test.out 2>&1 + rv=$? + tn=$((tn + 1)) + if [ $rv -ne 0 ]; then + printf 'not ok %d - %s %s\n' $tn $program "$*" + cat test.out | diagstdin + rm test.out + bailout "exit status $rv"; + fi + printf 'ok %d - %s %s\n' $tn $program "$*" + +} + +bailout() { + diag "$@" + printf "bail out!\n"; + exit 255; } shownote() { @@ -21,15 +49,28 @@ shownote() { fi } +diag() { + printf '# %s\n' "$@" +} + +diagfile() { + sed -e 's/^/# /' $1 +} + +diagstdin() { + sed -e 's/^/# /' +} + okexit() { exitwith 0 "$*" } failsok() { + rv=$? note= - if [ $? -eq 0 ]; then + if [ $rv -eq 0 ]; then printf 'not '; - note=$(printf '# got "%d" expected "%d"' "$1" "0") + note=$(printf 'got "%d" expected "%d"' "$rv" "0") fi tn=$((tn + 1)) printf 'ok %d - %s\n' $tn "$*" @@ -37,15 +78,17 @@ failsok() { } exitwith() { + rv=$? note= - if [ $? -ne $1 ]; then + if [ $rv -ne $1 ]; then printf 'not '; - note=$(printf '# got "%d" expected "%d"' "$1" "$2") + note=$(printf 'got "%d" expected "%d"' "$rv" "$1") fi shift tn=$((tn + 1)) printf 'ok %d - %s\n' $tn "$*" shownote + return $rv } okstreq() { @@ -71,3 +114,13 @@ finish() { printf '1..%d\n' $tn fi } + +skip() { + tap_skipping=$1 + shift + while [ $tap_skipping -gt 0 ]; do + tn=$((tn + 1)) + tap_skipping=$((tap_skipping - 1)) + printf 'ok %d - skip %s\n' $tn "$*" + done +}