124 lines
3.7 KiB
Bash
Executable File
124 lines
3.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Release gate for the Godot port. The matrix is the authoritative inventory
|
|
# of ASCII contracts: a release candidate cannot pass while a contract remains
|
|
# blocked, unowned, or classified without evidence.
|
|
set -euo pipefail
|
|
|
|
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
matrix_path="${MATRIX_PATH:-$root_dir/docs/parity/ASCII_TEST_MATRIX.md}"
|
|
matrix_only=false
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage: scripts/run-parity-gauntlet.sh [--matrix-only]
|
|
|
|
Validate the ASCII parity matrix. Without --matrix-only, also run the
|
|
release-critical Godot save/load and generated-floor seed suites.
|
|
|
|
MATRIX_PATH may override the matrix path for contract testing.
|
|
EOF
|
|
}
|
|
|
|
while (($#)); do
|
|
case "$1" in
|
|
--matrix-only) matrix_only=true ;;
|
|
-h|--help) usage; exit 0 ;;
|
|
*) echo "parity gauntlet: unknown argument: $1" >&2; usage >&2; exit 2 ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [[ ! -r "$matrix_path" ]]; then
|
|
echo "parity gauntlet: matrix is not readable: $matrix_path" >&2
|
|
exit 2
|
|
fi
|
|
|
|
set +e
|
|
matrix_result="$(awk -F'|' '
|
|
/^\|/ {
|
|
status=$3
|
|
evidence=$4
|
|
gsub(/^[[:space:]]+|[[:space:]]+$/, "", status)
|
|
gsub(/^[[:space:]]+|[[:space:]]+$/, "", evidence)
|
|
if (status == "Status" || status == "---") next
|
|
rows++
|
|
if (status == "blocked") {
|
|
printf "blocked row: %s\n", $2
|
|
invalid++
|
|
} else if (status != "ported" && status != "replaced" && status != "not_applicable") {
|
|
printf "invalid status %s: %s\n", status, $2
|
|
invalid++
|
|
}
|
|
if (evidence == "") {
|
|
printf "unowned row: %s\n", $2
|
|
invalid++
|
|
} else if (status == "not_applicable" && evidence !~ /[Jj]ustif/) {
|
|
printf "unjustified not_applicable row: %s\n", $2
|
|
invalid++
|
|
}
|
|
}
|
|
END {
|
|
if (rows == 0) {
|
|
print "matrix has no data rows"
|
|
invalid++
|
|
}
|
|
printf "rows=%d invalid=%d\n", rows, invalid
|
|
exit (invalid == 0 ? 0 : 1)
|
|
}
|
|
' "$matrix_path")"
|
|
matrix_status=$?
|
|
set -e
|
|
if ((matrix_status == 0)); then
|
|
printf 'parity gauntlet: matrix gate passed (%s)\n' "$matrix_result"
|
|
else
|
|
echo "parity gauntlet: release gate FAILED for $matrix_path" >&2
|
|
printf '%s\n' "$matrix_result" >&2
|
|
fi
|
|
|
|
if "$matrix_only"; then
|
|
exit "$matrix_status"
|
|
fi
|
|
|
|
cd "$root_dir"
|
|
"$root_dir/scripts/godot-import.sh"
|
|
|
|
GODOT_BIN="${GODOT_BIN:-/snap/bin/godot4}"
|
|
if [[ ! -x "$GODOT_BIN" ]]; then
|
|
GODOT_BIN="$(command -v godot4 || command -v godot || true)"
|
|
fi
|
|
: "${GODOT_BIN:?Set GODOT_BIN or install godot4/godot}"
|
|
|
|
run_gut() {
|
|
local label="$1"
|
|
local test_path="$2"
|
|
local log_path
|
|
log_path="$(mktemp)"
|
|
trap 'rm -f "$log_path"' RETURN
|
|
set +e
|
|
"$GODOT_BIN" --headless --path . -s res://addons/gut/gut_cmdln.gd -gtest="$test_path" -gexit 2>&1 | tee "$log_path"
|
|
local godot_status=${PIPESTATUS[0]}
|
|
set -e
|
|
if grep -Eq 'SCRIPT ERROR|Parse Error' "$log_path"; then
|
|
echo "parity gauntlet: $label reported a script or parse error" >&2
|
|
return 1
|
|
fi
|
|
if ((godot_status != 0)); then
|
|
echo "parity gauntlet: $label failed" >&2
|
|
return "$godot_status"
|
|
fi
|
|
trap - RETURN
|
|
rm -f "$log_path"
|
|
}
|
|
|
|
run_gut "save/load roundtrip" "res://tests/unit/test_save_repository.gd"
|
|
run_gut "save/load E2E" "res://tests/e2e/test_save_load_e2e.gd"
|
|
run_gut "generated-floor connectivity seeds" "res://tests/integration/test_floor_generator_connectivity.gd"
|
|
run_gut "generated-floor exit-path seeds" "res://tests/integration/test_floor_generator_exit_path.gd"
|
|
run_gut "generated-floor population seeds" "res://tests/integration/test_floor_population_safety.gd"
|
|
|
|
echo "parity gauntlet: release-critical save/load and generated-floor seed suites passed"
|
|
|
|
# Always run the executable gauntlet so blocked inventory rows do not hide a
|
|
# regression, but preserve the matrix failure as the release command's result.
|
|
exit "$matrix_status"
|