summaryrefslogtreecommitdiff
path: root/run_tests.sh
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2019-03-16 20:33:08 +1300
committerDavid Phillips <david@sighup.nz>2019-03-16 20:33:08 +1300
commit16a2da0f217aa4f2da4b084014e4da731740e0df (patch)
treef86f9bfe2c02c4d0c61c0fc523f22d65703f0eb5 /run_tests.sh
parent605e548e42c2ec4882a65b88a09c329a4819cb0a (diff)
downloadsudoku-16a2da0f217aa4f2da4b084014e4da731740e0df.tar.xz
Add simple solver testing framework
Diffstat (limited to 'run_tests.sh')
-rwxr-xr-xrun_tests.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/run_tests.sh b/run_tests.sh
new file mode 100755
index 0000000..2cff423
--- /dev/null
+++ b/run_tests.sh
@@ -0,0 +1,33 @@
+#!/bin/bash -e
+
+exit_code=0
+
+[ -z "$SOLVER" ] && SOLVER="$PWD/test-solver"
+XFAILS="$PWD/test/xfails"
+
+test_fail() {
+ t="$(basename $1)"
+ if grep -q "$t" "$XFAILS" ; then
+ echo -e "$t: "'[\e[34;1mXFAIL\e[0m]'
+ else
+ echo -e "$t: "'[\e[31;1mFAIL\e[0m]'
+ fi
+}
+
+test_pass() {
+ t="$(basename $1)"
+ echo -e "$t: "'[\e[32;1mPASS\e[0m]'
+}
+
+for t in test/*-* ; do
+ pushd "$t" >/dev/null
+ if ! "$SOLVER" >/dev/null ; then
+ test_fail "$t"
+ exit_code=1
+ else
+ test_pass "$t"
+ fi
+ popd >/dev/null
+done
+
+exit "$exit_code"