Add a test-window wrapper that keeps test runs in the background

tools/test_window.sh runs the game under the window class "TableTower
Test" (via a temporary override.cfg) so a KWin window rule can keep
automated screenshot runs unfocused and behind other windows, without
affecting normal playtests from the editor. Also ignore override.cfg
and agent worktrees.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RobinFiredrake 2026-11-08 12:11:55 -06:00
parent 60c2d03147
commit 8ea83947ff
3 changed files with 32 additions and 2 deletions

6
.gitignore vendored
View file

@ -11,3 +11,9 @@
.DS_Store
Thumbs.db
.vscode/
# Temporary file written by tools/test_window.sh
override.cfg
# Agent worktrees
.claude/worktrees/

View file

@ -51,8 +51,10 @@ godot --headless --path . -s res://tests/test_roller.gd
## Screenshots from the command line
```sh
godot --path . -- --screenshot=/tmp/board.png [--build] [--expand-all] [--collapse-all] \
tools/test_window.sh -- --screenshot=/tmp/board.png [--build] [--expand-all] [--collapse-all] \
[--roll=wilderness] [--shot-delay=0.75]
```
This uses the sample board and doesn't save anything.
This uses the sample board and doesn't save anything. `tools/test_window.sh` runs the game
under the window class "TableTower Test" (via a temporary `override.cfg`), which a KWin
window rule keeps in the background without focus.

22
tools/test_window.sh Executable file
View file

@ -0,0 +1,22 @@
#!/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" -- "$@"