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
+ fi
+ return $tap_return_value
}
require() {
- note="$@"
+ note="$*"
program=$1
shift
- $program "$@" >> test.out 2>&1
+ $program "$@" > test.out 2>&1
rv=$?
+ tn=$((tn + 1))
if [ $rv -ne 0 ]; then
- diag "bailing on $((tn + 1)) $program $*"
- printf "bail out! fail[$rv]: $@\n"
- exit 255;
+ printf 'not ok %d - %s %s\n' $tn $program "$*"
+ cat test.out | diagstdin
+ rm test.out
+ 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() {
if [ "$note" != "" ]; then
printf '# %s\n' "$note"
printf '# %s\n' "$@"
}
+diagfile() {
+ sed -e 's/^/# /' $1
+}
+
+diagstdin() {
+ sed -e 's/^/# /'
+}
+
okexit() {
exitwith 0 "$*"
}
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() {
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
+}