From 751de4d16c774016997db420e6ae0128cc9a1aff Mon Sep 17 00:00:00 2001 From: Anonymous78e <123822114+Anonymous78e@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:16:01 +0100 Subject: [PATCH] tests: a locked recorder.exe no longer hides the cmake batch case's result (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 Claude-Session: https://claude.ai/code/session_014sDZDAAcsauTL6d8ie67Qo --- tests/test_build_runtime_cmake.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_build_runtime_cmake.py b/tests/test_build_runtime_cmake.py index c7685a5210..64a2f38f33 100644 --- a/tests/test_build_runtime_cmake.py +++ b/tests/test_build_runtime_cmake.py @@ -35,7 +35,9 @@ class Recorder { class CMakeBatchTest(unittest.TestCase): @classmethod def setUpClass(cls): - cls.temp = tempfile.TemporaryDirectory(prefix="leonida_cmake_") + # A recorder.exe a child has just run can stay locked for a moment on Windows (antivirus, a late handle + # close); a failed cleanup must not replace the result of the case that used it. + cls.temp = tempfile.TemporaryDirectory(prefix="leonida_cmake_", ignore_cleanup_errors=True) cls.addClassCleanup(cls.temp.cleanup) cls.base = Path(cls.temp.name) source = cls.base / "recorder.cs" @@ -93,7 +95,7 @@ def test_native_and_batch_cmake_paths_and_exit_codes(self): for extension in (".exe", ".cmd", ".bat"): for fail in ("", "configure", "build"): with self.subTest(folder=name, extension=extension, fail=fail): - with tempfile.TemporaryDirectory(dir=self.base) as tmp: + with tempfile.TemporaryDirectory(dir=self.base, ignore_cleanup_errors=True) as tmp: folder = Path(tmp) / name folder.mkdir() result, src, out, ninja = self.run_build(folder, extension, fail)