TableTower/tools/run_tests.sh

46 lines
1.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Runs every headless suite in parallel and prints one line per suite.
# A suite fails if it doesn't print "PASS: 0 failure(s)" or if its output has
# a SCRIPT ERROR (a crashed test function can still print PASS).
# Usage: tools/run_tests.sh [name-filter] e.g. tools/run_tests.sh inspector
# Failing suites print their first 8 error lines; passing output is discarded.
set -u
cd "$(dirname "$0")/.."
GODOT="${GODOT:-$HOME/apps/Godot_v4.7.2-stable_linux.x86_64}"
OUT="$(mktemp -d)"
trap 'rm -rf "$OUT"' EXIT
suites=(tests/test_*${1:-}*.gd)
# Register any new class_name scripts first (cheap when nothing changed).
"$GODOT" --headless --path . --import >/dev/null 2>&1
for t in "${suites[@]}"; do
n="$(basename "$t" .gd)"
( timeout 300 "$GODOT" --headless --path . -s "res://$t" -- --sample >"$OUT/$n.log" 2>&1 ) &
while (( $(jobs -rp | wc -l) >= ${JOBS:-8} )); do wait -n; done
done
wait
fail=0
declare -A first_err
for t in "${suites[@]}"; do
n="$(basename "$t" .gd)"
log="$OUT/$n.log"
if grep -q "PASS: 0 failure(s)" "$log" && ! grep -q "SCRIPT ERROR" "$log"; then
echo "ok $n"
continue
fi
fail=1
e="$(grep -m1 -E "SCRIPT ERROR|^ *FAIL [^:]" "$log")"
# A shared compile error fails many suites the same way: report it once.
if [[ "$e" == *"SCRIPT ERROR"* ]]; then
first_err["$e"]+="$n "
else
echo "FAIL $n"
grep -E "FAIL|SCRIPT ERROR|ERROR" "$log" | head -8
fi
done
for e in "${!first_err[@]}"; do
echo "FAIL ${first_err[$e]}"
echo " $e"
done
(( fail )) && echo "SOME SUITES FAILED" || echo "ALL ${#suites[@]} SUITES PASSED"
exit $fail