]> pd.if.org Git - zpackage/blobdiff - t/tap.sh
integrate previous work
[zpackage] / t / tap.sh
index 553128ffe01e9a55e5e58570acc07699f1dab1ea..1811f5dde48aacbf9ed9945d9a15eb8596d40ba9 100755 (executable)
--- a/t/tap.sh
+++ b/t/tap.sh
@@ -7,7 +7,7 @@ tryrun() {
        note="$@"
        program=$1
        shift
-       $program "$@"
+       $program "$@" >> test.out 2>&1
        if [ $? -ne 0 ]; then
                printf 'not ';
        fi
@@ -15,12 +15,32 @@ tryrun() {
        printf 'ok %d - %s %s\n' $tn $program "$*"
 }
 
+require() {
+       note="$@"
+       program=$1
+       shift
+       $program "$@" >> test.out 2>&1
+       rv=$?
+       if [ $rv -ne 0 ]; then
+               diag "bailing on $((tn + 1)) $program $*"
+               printf "bail out! fail[$rv]: $@\n"
+               exit 255;
+       fi
+       tn=$((tn + 1))
+       printf 'ok %d - %s %s\n' $tn $program "$*"
+
+}
+
 shownote() {
        if [ "$note" != "" ]; then
                printf '# %s\n' "$note"
        fi
 }
 
+diag() {
+       printf '# %s\n' "$@"
+}
+
 okexit() {
        exitwith 0 "$*"
 }
@@ -42,7 +62,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))