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

Merged
LouisRiverstone merged 1 commit from upstream-pr/3246 into main 2026-12-03 15:45:18 +00:00
LouisRiverstone commented 2026-12-02 22:16:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by LouisRiverstone on 2026-12-02T22:16:45Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5615683463 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3246). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-12-02T22:16:45Z. --- 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 commented 2026-12-02 22:21:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T22:21:20Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6160066148 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3246#pullrequestreview-6160066148). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-02T22:21:20Z. **Review:** COMMENTED --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by LouisRiverstone on 2026-12-02T22:24:05Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360640737 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3246#issuecomment-7360640737). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-12-02T22:24:05Z. --- 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T22:48:15Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361181470 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3246#issuecomment-7361181470). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T22:48:15Z. --- ## 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 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by LouisRiverstone on 2026-12-03T02:11:15Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7365181015 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3246#issuecomment-7365181015). Originally posted by [LouisRiverstone](https://github.com/LouisRiverstone) on 2026-12-03T02:11:15Z. --- @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 reviewers
No labels
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.

Reference
ProjectLeonida/mandy!3246
No description provided.