#!/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 # Full output of failing suites is printed; 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) 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 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" else echo "FAIL $n" grep -E "FAIL|SCRIPT ERROR|ERROR|at: " "$log" | head -40 fail=1 fi done (( fail )) && echo "SOME SUITES FAILED" || echo "ALL ${#suites[@]} SUITES PASSED" exit $fail