summaryrefslogtreecommitdiffstatshomepage
path: root/tests/run-tests-exp.sh
blob: 8f81b96d2fe89fc5070cdce041e5776ec58990b2 (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
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
#
# This is plain shell variant of run-tests script, which uses .exp files
# as generated by run-tests --write-exp. It is useful to run testsuite
# on embedded systems which don't have CPython3.
#

RM="rm -f"
MP_PY=micropython

numtests=0
numtestcases=0
numpassed=0
numskipped=0
numfailed=0
nameskipped=
namefailed=

if [ $# -eq 0 ]
then
    tests="basics/*.py micropython/*.py float/*.py import/*.py io/*.py misc/*.py unicode/*.py extmod/*.py unix/*.py"
else
    tests="$@"
fi

for infile in $tests
do
    basename=`basename $infile .py`
    outfile=${basename}.py.out
    expfile=$infile.exp

    $MP_PY $infile > $outfile
    numtestcases=$(expr $numtestcases + $(cat $expfile | wc -l))

    if grep -q "SKIP\|SyntaxError: invalid micropython decorator" $outfile
    then
        # we don't count tests that explicitly ask to be skipped
        # we don't count tests that fail due to unsupported decorator
        echo "skip  $infile"
        $RM $outfile
        numskipped=$(expr $numskipped + 1)
        nameskipped="$nameskipped $basename"
    else
        diff --brief $expfile $outfile > /dev/null

        if [ $? -eq 0 ]
        then
            echo "pass  $infile"
            $RM $outfile
            numpassed=$(expr $numpassed + 1)
        else
            echo "FAIL  $infile"
            numfailed=$(expr $numfailed + 1)
            namefailed="$namefailed $basename"
        fi
    fi

    numtests=$(expr $numtests + 1)
done

echo "$numtests tests performed ($numtestcases individual testcases)"
echo "$numpassed tests passed"
if [ $numskipped != 0 ]
then
    echo "$numskipped tests skipped -$nameskipped"
fi
if [ $numfailed != 0 ]
then
    echo "$numfailed tests failed -$namefailed"
    exit 1
else
    exit 0
fi