aboutsummaryrefslogtreecommitdiff
path: root/test/run.sh
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <msabate@suse.com>2023-12-21 00:02:51 +0100
committerMiquel Sabaté Solà <msabate@suse.com>2023-12-21 18:41:41 +0100
commit9e22faffffa20aa256a05468157404006e2e4d1e (patch)
tree04266bf24d93a5a11452c27c10dbca16e3a3a8d9 /test/run.sh
downloadlist.nes-9e22faffffa20aa256a05468157404006e2e4d1e.tar.gz
list.nes-9e22faffffa20aa256a05468157404006e2e4d1e.zip
Initial commit
Implemented the List scope which brings some handy macros and functions to manipulate big lists on the NES. Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'test/run.sh')
-rw-r--r--test/run.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/run.sh b/test/run.sh
new file mode 100644
index 0000000..6caef32
--- /dev/null
+++ b/test/run.sh
@@ -0,0 +1,56 @@
+#!/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"
+
+# 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 [ ! -z "${GITHUB_ACTION}" ]; then
+ exit 0
+fi
+
+# 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