-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-tests.sh
executable file
·83 lines (72 loc) · 1.39 KB
/
run-tests.sh
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
if [ "$1" = "-v" ]; then
verbose="-v"
elif [ -n "$1" ]; then
echo
echo " Usage: $0 [-v]"
echo
echo " -v Show verbose output from tests"
echo
exit 2
else
verbose=""
fi
set -eu
cd $(dirname "$0")
count=$(ls -1 tests/test-*.sh | wc -l | sed 's/[^0-9]//g')
i=1
passcount=0
failcount=0
failing=""
run_a_test() {
local test="$1"
if [ -n "$verbose" ]; then
./$t
else
./$t >/dev/null 2>&1
fi
}
if [ -n "$verbose" ]; then
export REPOINT_VERBOSE=1
else
echo
fi
for t in tests/test-*.sh ; do
if [ -n "$verbose" ]; then
echo
echo "Test $i/$count: $t..."
else
echo -n "$t: "
fi
if run_a_test $t; then
if [ -n "$verbose" ]; then
echo "pass: $t"
else
echo "pass"
fi
passcount=$(($passcount+1))
else
if [ -n "$verbose" ]; then
echo "FAIL: $t"
else
echo "FAIL"
fi
failcount=$(($failcount+1))
failing="$failing $t"
fi
i=$(($i + 1))
done
if [ "$passcount" = "$count" ]; then
echo
echo "** PASS: All tests ($passcount/$count) passed"
echo
else
echo
echo "** FAIL: $failcount tests (of $count) failed"
echo "** Failing tests:$failing"
if [ -z "$verbose" ]; then
echo "** Re-run with -v for verbose output"
fi
echo
exit 3
fi