aboutsummaryrefslogtreecommitdiff
path: root/test/run-tests.sh
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2017-07-27 14:16:17 +1200
committerDavid Phillips <david@sighup.nz>2017-07-27 14:16:17 +1200
commit8df5d237856d365a7a49835274e58e8c8bb281b1 (patch)
tree2973898cdff4fd9d4e4e5acf69b97221c879bfb9 /test/run-tests.sh
parent92d9e59d6b3dc5375c100c72ba8907502aea8331 (diff)
downloadsand-leek-8df5d237856d365a7a49835274e58e8c8bb281b1.tar.xz
Add more tests, pull simple test runner from other project
Diffstat (limited to 'test/run-tests.sh')
-rwxr-xr-xtest/run-tests.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/run-tests.sh b/test/run-tests.sh
new file mode 100755
index 0000000..07647dd
--- /dev/null
+++ b/test/run-tests.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+
+fail()
+{
+ echo -e '[\e[1;31mFAIL\e[0m] '$i: $@
+ exit 1
+}
+
+pass()
+{
+ echo -e '[\e[0;32mPASS\e[0m] '$i
+}
+
+check_expected()
+{
+ [ -z $1 ] && echo WARN: check_expected called with no argument
+ if [ -f $1.expected ] ; then
+ diff $1.expected $1.tmp >/dev/null
+ if [ $? -ne 0 ] ; then
+ fail "$1 didn't match expected"
+ fi
+ fi
+}
+
+pushd $(dirname $0) >/dev/null
+EXECUTABLE="../../sand-leek"
+for i in *.test ; do
+ pushd ${i} >/dev/null
+ ( . ./run.sh ) 2>stderr.tmp >stdout.tmp
+ if [ $? -ne 0 ] ; then
+ fail "script had non-zero return code"
+ fi
+
+ check_expected stdout
+ check_expected stderr
+
+ pass $i
+
+ rm std{err,out}.tmp
+ popd >/dev/null
+done
+popd >/dev/null