X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=t%2Ftap.sh;h=0d03831bcf03cbb41d63ba198d8ab1f0a96f61a5;hb=refs%2Ftags%2Fv0.1.6;hp=59df961a207547397e0719816096d61fe67f6de8;hpb=458ecde52cbb587e9db52f4ae16fcd76002feb61;p=zpackage diff --git a/t/tap.sh b/t/tap.sh index 59df961..0d03831 100755 --- a/t/tap.sh +++ b/t/tap.sh @@ -7,34 +7,60 @@ tryrun() { note="$@" program=$1 shift - $program "$@" - if [ $? -ne 0 ]; then + $program "$@" > test.out 2>&1 + rv=$? + if [ $rv -ne 0 ]; then printf 'not '; fi tn=$((tn + 1)) printf 'ok %d - %s %s\n' $tn $program "$*" + if [ $rv -ne 0 ]; then + cat test.out | diagstdin + fi + return $rv } require() { - note="$@" + note="$*" program=$1 shift - $program "$@" - if [ $? -ne 0 ]; then - printf "bail out! fail[$?]: $@\n" - exit 255; - fi + $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() { if [ "$note" != "" ]; then printf '# %s\n' "$note" fi } +diag() { + printf '# %s\n' "$@" +} + +diagfile() { + sed -e 's/^/# /' $1 +} + +diagstdin() { + sed -e 's/^/# /' +} + okexit() { exitwith 0 "$*" } @@ -56,7 +82,7 @@ exitwith() { note= 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)) @@ -87,3 +113,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 +}