blob: 073d12c2eac6a3eab33f3a2409af0fe53de70236 (
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
|
#!/bin/sh
pass=0
fail=0
for testfile in tests/*.bth; do
outfile=${testfile%.bth}.out
output="$(./bth <$testfile 2>&1)"
run_res=$?
echo "$output" | diff $outfile - >/dev/null
diff_res=$?
testname=${testfile#tests/}
testname=${testname%.bth}
case $diff_res in
0) printf '\033[32m\033[1mPASS\033[0m %s\n' "$testname"
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
printf "\033[32m%s\033[0m passed; " $pass
if [ $fail -eq 0 ]; then
printf "0 failed; "
else
printf "\033[31m%s\033[0m failed; " $fail
fi
printf "%s total\n" $((pass + fail))
if [ $fail -eq 0 ]; then
exit 0
else
exit 1
fi
|