-
Notifications
You must be signed in to change notification settings - Fork 4
/
runtests
executable file
·45 lines (40 loc) · 1.13 KB
/
runtests
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
#!/bin/bash
USAGE="
$0 {test rom}
For each test rom, or all under tests/ if omitted, run the test in headless mode
and output results. Will exit success only if all listed tests pass.
"
BGB_DEBUGMSG_PATH="$HOME/Downloads/bgb/debugmsg.txt"
SUCCESS_TOKEN="=== Success ==="
runtest() {
echo "Running test rom: $1"
rm -f "$BGB_DEBUGMSG_PATH"
bgb -hf "$1"
if ! [ -f "$BGB_DEBUGMSG_PATH" ]; then
echo "Test rom failed to start, or did not emit any messages"
return 1
fi
cat "$BGB_DEBUGMSG_PATH" | grep -vF "$SUCCESS_TOKEN"
grep -qF "$SUCCESS_TOKEN" "$BGB_DEBUGMSG_PATH" # sets exit status
}
if [ "$#" -gt 0 ]; then
roms=("$@")
else
roms=()
# Note the process substitution is needed here (instead of a pipeline)
# or else the while body will execute in a subshell and roms will be unchanged.
while read line; do
# special case: meta_test/2_this_fails is meant to fail and should be excluded
[ "$line" == "tests/meta_test/2_this_fails.gb" ] && continue
roms+=("$line")
done < <(find tests/ -name '*.gb' | sort)
fi
code=0
for rom in "${roms[@]}"; do
if ! runtest "$rom"; then
echo "$rom failed!"
code=1
fi
echo
done
exit "$code"