blob: 2e2de830c4b320372a6eff6f79ad63b9d397a842 (
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
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
|
#!/bin/sh
pass=0
fail=0
skip=0
show_passes=false
if [ "$1" = "-a" ]; then
show_passes=true
shift
fi
skipglob="$1"
skip() {
printf '\033[33mSKIP\033[0m %s (%s)\n' "$testname" "$1"
skip=$((skip + 1))
}
for testfile in tests/*.bth; do
outfile=${testfile%.bth}.out
testname=${testfile#tests/}
testname=${testname%.bth}
if [ ! -f "$outfile" ]; then
skip "no output file"
continue
fi
case "$testname" in
$skipglob) skip "matches skip glob $skipglob"
continue ;;
esac
output="$(./bth "$testfile" 2>&1)"
echo "$output" | diff "$outfile" - >/dev/null
diff_res=$?
case $diff_res in
0) if $show_passes; then
printf '\033[32m\033[1mPASS\033[0m %s\n' "$testname"
fi
pass=$((pass + 1)) ;;
1) printf '\033[31m\033[1mFAIL\033[0m %s\n' "$testname"
printf "\tgot output: %s\n" "$(echo "$output" | head -n4)"
printf "\texpected: "
cat "$outfile"
fail=$((fail + 1)) ;;
esac
done
echo
pnum () {
if [ "$1" -eq 0 ]; then
printf "0 %s; " "$2"
else
printf "\033[3%dm%d\033[0m %s; " "$3" "$1" "$2"
fi
}
pnum $pass passed 2
pnum $fail failed 1
pnum $skip skipped 3
printf "%s total\n" $((pass + fail + skip))
if [ $fail -eq 0 ]; then
exit 0
else
exit 1
fi
|