F4: Headless test harness
Add an in-repo test runner that discovers test/**/test_*.gd and runs under --headless. It uses Godot's Logger API, so engine and script errors during a test fail that test. make test runs the suite, and make test-selfcheck runs deliberately failing fixtures to prove each kind of failure is detected. Closes #4 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Runs the headless test suite. Extra arguments are passed to the runner, for
|
||||
# example: tools/run_tests.sh --root=res://test/sim
|
||||
set -uo pipefail
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
# A hang in a test must fail the run, not block it forever.
|
||||
exec timeout --signal=KILL "${TIDEWALL_TEST_TIMEOUT:-900}" \
|
||||
tools/godot.sh --script res://test/framework/runner.gd -- "$@"
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# Proves the test runner detects each kind of failure, using deliberate fixtures.
|
||||
set -uo pipefail
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
status=0
|
||||
# check <fixture> <expected exit> <text that must appear in the output>
|
||||
check() {
|
||||
local fixture="$1" expected="$2" needle="$3" output code
|
||||
output="$(tools/run_tests.sh "--root=res://test/fixtures/$fixture" 2>&1)"
|
||||
code=$?
|
||||
if [[ "$code" -ne "$expected" ]]; then
|
||||
echo "selfcheck FAIL $fixture: exit $code, expected $expected"
|
||||
echo "$output" | tail -n 20
|
||||
status=1
|
||||
elif ! grep -qF -- "$needle" <<<"$output"; then
|
||||
echo "selfcheck FAIL $fixture: output lacks '$needle'"
|
||||
echo "$output" | tail -n 20
|
||||
status=1
|
||||
else
|
||||
echo "selfcheck ok $fixture (exit $code)"
|
||||
fi
|
||||
}
|
||||
|
||||
check passes 0 "Tests: 3 passed, 0 failed."
|
||||
check assert 1 "deliberate fixture failure: expected 3, got 2"
|
||||
check script_error 1 "engine error:"
|
||||
check engine_error 1 "engine error:"
|
||||
check parse_error 1 "could not compile the script"
|
||||
check not_a_test 1 "does not extend TestCase"
|
||||
check missing_error 1 "expected an engine error containing"
|
||||
check empty 1 "No tests ran"
|
||||
|
||||
exit "$status"
|
||||
Reference in New Issue
Block a user