37 lines
1.1 KiB
Bash
Executable file
37 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Runs the GUT headless test suite — mirrors the CI "headless GUT" step exactly.
|
|
# Flatpak swallows get_tree().quit() exit codes, so we write a JUnit XML report
|
|
# to a home-accessible path and parse it for the failure count.
|
|
#
|
|
# Usage: bash tools/gut-headless.sh [extra gut flags]
|
|
set -uo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
RESULTS_DIR="$REPO_ROOT/.local/iter"
|
|
mkdir -p "$RESULTS_DIR"
|
|
RESULTS_FILE="$RESULTS_DIR/gut-junit.xml"
|
|
|
|
flatpak run --filesystem=home org.godotengine.Godot \
|
|
--path "$REPO_ROOT/src/game" \
|
|
--headless \
|
|
-s addons/gut/gut_cmdln.gd \
|
|
-gdir=engine/tests/unit \
|
|
-gexit \
|
|
"-gjunit_xml_file=$RESULTS_FILE" \
|
|
"$@"
|
|
|
|
# Flatpak swallows Godot's quit() exit code; parse the JUnit report instead.
|
|
# The first <testsuites ...> line has the aggregate failures="N" count.
|
|
FAIL_COUNT=0
|
|
if [[ -f "$RESULTS_FILE" ]]; then
|
|
FAIL_COUNT=$(grep -oP 'failures="\K[0-9]+' "$RESULTS_FILE" | head -1)
|
|
FAIL_COUNT=${FAIL_COUNT:-0}
|
|
fi
|
|
|
|
if [[ "$FAIL_COUNT" -gt 0 ]]; then
|
|
echo "gut-headless: $FAIL_COUNT failing test(s)" >&2
|
|
exit 1
|
|
fi
|
|
exit 0
|