diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2023-12-08 21:57:52 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2023-12-08 21:57:52 +0100 |
| commit | 46103595c072651ade490c48c417f5d8d7ba9327 (patch) | |
| tree | 92cc48e3e88e614618ea2cca3771c88674f92189 /test/run.sh | |
| parent | 57fde0bb5184371da33b212de6731c6e6829349f (diff) | |
| download | aoc2023.nes-46103595c072651ade490c48c417f5d8d7ba9327.tar.gz aoc2023.nes-46103595c072651ade490c48c417f5d8d7ba9327.zip | |
Added a test suite
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'test/run.sh')
| -rw-r--r-- | test/run.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/run.sh b/test/run.sh new file mode 100644 index 0000000..2142ad1 --- /dev/null +++ b/test/run.sh @@ -0,0 +1,44 @@ +#!/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 + +# Github Actions do not allow GUI programs to be run. This means that the code +# below will always fail (fceux won't be able to run). There is a way to emulate +# an X server with tools like xvfb-run or xvncserver, but so far I've had no +# luck on this front. +if [ -n "${GITHUB_ACTION}" ]; then + exit 0 +fi + +# Run all the tests that we have on Lua. +for name in $(seq 2); 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 |
