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>
35 lines
1.1 KiB
Bash
Executable File
35 lines
1.1 KiB
Bash
Executable File
#!/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"
|