summaryrefslogtreecommitdiffstats
path: root/test
blob: 5b1090105aa5f8daba564ddf6e6133b84abb4c63 (plain) (blame)
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
#!/bin/sh

# Every test file must start with a line formatted as follows:
#   #:<exit code>:<additional makel command line options>

exec >&2

nfails=0

for f in tests/*.mk; do
    header="$(head -n 1 < "$f")"
    expected=$(printf '%s' "$header" | cut -d : -f 2)
    options="$(printf '%s' "$header" | cut -d : -f 3-)"

    ./makel -f "$f" $options >/dev/null 2>/dev/null
    got=$?

    if test $got -lt $expected; then
        printf '%s: %s\n' "$f" "defect was not detected (expected ${expected}, got ${got})"
        : $(( nfails++ ))
    elif test $got -gt $expected; then
        printf '%s: %s\n' "$f" "found more serious defects than expected (expected ${expected}, got ${got})"
        : $(( nfails++ ))
    fi
done

if test $nfails -gt 0; then
    printf '%s\n' '----------'
    printf '%s\n' "${nfails} tests returned different exit codes than expected."
fi