run_game_wine.sh: a run is torn down once (WINE-TEARDOWN-ONCE) #3246

Manually merged
github merged 1 commit from github-bot/gh-3246 into gh-pr/3246/base 2026-12-03 15:52:54 +00:00 AGit
Owner

@⁠LouisRiverstone on GitHub · 2026-12-02 22:16 UTC · original
LouisRiverstone:fix/wine-teardown-once → main · +12 −1 · 2 files · 1 commits · merged 2026-12-03 15:45 UTC

Claim: #2570 (WINE-TEARDOWN-ONCE), following Neutron-0's finding on scripts/run_game_wine.sh:327 with :292.

Why

The outer half sets trap teardown EXIT (:292) and also calls teardown itself before the summary (:327), so teardown ran twice. The second run kills a wineserver that is already gone and removes $XDG_RUNTIME_DIR, which is also already gone. That is two more spawns at the end of every run, and on a Windows host they are the costliest ones (Neutron-0 measured 2-3 s).

What changed

  • scripts/run_game_wine.sh: teardown; SESSION_PID=; trap - EXIT. The trap is dropped on the same line, after the explicit teardown. A signal before that point still tears the run down through the trap, as before. Nothing after it starts a process or makes a folder.
  • tests/test_run_game_wine.py: test_a_run_is_torn_down_once gives wineserver a stub that logs its arguments and checks there are exactly two -k calls. One is the inner run's, after the title returns (:110), and one is the teardown's.

Verification (WSL Ubuntu, Python 3.14; this class skips on Windows; no game files, Wine or GPU needed)

  • Red/green: with the script change reverted, the new test sees 3 -k calls; with it, 2.
  • tests/test_run_game_wine.py 17 OK; tests/test_run_game_wine_safety.py 3 OK; bash -n passes.
  • python -I scripts/check_no_game_data.py on both files: exit 0. Both stay LF, and the script keeps mode 100755.

This touches tests/test_run_game_wine.py in a different place from #3241, so the two merge in either order.

AI assistance

AI-assisted: written with Claude Code (Claude Opus 5.5). It was reviewed by a separate read-only reviewer agent (Claude Opus 5.5), which checked every path after the trap is dropped (signals, exit 3, the summary), that no set -e can skip the explicit teardown, and that the test is free of races. It found nothing blocking; I applied its wording suggestion for the comment.

🤖 Generated with Claude Code

**@⁠LouisRiverstone** on GitHub · 2026-12-02 22:16 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3246) `LouisRiverstone:fix/wine-teardown-once` → `main` · +12 −1 · 2 files · 1 commits · merged 2026-12-03 15:45 UTC Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/2570 (WINE-TEARDOWN-ONCE), following Neutron-0's finding on `scripts/run_game_wine.sh:327` with `:292`. ## Why The outer half sets `trap teardown EXIT` (`:292`) and also calls `teardown` itself before the summary (`:327`), so `teardown` ran twice. The second run kills a wineserver that is already gone and removes `$XDG_RUNTIME_DIR`, which is also already gone. That is two more spawns at the end of every run, and on a Windows host they are the costliest ones (Neutron-0 measured 2-3 s). ## What changed - `scripts/run_game_wine.sh`: `teardown; SESSION_PID=; trap - EXIT`. The trap is dropped on the same line, after the explicit teardown. A signal before that point still tears the run down through the trap, as before. Nothing after it starts a process or makes a folder. - `tests/test_run_game_wine.py`: `test_a_run_is_torn_down_once` gives `wineserver` a stub that logs its arguments and checks there are exactly two `-k` calls. One is the inner run's, after the title returns (`:110`), and one is the teardown's. ## Verification (WSL Ubuntu, Python 3.14; this class skips on Windows; no game files, Wine or GPU needed) - Red/green: with the script change reverted, the new test sees 3 `-k` calls; with it, 2. - `tests/test_run_game_wine.py` 17 OK; `tests/test_run_game_wine_safety.py` 3 OK; `bash -n` passes. - `python -I scripts/check_no_game_data.py` on both files: exit 0. Both stay LF, and the script keeps mode 100755. This touches `tests/test_run_game_wine.py` in a different place from #3241, so the two merge in either order. ## AI assistance AI-assisted: written with Claude Code (Claude Opus 5.5). It was reviewed by a separate read-only reviewer agent (Claude Opus 5.5), which checked every path after the trap is dropped (signals, `exit 3`, the summary), that no `set -e` can skip the explicit teardown, and that the test is free of races. It found nothing blocking; I applied its wording suggestion for the comment. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The outer half tore the run down before the summary and then again from
its EXIT trap. That killed a wineserver that was already gone and removed
a folder that was already gone: two more spawns at the end of every run,
the costliest ones on a Windows host. The trap is dropped once the
explicit teardown has run. A stubbed full run now counts its wineserver -k
calls: the inner run's and the teardown's, once each (3 before, 2 now).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 22:21:55 +00:00
Author
Owner

@⁠merzleckeier on GitHub · 2026-12-02 22:21 UTC · original · reviewed

Reviewed d19028d1 on f3865cae8 using a Linux sandbox with the existing stubs. The new test sees three wineserver -k calls against the original script and two with this change. All 17 tests passed on this head, and all 18 passed with #3241 at 8bc989c12 applied on top.

I also stubbed a session that exits before the inner launcher starts. The outer launcher returned its normal early-exit status 3, called wineserver -k once and removed its temporary XDG directory. No real Wine or game files were used.

**@⁠merzleckeier** on GitHub · 2026-12-02 22:21 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3246#pullrequestreview-6160066148) · **reviewed** Reviewed `d19028d1` on `f3865cae8` using a Linux sandbox with the existing stubs. The new test sees three `wineserver -k` calls against the original script and two with this change. All 17 tests passed on this head, and all 18 passed with #3241 at `8bc989c12` applied on top. I also stubbed a session that exits before the inner launcher starts. The outer launcher returned its normal early-exit status 3, called `wineserver -k` once and removed its temporary XDG directory. No real Wine or game files were used.
github-bot force-pushed github-bot/gh-3246 from d19028d127 to c84899f090 2026-12-02 22:28:32 +00:00 Compare
Author
Owner

@⁠LouisRiverstone on GitHub · 2026-12-02 22:24 UTC · original

Rewrote the branch's commits without a co-author trailer, so the head SHA changed (now c84899f09). The tree is identical to the reviewed one.

**@⁠LouisRiverstone** on GitHub · 2026-12-02 22:24 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3246#issuecomment-7360640737) Rewrote the branch's commits without a co-author trailer, so the head SHA changed (now `c84899f09`). The tree is identical to the reviewed one.
Author
Owner

@⁠fiestorra on GitHub · 2026-12-02 22:48 UTC · original

VERIFY-3246 — no verificable en esta máquina: sus diecisiete pruebas se saltan en Windows

Own commit c84899f09 — scripts/run_game_wine.sh (+1/−1), tests/test_run_game_wine.py (+10)
Ran python -I tests/test_run_game_wine.py
Ran 17 tests in 0.000s — OK (skipped=17)

The suite is POSIX only and skips whole on Windows, so the fix is not verified here — and a Windows CI reading "17 passed" would be reading nothing.

What the change is, and it is small and pointed:

-teardown; SESSION_PID=
+# Torn down before the summary; the EXIT trap is dropped so it does not run again.
+teardown; SESSION_PID=; trap - EXIT

The run is torn down once: after the summary the EXIT trap is dropped, so a clean exit does not tear the session down a second time. The failure mode it removes is the one that looks like a stray process after a successful run — and the new test in the same file is what pins it, on a host that can run it.

What would verify either of them: a POSIX host with bash; the test needs no game, no Wine and no KWin (that is the point of its stubs). I do not have one in this session.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-12-02 22:48 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3246#issuecomment-7361181470) ## VERIFY-3246 — **no verificable en esta máquina**: sus diecisiete pruebas se saltan en Windows | | | |---|---| | Own commit | `c84899f09` — `scripts/run_game_wine.sh` (+1/−1), `tests/test_run_game_wine.py` (+10) | | Ran | `python -I tests/test_run_game_wine.py` | ``` Ran 17 tests in 0.000s — OK (skipped=17) ``` **The suite is POSIX only** and skips whole on Windows, so **the fix is not verified here** — and a Windows CI reading "17 passed" would be reading nothing. **What the change is, and it is small and pointed**: ```diff -teardown; SESSION_PID= +# Torn down before the summary; the EXIT trap is dropped so it does not run again. +teardown; SESSION_PID=; trap - EXIT ``` **The run is torn down once**: after the summary the `EXIT` trap is dropped, so a clean exit does not tear the session down a second time. **The failure mode it removes is the one that looks like a stray process after a successful run** — and the new test in the same file is what pins it, on a host that can run it. **What would verify either of them**: a POSIX host with `bash`; the test needs no game, no Wine and no KWin (that is the point of its stubs). I do not have one in this session. Written with an AI assistant.
Author
Owner

@⁠LouisRiverstone on GitHub · 2026-12-03 02:11 UTC · original

@⁠fiestorra right: this suite is POSIX-only and skips on Windows. I ran it on WSL Ubuntu (Python 3.14): 17 OK with the change, and the new check fails without it. merzleckeier also re-ran it in a Linux sandbox. The CI linux-python-and-viewer job runs it too, and it is green here.

**@⁠LouisRiverstone** on GitHub · 2026-12-03 02:11 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3246#issuecomment-7365181015) @⁠fiestorra right: this suite is POSIX-only and skips on Windows. I ran it on WSL Ubuntu (Python 3.14): 17 OK with the change, and the new check fails without it. merzleckeier also re-ran it in a Linux sandbox. The CI `linux-python-and-viewer` job runs it too, and it is green here.
github-bot changed target branch from main to gh-pr/3246/base 2026-12-03 15:52:28 +00:00
github manually merged commit c84899f090 into gh-pr/3246/base 2026-12-03 15:52:54 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/ubiquitarianism--leonida!3246
No description provided.