]> pd.if.org Git - zpackage/blobdiff - t/tap.sh
add -o option to runscript
[zpackage] / t / tap.sh
index 553128ffe01e9a55e5e58570acc07699f1dab1ea..580fcbd2d02d6be9e0627a880af59dee46bd6ad8 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,45 @@ tryrun() {
        printf 'ok %d - %s %s\n' $tn $program "$*"
 }
 
+require() {
+       note="$*"
+       program=$1
+       shift
+       $program "$@" >> test.out 2>&1
+       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() {
+       diag "$@"
+       printf "bail out!\n";
+       exit 255;
+}
+
 shownote() {
        if [ "$note" != "" ]; then
                printf '# %s\n' "$note"
        fi
 }
 
+diag() {
+       printf '# %s\n' "$@"
+}
+
+diagfile() {
+       sed -e 's/^/# /' $1
+}
+
+diagstdin() {
+       sed -e 's/^/# /'
+}
+
 okexit() {
        exitwith 0 "$*"
 }
@@ -42,7 +75,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))