aboutsummaryrefslogtreecommitdiff
path: root/test/run.sh
blob: 8b3e5e66c790822efa1eecdebc8ff0d5f3156f13 (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
#!/usr/bin/env bash

set -e

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

# Clean previous builds and prepare the test environment.
rm -f "$ROOT/out/test-results.txt"
make clean
sed -i 's/RUN_TESTS = 0/RUN_TESTS = 1/g' $ROOT/test/defines.s

# Run all the tests that we have on Lua.
for name in $(seq 4); do
    DEBUG=1 make out/$name.nes
    fceux --loadlua "$ROOT/test/$name.lua" "$ROOT/out/$name.nes"
done

# Show the results.
cat "$ROOT/out/test-results.txt"
n=$(cat "$ROOT/out/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