Debian Codegraph @

tests/runtests

raw
1 #!/bin/sh
2
3 set -e
4 set -u
5
6 count=0
7 any_failed=0
8 silent=0
9 glob=""
10
11 for arg in $@; do
12 if [ "x$arg" = "x-s" ]; then
13 silent=1
14 elif [ "x$arg" != "x" ]; then
15 glob="$arg"
16 fi
17 done
18
19 for duck in *$glob*.duck; do
20 count=$(( count + 1 ))
21 out=$(echo $duck | sed -e 's/\.duck$/.out/')
22 page=$(echo $duck | sed -e 's/\.duck$/.page/')
23 error=$(echo $duck | sed -e 's/\.duck$/.error/')
24 fail=""
25 if [ -f "$page" ]; then
26 python3 runtest.py "$duck" > "$out" || fail="exit status $?"
27 if ! cmp "$out" "$page" >&2; then
28 fail="${fail:+${fail}, }unexpected output"
29 diff -u "$out" "$page" >&2 || :
30 fi
31 elif [ -f "$error" ]; then
32 status=0
33 python3 runtest.py "$duck" > "$out" || :
34 if ! cmp "$out" "$error" >&2; then
35 fail="unexpected error message"
36 diff -u "$out" "$error" >&2 || :
37 fi
38 else
39 fail="neither $page nor $error exists"
40 fi
41 if [ -z "$fail" ]; then
42 if [ $silent = 0 ]; then
43 echo "ok $count - $duck"
44 fi
45 else
46 any_failed=1
47 echo "not ok $count - $duck: $fail"
48 fi
49 done
50
51 echo "1..$count"
52
53 if [ "$any_failed" = 0 ]; then
54 echo "# All tests successful"
55 else
56 echo "# At least one test failed"
57 fi
58
59 exit $any_failed