X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=t%2Ftap.sh;h=f881b1cdcc1a7d7865c0ad46c315dec8ba3b8cea;hb=9d52e76ca7992bf2f38868dbcf9c84a7cc1484c9;hp=1811f5dde48aacbf9ed9945d9a15eb8596d40ba9;hpb=d3b90e6aa8ab580c77ead76ff5c6c6dca7991cc6;p=zpackage diff --git a/t/tap.sh b/t/tap.sh index 1811f5d..f881b1c 100755 --- a/t/tap.sh +++ b/t/tap.sh @@ -4,31 +4,34 @@ tn=0 planned=0 tryrun() { - note="$@" program=$1 shift - $program "$@" >> test.out 2>&1 - 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 + rm test.out + fi + return $tap_return_value } require() { - note="$@" - program=$1 - shift - $program "$@" >> test.out 2>&1 + tryrun "$@" rv=$? if [ $rv -ne 0 ]; then - diag "bailing on $((tn + 1)) $program $*" - printf "bail out! fail[$rv]: $@\n" - exit 255; + bailout "exit status $rv"; fi - tn=$((tn + 1)) - printf 'ok %d - %s %s\n' $tn $program "$*" +} +bailout() { + diag "$@" + printf "bail out!\n"; + exit 255; } shownote() { @@ -41,6 +44,14 @@ diag() { printf '# %s\n' "$@" } +diagfile() { + sed -e 's/^/# /' $1 +} + +diagstdin() { + sed -e 's/^/# /' +} + okexit() { exitwith 0 "$*" } @@ -62,12 +73,13 @@ exitwith() { note= if [ $rv -ne $1 ]; then printf 'not '; - note=$(printf '# got "%d" expected "%d"' "$rv" "$1") + note=$(printf 'got "%d" expected "%d"' "$rv" "$1") fi shift tn=$((tn + 1)) printf 'ok %d - %s\n' $tn "$*" shownote + return $rv } okstreq() { @@ -93,3 +105,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 +}