File: runtests

package info (click to toggle)
mallard-ducktype 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,648 kB
  • sloc: python: 4,054; sh: 64; makefile: 7
file content (59 lines) | stat: -rwxr-xr-x 1,316 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

set -e
set -u

count=0
any_failed=0
silent=0
glob=""

for arg in $@; do
    if [ "x$arg" = "x-s" ]; then
        silent=1
    elif [ "x$arg" != "x" ]; then
        glob="$arg"
    fi
done

for duck in *$glob*.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
        if [ $silent = 0 ]; then
            echo "ok $count - $duck"
        fi
    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