Files

60 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Contract tests for the release parity gate. These fixtures keep the real
# matrix untouched while proving that release-blocking classifications cannot
# accidentally be reported as a passing gauntlet.
set -euo pipefail
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
temporary_dir="$(mktemp -d)"
trap 'rm -rf "$temporary_dir"' EXIT
write_matrix() {
local path="$1"
local status="$2"
local evidence="$3"
cat >"$path" <<EOF
# fixture
| ASCII module | Status | Godot evidence / planned owner |
| --- | --- | --- |
| \`test_fixture.py\` | $status | $evidence |
EOF
}
assert_gate_passes() {
local name="$1"
local status="$2"
local evidence="$3"
local matrix="$temporary_dir/${name}.md"
write_matrix "$matrix" "$status" "$evidence"
MATRIX_PATH="$matrix" "$root_dir/scripts/run-parity-gauntlet.sh" --matrix-only
}
assert_gate_fails() {
local name="$1"
local status="$2"
local evidence="$3"
local matrix="$temporary_dir/${name}.md"
local log="$temporary_dir/${name}.log"
write_matrix "$matrix" "$status" "$evidence"
set +e
MATRIX_PATH="$matrix" "$root_dir/scripts/run-parity-gauntlet.sh" --matrix-only >"$log" 2>&1
local status_code=$?
set -e
if [[ "$status_code" -eq 0 ]]; then
echo "parity gate unexpectedly accepted $name" >&2
cat "$log" >&2
exit 1
fi
}
assert_gate_passes "ported" "ported" 'G1 — `test_fixture.gd`'
assert_gate_passes "replaced" "replaced" 'G1 — `test_fixture.gd`'
assert_gate_passes "not-applicable" "not_applicable" 'Justified: graphical port has no terminal-only equivalent.'
assert_gate_fails "blocked" "blocked" "G6 — pending"
assert_gate_fails "unowned" "replaced" ""
assert_gate_fails "unjustified-not-applicable" "not_applicable" "No equivalent"
assert_gate_fails "unknown-status" "pending" "G6 — pending"
echo "parity gauntlet matrix gate contracts passed"