aboutsummaryrefslogtreecommitdiff
path: root/test/run.sh
blob: 54b69e08bfbeacefc92649a9d33fb57d3dd1b7aa (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
43
44
45
46
47
48
#!/usr/bin/env bash

set -e

ROOT="$( cd "$( dirname "$0" )/.." && pwd )"
cd "$ROOT"

# Clean previous builds, prepare the test environment and call build again with
# a test setup.
sed -i 's/.ifdef RUN_TESTS/RUN_TESTS = 1\n.ifdef RUN_TESTS/g' "$ROOT/test/suite.s"
DEBUG=1 make test/suite.nes

rm -f "$ROOT/tmp/test-results.txt"

# Run all the tests that we have on Lua.
for file in test/*.lua; do
    if [ -n "$(echo $file | grep -v utils.lua)" ]; then
        echo $file
        fceux --loadlua $file "$ROOT/test/suite.nes"
    fi
done

#
# Show the results.

if [ ! -f "$ROOT/tmp/test-results.txt" ]; then
    echo "Something went wrong: test results were not printed out!"
    exit 1
fi

cat "$ROOT/tmp/test-results.txt"

n=$(cat "$ROOT/tmp/test-results.txt" | grep FAIL | wc -l)
echo ""
case $n in
    0)
        echo "All tests passed!"
        exit 0
        ;;
    1)
        echo "1 test failed!"
        exit 1
        ;;
    *)
        echo "$n tests failed!"
        exit 1
        ;;
esac