summaryrefslogtreecommitdiff
path: root/minitap.sh
diff options
context:
space:
mode:
Diffstat (limited to 'minitap.sh')
-rw-r--r--minitap.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/minitap.sh b/minitap.sh
new file mode 100644
index 0000000..d5bb4f8
--- /dev/null
+++ b/minitap.sh
@@ -0,0 +1,59 @@
+minitap_started=0
+minitap_counter=0
+
+function ok() {
+ minitap/maybe-start
+ (( ++minitap_counter ))
+ echo "ok ${minitap_counter} - $*"
+}
+
+function nok() {
+ minitap/maybe-start
+ (( ++minitap_counter ))
+ echo "not ok ${minitap_counter} - $*"
+}
+
+function diag() {
+ echo "# $*"
+}
+
+function is() {
+ local got="$1";shift
+ local expect="$1";shift
+
+ if [[ "$got" == $expect ]]; then
+ ok "$@"
+ else
+ diag "got <$got>, expected <$expect>";
+ nok "$@"
+ fi
+}
+
+function should-succeed() {
+ local last_status="$?"
+ if [[ "$last_status" -eq 0 ]]; then
+ ok "$@"
+ else
+ nok "$@"
+ fi
+}
+
+function should-fail() {
+ local last_status="$?"
+ if [[ "$last_status" -eq 0 ]]; then
+ nok "$@"
+ else
+ ok "$@"
+ fi
+}
+
+function done-testing() {
+ echo "1..${minitap_counter}"
+}
+
+function minitap/maybe-start() {
+ if [[ "$minitap_started" == 0 ]]; then
+ echo "TAP version 13"
+ minitap_started=1
+ fi
+}