X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=t%2Ftap.sh;h=c9fe8788b52694a69da2768638c4537c4018a1c5;hb=28c32424d04f982985b685ce891ed7db6237504e;hp=580fcbd2d02d6be9e0627a880af59dee46bd6ad8;hpb=837982b6e11a00d6416de2c25004f94ccc6b0d4a;p=zpackage diff --git a/t/tap.sh b/t/tap.sh index 580fcbd..c9fe878 100755 --- a/t/tap.sh +++ b/t/tap.sh @@ -4,30 +4,41 @@ tn=0 planned=0 tryrun() { - note="$@" + if [ "$1" = "-v" ]; then + allout=1 + shift + else + allout=0 + fi + program=$1 shift - $program "$@" >> test.out 2>&1 - if [ $? -ne 0 ]; then + + $program "$@" > test.out 2>&1 + tap_rv=$? + tn=$((tn + 1)) + + if [ $tap_rv -ne 0 ]; then printf 'not '; fi - tn=$((tn + 1)) printf 'ok %d - %s %s\n' $tn $program "$*" + + if [ $allout -eq 1 ] || [ $tap_rv -ne 0 ]; then + if test -s test.out; then + cat test.out | diagstdin + fi + rm test.out + fi + + return $tap_rv } require() { - note="$*" - program=$1 - shift - $program "$@" >> test.out 2>&1 + tryrun "$@" rv=$? - tn=$((tn + 1)) if [ $rv -ne 0 ]; then - printf 'not ok %d - %s %s\n' $tn $program "$*" bailout "exit status $rv"; fi - printf 'ok %d - %s %s\n' $tn $program "$*" - } bailout() { @@ -75,12 +86,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() { @@ -106,3 +118,33 @@ 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 "$*" + #ok '# skip ' "$*" + done +} + +ok() { + rv=$1 + shift + if [ $rv = 1 ]; then + printf 'not ' + fi + tn=$((tn + 1)) + printf 'ok %d - %s\n' $tn "$*" + return $rv +} + +pass() { + ok 0 "$@" +} + +fail() { + ok 1 "$@" +}