build: remove the startup_stubs trap-log folder on exit #1488
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1495"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T12:57:21Z.
Change
tests/startup_stub_check.py(CTeststartup_stubs) creates its trap log withtempfile.mkdtemp(prefix="x2w_trap_")and never removes the folder. Every run leaves anx2w_trap_*folder with atrap.logof about 17 KB in%TEMP%. On this machine, a day of local runs had left 40 of them, and each held onlytrap.log.This registers
shutil.rmtree(log_dir, ignore_errors=True)withatexitright 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 theX2W_TRAP_LOGpath 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,devpreset (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:ctest --preset dev --no-tests=error -R '^startup_stubs$', 3 times, with this changewhoami.exeas the consumer, so the check fails (exit 1), with this changemaintests/bidi_controls_check.pyandgit diff --checkpassed.Checklist
AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:16:50Z.
Review: COMMENTED
Reviewed
8a03ab307bdb2e0cb8b3e0c44ceb57c76b7af889(tests/startup_stub_check.py).Audit
log_dir = tempfile.mkdtemp(prefix="x2w_trap_")and registersatexit.register(shutil.rmtree, log_dir, ignore_errors=True)before settingX2W_TRAP_LOG, so the folder is cleaned up on both normal exit andsys.exit(1)/ uncaught exceptions without altering the test assertions.Checks
tests/docs_links_check.py(16 Markdown files, 334 links),tests/bidi_controls_check.py(1223 tracked files), andgit diff --checkall passed.--preset dev): builtstartup_stub_consumerand stub/shim DLLs (26.55s);ctest --preset dev -R '^startup_stubs$' --no-tests=error— 1/1 passed (0.59s)./O2(--preset release): builtstartup_stub_consumerand stub/shim DLLs (42.61s);ctest --preset release -R '^startup_stubs$' --no-tests=error— 1/1 passed (0.58s).