build: remove the startup_stubs trap-log folder on exit #1488

Merged
Asimmimx merged 1 commit from upstream-pr/1495 into main 2026-11-24 13:29:01 +00:00
Asimmimx commented 2026-11-24 12:57:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T12:57:21Z.


Change

tests/startup_stub_check.py (CTest startup_stubs) creates its trap log with tempfile.mkdtemp(prefix="x2w_trap_") and never removes the folder. Every run leaves an x2w_trap_* folder with a trap.log of about 17 KB in %TEMP%. On this machine, a day of local runs had left 40 of them, and each held only trap.log.

This registers shutil.rmtree(log_dir, ignore_errors=True) with atexit right after the folder is created. It therefore also runs on the failure path (sys.exit(1)) and on an uncaught exception. The check's assertions and the X2W_TRAP_LOG path it passes to the stub consumer are unchanged.

The edit is at the top of the file, apart from the new store-context case that #1470 adds further down, so the two merge in either order.

Verification

Commit 3c6273ac (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Python 3.12.10.

I counted the x2w_trap_* folders in %TEMP% before and after each run:

Run Result Folders before → after
ctest --preset dev --no-tests=error -R '^startup_stubs$', 3 times, with this change Passed 3/3 39 → 39
the CTest command line with whoami.exe as the consumer, so the check fails (exit 1), with this change FAIL, as intended 39 → 39
the same failing command with the script from main FAIL 39 → 40

tests/bidi_controls_check.py and git diff --check passed.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture. (The failing-run row is the failure case.)
  • I updated README/docs when a capability or build requirement changed. (No capability changed.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6582294755 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1495). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T12:57:21Z. --- ## Change `tests/startup_stub_check.py` (CTest `startup_stubs`) creates its trap log with `tempfile.mkdtemp(prefix="x2w_trap_")` and never removes the folder. Every run leaves an `x2w_trap_*` folder with a `trap.log` of about 17 KB in `%TEMP%`. On this machine, a day of local runs had left 40 of them, and each held only `trap.log`. This registers `shutil.rmtree(log_dir, ignore_errors=True)` with `atexit` right after the folder is created. It therefore also runs on the failure path (`sys.exit(1)`) and on an uncaught exception. The check's assertions and the `X2W_TRAP_LOG` path it passes to the stub consumer are unchanged. The edit is at the top of the file, apart from the new store-context case that #1470 adds further down, so the two merge in either order. ## Verification Commit `3c6273ac` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Python 3.12.10. I counted the `x2w_trap_*` folders in `%TEMP%` before and after each run: | Run | Result | Folders before → after | |---|---|---| | `ctest --preset dev --no-tests=error -R '^startup_stubs$'`, 3 times, with this change | Passed 3/3 | 39 → 39 | | the CTest command line with `whoami.exe` as the consumer, so the check fails (exit 1), with this change | FAIL, as intended | 39 → 39 | | the same failing command with the script from `main` | FAIL | 39 → 40 | `tests/bidi_controls_check.py` and `git diff --check` passed. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. (The failing-run row is the failure case.) - [x] I updated README/docs when a capability or build requirement changed. (No capability changed.) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 14:02:56 +00:00
tedin7 commented 2026-11-24 14:02:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:16:50Z.

Review: COMMENTED


Reviewed 8a03ab307bdb2e0cb8b3e0c44ceb57c76b7af889 (tests/startup_stub_check.py).

Audit

  • Temp directory cleanup: Creates log_dir = tempfile.mkdtemp(prefix="x2w_trap_") and registers atexit.register(shutil.rmtree, log_dir, ignore_errors=True) before setting X2W_TRAP_LOG, so the folder is cleaned up on both normal exit and sys.exit(1) / uncaught exceptions without altering the test assertions.
  • Hygiene: Title-neutral, focused single-file change, no unrelated edits.

Checks

  • Linux: tests/docs_links_check.py (16 Markdown files, 334 links), tests/bidi_controls_check.py (1223 tracked files), and git diff --check all passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): built startup_stub_consumer and stub/shim DLLs (26.55s); ctest --preset dev -R '^startup_stubs$' --no-tests=error — 1/1 passed (0.59s).
    • Release /O2 (--preset release): built startup_stub_consumer and stub/shim DLLs (42.61s); ctest --preset release -R '^startup_stubs$' --no-tests=error — 1/1 passed (0.58s).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6039859227 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1495#pullrequestreview-6039859227). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T13:16:50Z. **Review:** COMMENTED --- Reviewed `8a03ab307bdb2e0cb8b3e0c44ceb57c76b7af889` (`tests/startup_stub_check.py`). ### Audit - **Temp directory cleanup**: Creates `log_dir = tempfile.mkdtemp(prefix="x2w_trap_")` and registers `atexit.register(shutil.rmtree, log_dir, ignore_errors=True)` before setting `X2W_TRAP_LOG`, so the folder is cleaned up on both normal exit and `sys.exit(1)` / uncaught exceptions without altering the test assertions. - **Hygiene**: Title-neutral, focused single-file change, no unrelated edits. ### Checks - **Linux**: `tests/docs_links_check.py` (16 Markdown files, 334 links), `tests/bidi_controls_check.py` (1223 tracked files), and `git diff --check` all passed. - **Windows Server 2025** (Build 26100, MSVC 14.44.35207 + D3D12 WARP): - **Debug (`--preset dev`)**: built `startup_stub_consumer` and stub/shim DLLs (`26.55s`); `ctest --preset dev -R '^startup_stubs$' --no-tests=error` — **1/1 passed** (`0.59s`). - **Release `/O2` (`--preset release`)**: built `startup_stub_consumer` and stub/shim DLLs (`42.61s`); `ctest --preset release -R '^startup_stubs$' --no-tests=error` — **1/1 passed** (`0.58s`).
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
R0Y00/Xbox2Windows!1488
No description provided.