]> pd.if.org Git - zpackage/commitdiff
add shell tap functions
authorNathan Wagner <nw@hydaspes.if.org>
Fri, 21 Sep 2018 07:51:15 +0000 (07:51 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Mon, 24 Sep 2018 10:40:18 +0000 (10:40 +0000)
improve shell tap diag output

t/tap.sh

index 1811f5dde48aacbf9ed9945d9a15eb8596d40ba9..580fcbd2d02d6be9e0627a880af59dee46bd6ad8 100755 (executable)
--- a/t/tap.sh
+++ b/t/tap.sh
@@ -16,21 +16,26 @@ tryrun() {
 }
 
 require() {
-       note="$@"
+       note="$*"
        program=$1
        shift
        $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 "$*"
+               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"
@@ -41,6 +46,14 @@ diag() {
        printf '# %s\n' "$@"
 }
 
+diagfile() {
+       sed -e 's/^/# /' $1
+}
+
+diagstdin() {
+       sed -e 's/^/# /'
+}
+
 okexit() {
        exitwith 0 "$*"
 }