Skip to content

tests: a locked recorder.exe no longer hides the cmake batch case's result (TEST-CMAKE-BATCH-CLEANUP) - #1439

Open
Anonymous78e wants to merge 1 commit into
ProjectLeonida:mainfrom
Anonymous78e:test/cmake-batch-cleanup
Open

Anonymous78e wants to merge 1 commit into
ProjectLeonida:mainfrom
Anonymous78e:test/cmake-batch-cleanup

Conversation

@Anonymous78e

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-CMAKE-BATCH-CLEANUP (#14 (comment))

What and why

Part (3) of @GTAVIB4GTAVI's parallel-load finding (#14). Parts (1) and (2) are #1410 and #1002.

tests/test_build_runtime_cmake.py builds each case in tempfile.TemporaryDirectory(dir=self.base) and copies a recorder.exe into it, which a child process runs. When Windows still holds that image at cleanup (antivirus, a late handle close), shutil.rmtree raises PermissionError: [WinError 5] and that error replaces the case's own result, as reported:

PermissionError: [WinError 5] Access is denied: ...\caret^dir\tools ^ & 東京\recorder.exe

Both temp folders, the per-case one and the class one that holds the compiled recorder, now pass ignore_cleanup_errors=True (Python 3.10+; the project needs 3.12+), so the assertion stays in charge. Nothing else changes.

Tested

Windows 11 Pro 26H2, CPython 3.13.15, on main 1154976:

  • The mechanism, deterministically: a file held open inside a TemporaryDirectory whose body fails an assertion.

    exception that surfaces
    no flag (as on main) PermissionError: [WinError 32] ...
    ignore_cleanup_errors=True AssertionError: the case's own assertion
  • python -I tests/test_build_runtime_cmake.py: 1 test (27 subtests) OK in 11 s with this change.

  • scripts/check_no_game_data.py on the file: clean.

GPUs tested: n/a

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

https://claude.ai/code/session_014sDZDAAcsauTL6d8ie67Qo

…esult (TEST-CMAKE-BATCH-CLEANUP)

test_build_runtime_cmake builds each case in a TemporaryDirectory and runs a
recorder.exe from it. When Windows still holds that image at cleanup,
rmtree's PermissionError replaced the case's own result. Both temp folders
now pass ignore_cleanup_errors=True, so the assertion stays in charge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014sDZDAAcsauTL6d8ie67Qo
@PierreEbele

Copy link
Copy Markdown
Contributor

Reviewed 751de4d: both TemporaryDirectory calls in test_build_runtime_cmake.py now pass ignore_cleanup_errors=True, so a still-locked recorder.exe at cleanup can no longer replace (or masquerade as) a case's result: both the class-level folder and each subTest's copied recorder. Could not run the suite here (Windows-only: csc.exe and powershell.exe; on this Linux box it exits OK (skipped=1) and compiles clean); fault injection also cannot reproduce the lock here, so this is a code-reading review: I verified the mechanism by reading tempfile's routing: cleanup() forwards the flag and every raise site in rmtree's onexc, including the locked-file PermissionError branch, is behind if not ignore_errors; README pins Python 3.12+ and the ci check job runs this file on windows-latest. Leaked leonida_cmake* folders when cleanup does fail are the accepted trade-off. No findings.

AI-assisted review.

Recommendation: Merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants