Files
DungeonCrawlerWorld/tests/scripts/test_export_scripts.sh

48 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Contract test for G5 release scripts. It needs no Godot installation: a tiny
# stand-in lets the test prove that the scripts themselves reject absent templates
# before attempting an export.
set -euo pipefail
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
temporary_dir="$(mktemp -d)"
trap 'rm -rf "$temporary_dir"' EXIT
fake_godot="$temporary_dir/godot"
cat >"$fake_godot" <<'FAKE_GODOT'
#!/usr/bin/env bash
set -euo pipefail
if [[ "${1:-}" == "--version" ]]; then
echo "4.5.stable.official.test"
exit 0
fi
printf 'unexpected Godot invocation: %s\n' "$*" >&2
exit 99
FAKE_GODOT
chmod +x "$fake_godot"
assert_missing_templates() {
local script_name="$1"
local preset_name="$2"
local log_path="$temporary_dir/${script_name}.log"
set +e
GODOT_BIN="$fake_godot" \
GODOT_EXPORT_TEMPLATES_DIR="$temporary_dir/no-templates" \
SKIP_SMOKE=1 \
bash "$root_dir/scripts/$script_name" >"$log_path" 2>&1
local status=$?
set -e
if [[ "$status" -eq 0 ]]; then
echo "$script_name unexpectedly succeeded without export templates" >&2
cat "$log_path" >&2
exit 1
fi
grep -Fq "missing Godot export templates" "$log_path"
grep -Fq "$preset_name" "$log_path"
}
assert_missing_templates "build-linux.sh" "Linux/X11"
assert_missing_templates "build-windows.sh" "Windows Desktop"
echo "export script missing-template contracts passed"