about summary refs log tree commit homepage
path: root/t/test-lib.sh
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-04 16:38:08 -0700
committerEric Wong <normalperson@yhbt.net>2009-10-04 18:38:32 -0700
commit903766ba0d278cb55d08e072c4c96c1d7f0dee8d (patch)
tree3f29a3aab6452c304043816c7c1c3c76f3009d8a /t/test-lib.sh
parent756c060f2992d35e30249688f1cfab8de9b4dfc1 (diff)
downloadrainbows-903766ba0d278cb55d08e072c4c96c1d7f0dee8d.tar.gz
I'd rather write shell scripts in shell than shell scripts in
Ruby like was done with Unicorn.  We're a *nix-only project so
we'll embrace *nix tools to their fullest extent and as a
pleasant side-effect these test cases are immune to internal API
changes.
Diffstat (limited to 't/test-lib.sh')
-rw-r--r--t/test-lib.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
new file mode 100644
index 0000000..9e286bc
--- /dev/null
+++ b/t/test-lib.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Copyright (c) 2009 Eric Wong
+set -e
+set -u
+T=$(basename $0)
+ruby="${ruby-ruby}"
+
+# ensure a sane environment
+TZ=UTC LC_ALL=C LANG=C
+export LANG LC_ALL TZ
+unset CDPATH
+
+die () {
+        echo >&2 "$@"
+        exit 1
+}
+
+TEST_RM_LIST=""
+trap 'rm -f $TEST_RM_LIST' 0
+PATH=$PWD/bin:$PATH
+export PATH
+
+test -x $PWD/bin/unused_listen || die "must be run in 't' directory"
+
+wait_for_pid () {
+        path="$1"
+        nr=30
+        while ! test -s "$path" && test $nr -gt 0
+        do
+                nr=$(($nr - 1))
+                sleep 1
+        done
+}
+
+require_revactor () {
+        if ! $ruby -rrevactor -e "puts Revactor::VERSION" >/dev/null 2>&1
+        then
+                echo >&2 "skipping $T since we don't have Revactor"
+                exit 0
+        fi
+}