]> pd.if.org Git - zpackage/blobdiff - t/tap.sh
fix bug in tap exit with, add diag
[zpackage] / t / tap.sh
index 553128ffe01e9a55e5e58570acc07699f1dab1ea..b82f203f5f7628cbdaca6d46d46974a2431ba826 100755 (executable)
--- a/t/tap.sh
+++ b/t/tap.sh
@@ -15,12 +15,30 @@ tryrun() {
        printf 'ok %d - %s %s\n' $tn $program "$*"
 }
 
+require() {
+       note="$@"
+       program=$1
+       shift
+       $program "$@"
+       if [ $? -ne 0 ]; then
+               printf "bail out! fail[$?]: $@\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 +60,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))