summaryrefslogtreecommitdiff
path: root/run_tests.sh
blob: e185b3ff9cd843e34e797674aeb69598ddb23b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash

t_pass=0
t_fail=0
t_xfail=0

[ -z "$SOLVER" ] && SOLVER="$PWD/test-solver"
XFAILS="$PWD/test/xfails"

test_fail() {
	t="$(basename $1)"
	reason="$2"
	if grep -q "^$t\b" "$XFAILS" ; then
		echo -e '[\e[34;1mXFAIL\e[0m]'" $t: $reason"
		((t_xfail++))
	else
		echo -e '[\e[31;1mFAIL\e[0m]'"  $t: $reason"
		((t_fail++))
	fi
}

test_pass() {
	t="$(basename $1)"
	echo -e '[\e[32;1mPASS\e[0m]'"  $t"
	((t_pass++))
}

for t in test/*-* ; do
	pushd "$t" >/dev/null
	reason="$("$SOLVER" 2>&1 1>/dev/null)"
	if [ "$?" -ne 0 ]; then
		test_fail "$t" "$reason"
	else
		test_pass "$t"
	fi
	popd >/dev/null
done

total_fail="$((t_fail + t_xfail))"
echo "========================================"
echo "Passes  : $t_pass"
echo "Failures: $t_fail ($t_xfail of which are expected)"
echo "========================================"

if [ "$t_fail" -gt "0" ]; then
	exit 1
fi