68 lines
2.1 KiB
Bash
Executable File
68 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$root_dir"
|
|
GODOT_BIN="${GODOT_BIN:-/snap/bin/godot4}"
|
|
if [[ ! -x "$GODOT_BIN" ]]; then
|
|
GODOT_BIN="$(command -v godot4 || command -v godot || true)"
|
|
fi
|
|
if [[ -z "$GODOT_BIN" ]]; then
|
|
echo "visual check unavailable: set GODOT_BIN or install godot4/godot" >&2
|
|
exit 2
|
|
fi
|
|
|
|
"$root_dir/scripts/godot-import.sh"
|
|
|
|
mkdir -p artifacts
|
|
log_path="artifacts/visual-check.log"
|
|
initial_capture_path="artifacts/visual-check.png"
|
|
exit_capture_path="artifacts/visual-check-exit.png"
|
|
rm -f "$initial_capture_path" "$exit_capture_path"
|
|
: > "$log_path"
|
|
|
|
runner=()
|
|
if [[ -z "${DISPLAY:-}" ]]; then
|
|
if command -v xvfb-run >/dev/null 2>&1; then
|
|
runner=(xvfb-run --auto-servernum --server-args="-screen 0 1280x720x24")
|
|
else
|
|
echo "visual check unavailable: DISPLAY is unset and xvfb-run is not installed" | tee "$log_path" >&2
|
|
exit 2
|
|
fi
|
|
fi
|
|
|
|
run_capture() {
|
|
local label="$1"
|
|
local capture_argument="$2"
|
|
set +e
|
|
timeout --foreground 20s "${runner[@]}" "$GODOT_BIN" --path . -- --"$capture_argument" >>"$log_path" 2>&1
|
|
local status=$?
|
|
set -e
|
|
if (( status != 0 )); then
|
|
echo "visual check failed: $label capture Godot exited with status $status; see $log_path" >&2
|
|
exit "$status"
|
|
fi
|
|
}
|
|
|
|
run_capture "initial" "capture"
|
|
run_capture "exit" "capture-exit"
|
|
# Godot's SCRIPT ERROR / Parse Error diagnostics are actionable application
|
|
# failures. Do not treat unrelated backend diagnostics (for example the
|
|
# expected xkbcommon Compose warnings emitted by some Snap/Xvfb setups) as an
|
|
# application failure.
|
|
if grep -Ev '^ERROR: [0-9]+ resources still in use at exit$' "$log_path" | grep -Eq 'SCRIPT ERROR|Parse Error|^ERROR:'; then
|
|
echo "visual check failed: Godot application error; see $log_path" >&2
|
|
exit 1
|
|
fi
|
|
|
|
measure_capture() {
|
|
local capture_path="$1"
|
|
if ! python3 "$root_dir/scripts/check-visual-capture.py" "$capture_path"; then
|
|
echo "visual check failed: invalid or unreadable capture $capture_path" >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
measure_capture "$initial_capture_path"
|
|
measure_capture "$exit_capture_path"
|