]> pd.if.org Git - zpackage/blobdiff - t/tap.sh
add required test to tap
[zpackage] / t / tap.sh
index 23c52997190d8f127cab8a8384f828d92bcf50f2..59df961a207547397e0719816096d61fe67f6de8 100755 (executable)
--- a/t/tap.sh
+++ b/t/tap.sh
@@ -15,6 +15,20 @@ 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"
@@ -26,10 +40,11 @@ okexit() {
 }
 
 failsok() {
+       rv=$?
        note=
-       if [ $? -eq 0 ]; then
+       if [ $rv -eq 0 ]; then
                printf 'not ';
-               note=$(printf '# got "%d" expected "%d"' "$1" "0")
+               note=$(printf 'got "%d" expected "%d"' "$rv" "0")
        fi
        tn=$((tn + 1))
        printf 'ok %d - %s\n' $tn "$*"
@@ -37,8 +52,9 @@ failsok() {
 }
 
 exitwith() {
+       rv=$?
        note=
-       if [ $? -ne $1 ]; then
+       if [ $rv -ne $1 ]; then
                printf 'not ';
                note=$(printf '# got "%d" expected "%d"' "$1" "$2")
        fi