TableTower/tools/test_window.sh

23 lines
984 B
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# Runs TableTower in a window for automated checks (screenshots, smoke tests).
#
# While it runs, a temporary override.cfg renames the project to "TableTower Test",
# so its window class is "TableTower Test". A KWin window rule keeps windows of
# that class in the background without focus. The file is removed on exit, so
# normal runs from the editor are unaffected.
#
# Usage: tools/test_window.sh [project dir] -- [user args, e.g. --screenshot=/tmp/x.png]
set -euo pipefail
GODOT="${GODOT:-$HOME/apps/Godot_v4.7.2-stable_linux.x86_64}"
PROJECT="$(pwd)"
if [[ $# -gt 0 && "$1" != "--" ]]; then PROJECT="$(cd "$1" && pwd)"; shift; fi
[[ "${1:-}" == "--" ]] && shift
OVERRIDE="$PROJECT/override.cfg"
if [[ -e "$OVERRIDE" ]]; then
echo "override.cfg already exists in $PROJECT; is another test window running?" >&2
exit 1
fi
printf '[application]\n\nconfig/name="TableTower Test"\n' > "$OVERRIDE"
trap 'rm -f "$OVERRIDE"' EXIT
"$GODOT" --path "$PROJECT" -- "$@"