summaryrefslogtreecommitdiff
path: root/tests/run_tests.sh
blob: 4e4697747c383b56ee1454b83d2b11428cdc0f31 (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
40
41
42
#!/bin/sh

set -e

run() {
    ( # So we don't have to cd ..
        cd "$1" || return 1

        php ../test.php > have

        printf '\e[1m%s\e[0m: ' "$1"
        if sed 's/\s*//' < have | grep -v '^$' | cmp -s want; then
            echo "OK"
            rm ./*.transc.php
        else
            echo "FAILED"
            for tpl in *.tpl; do
                php ../dump_ast.php < "$tpl" > "$tpl.ast"
            done
            return 1
        fi
    )
}

run_many() {
    retval=0
    while [ $# -gt 0 ]; do
        if ! run "$1"; then
            retval=1
        fi

        shift
    done

    return $retval
}

if [ $# -eq 0 ]; then
    run_many test_*
else
    run_many "$@"
fi