blob: 6caef322d2058c2f5b0a489f507cc357ef0267d4 (
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
49
50
51
52
53
54
55
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
|