From 8ea83947ffa6bc659091cf0d3cd99386e52fc45c Mon Sep 17 00:00:00 2001 From: RobinFiredrake Date: Sun, 8 Nov 2026 12:11:55 -0600 Subject: [PATCH] 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 --- .gitignore | 6 ++++++ README.md | 6 ++++-- tools/test_window.sh | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100755 tools/test_window.sh diff --git a/.gitignore b/.gitignore index 38da218..d2b08cd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,9 @@ .DS_Store Thumbs.db .vscode/ + +# Temporary file written by tools/test_window.sh +override.cfg + +# Agent worktrees +.claude/worktrees/ diff --git a/README.md b/README.md index 8181f6b..3f2e4d7 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/tools/test_window.sh b/tools/test_window.sh new file mode 100755 index 0000000..326eb73 --- /dev/null +++ b/tools/test_window.sh @@ -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" -- "$@"