File: runtests

package info (click to toggle)
mallard-ducktype 0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,232 kB
  • sloc: python: 3,590; sh: 53; makefile: 7
file content (47 lines) | stat: -rwxr-xr-x 1,110 bytes parent folder | download
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/sh

set -e
set -u

count=0
any_failed=0

for duck in *.duck; do
    count=$(( count + 1 ))
    out=$(echo $duck | sed -e 's/\.duck$/.out/')
    page=$(echo $duck | sed -e 's/\.duck$/.page/')
    error=$(echo $duck | sed -e 's/\.duck$/.error/')
    fail=""
    if [ -f "$page" ]; then
        python3 runtest.py "$duck" > "$out" || fail="exit status $?"
        if ! cmp "$out" "$page" >&2; then
            fail="${fail:+${fail}, }unexpected output"
            diff -u "$out" "$page" >&2 || :
        fi
    elif [ -f "$error" ]; then
        status=0
        python3 runtest.py "$duck" > "$out" || :
        if ! cmp "$out" "$error" >&2; then
            fail="unexpected error message"
            diff -u "$out" "$error" >&2 || :
        fi
    else
        fail="neither $page nor $error exists"
    fi
    if [ -z "$fail" ]; then
        echo "ok $count - $duck"
    else
        any_failed=1
        echo "not ok $count - $duck: $fail"
    fi
done

echo "1..$count"

if [ "$any_failed" = 0 ]; then
    echo "# All tests successful"
else
    echo "# At least one test failed"
fi

exit $any_failed