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

Merged
leonida/mandy
LouisRiverstone merged 1 commit from fix/wine-teardown-once into main 2026-12-03 15:45:18 +00:00

Pull request successfully merged and closed

LouisRiverstone commented 2026-12-02 22:16:46 +00:00

Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7360399128 (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

Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7360399128 (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)
merzleckeier reviewed 2026-12-02 22:21:20 +00:00
merzleckeier left a comment
No description provided.
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.
LouisRiverstone commented 2026-12-02 22:24:05 +00:00

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.

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.
fiestorra commented 2026-12-02 22:48:15 +00:00

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.

## 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.
LouisRiverstone commented 2026-12-03 02:11:15 +00:00

@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.

@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.
Sign in to join this conversation.
No description provided.