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

Manually merged
github merged 1 commit from gh-pr/1495/head into gh-pr/1495/base 2026-11-26 23:11:41 +00:00
Owner

@⁠Asimmimx on GitHub · 2026-11-24 12:57 UTC · original
Asimmimx:tests/startup-stubs-temp-cleanup → main · +6 −1 · 1 files · 1 commits · merged 2026-11-24 13:29 UTC

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

**@⁠Asimmimx** on GitHub · 2026-11-24 12:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1495) `Asimmimx:tests/startup-stubs-temp-cleanup` → `main` · +6 −1 · 1 files · 1 commits · merged 2026-11-24 13:29 UTC ## 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).
startup_stub_check.py created its trap log in tempfile.mkdtemp() and
never removed the folder, so every startup_stubs run left an
x2w_trap_* folder with a trap.log of about 17 KB in %TEMP%. Register
shutil.rmtree for that folder with atexit, which also runs when the
check fails through sys.exit(1).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:11:40 +00:00
github manually merged commit 8a03ab307b into gh-pr/1495/base 2026-11-26 23:11:41 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 13:16 UTC · original · reviewed

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).
**@⁠tedin7** on GitHub · 2026-11-24 13:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1495#pullrequestreview-6039859227) · **reviewed** 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`).
This discussion has been locked. Commenting is limited to contributors.
No description provided.