From b876033bd42f1924f9f4e85189b88b1741d568cd Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Wed, 28 Sep 2016 00:45:56 +0000 Subject: [PATCH] move shell tap functions to separate file --- t/tap.sh | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 t/tap.sh diff --git a/t/tap.sh b/t/tap.sh new file mode 100755 index 0000000..23c5299 --- /dev/null +++ b/t/tap.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +tn=0 +planned=0 + +tryrun() { + note="$@" + program=$1 + shift + $program "$@" + if [ $? -ne 0 ]; then + printf 'not '; + fi + tn=$((tn + 1)) + printf 'ok %d - %s %s\n' $tn $program "$*" +} + +shownote() { + if [ "$note" != "" ]; then + printf '# %s\n' "$note" + fi +} + +okexit() { + exitwith 0 "$*" +} + +failsok() { + note= + if [ $? -eq 0 ]; then + printf 'not '; + note=$(printf '# got "%d" expected "%d"' "$1" "0") + fi + tn=$((tn + 1)) + printf 'ok %d - %s\n' $tn "$*" + shownote +} + +exitwith() { + note= + if [ $? -ne $1 ]; then + printf 'not '; + note=$(printf '# got "%d" expected "%d"' "$1" "$2") + fi + shift + tn=$((tn + 1)) + printf 'ok %d - %s\n' $tn "$*" + shownote +} + +okstreq() { + note= + if [ "$1" != "$2" ]; then + printf 'not '; + note=$(printf 'got "%s" expected "%s"' "$1" "$2") + fi + + shift;shift; + tn=$((tn + 1)) + printf 'ok %d - %s\n' $tn "$*" + shownote +} + +plan() { + planned=$1 + printf '1..%d\n' $planned +} + +finish() { + if [ $planned -eq 0 ]; then + printf '1..%d\n' $tn + fi +} -- 2.40.0