From d82746c31d2466cc200dd76b434ccf2524871126 Mon Sep 17 00:00:00 2001 From: Martin Kuntz Jacobsen Date: Mon, 16 Nov 2026 11:21:22 +0100 Subject: [PATCH 1/2] quality: windows preflight scratch cleanup and ansible case platforms (part of #12277) Scratch::close clears read-only entries and retries while entries are held, so latexindent on windows_arm64 no longer fails with "scratch cleanup: Access is denied". real_result_ansible_lint_dirty no longer runs on windows_x86_64, where ansible_lint is declared unsupported. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xut2hzwNN9Q3DFZx18pNic --- core/quality/adapter/src/exec.rs | 47 ++++++++++++++++++++- core/quality/testdata/real_result_cases.bzl | 6 +-- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/core/quality/adapter/src/exec.rs b/core/quality/adapter/src/exec.rs index b48099cf13..2bbe7dd905 100644 --- a/core/quality/adapter/src/exec.rs +++ b/core/quality/adapter/src/exec.rs @@ -185,10 +185,41 @@ impl Scratch { /// /// Returns an I/O error when the filesystem or process operation fails. pub fn close(self) -> io::Result<()> { - self.dir.close() + remove_scratch(&self.dir.keep()) } } +const SCRATCH_REMOVE_BACKOFF_MS: [u64; 6] = [10, 50, 100, 250, 500, 1000]; + +#[cfg(windows)] +const ERROR_SHARING_VIOLATION: i32 = 32; + +fn held(err: &io::Error) -> bool { + #[cfg(windows)] + if err.raw_os_error() == Some(ERROR_SHARING_VIOLATION) { + return true; + } + err.kind() == io::ErrorKind::PermissionDenied +} + +/// Removes a closed scratch tree, clearing read-only entries and retrying while entries are held. +fn remove_scratch(path: &Path) -> io::Result<()> { + let mut outcome = std::fs::remove_dir_all(path); + for delay in SCRATCH_REMOVE_BACKOFF_MS { + match &outcome { + Err(err) if held(err) => {} + _ => return outcome, + } + dx_process::make_writable(path); + outcome = std::fs::remove_dir_all(path); + if outcome.is_ok() { + return outcome; + } + std::thread::sleep(Duration::from_millis(delay)); + } + outcome +} + fn ensure_no_symlink_prefix(root: &Path, path: &Path, rel: &Path) -> io::Result<()> { let suffix = path.strip_prefix(root).map_err(|_| { io::Error::new( @@ -741,6 +772,20 @@ mod tests { assert!(scratch.close().is_err(), "missing tree is an error"); } + #[cfg(unix)] + #[test] + fn close_removes_a_read_only_tree() { + use std::os::unix::fs::PermissionsExt as _; + let scratch = Scratch::create(&std::env::temp_dir()).expect("scratch"); + let root = scratch.root().to_owned(); + let locked = root.join("locked"); + std::fs::create_dir(&locked).expect("locked dir"); + std::fs::write(locked.join("file"), b"x").expect("file"); + std::fs::set_permissions(&locked, std::fs::Permissions::from_mode(0o500)).expect("chmod"); + scratch.close().expect("close clears read-only entries"); + assert!(!root.exists(), "closed scratch is gone"); + } + fn pair(key: &str, value: &str) -> (OsString, OsString) { (OsString::from(key), OsString::from(value)) } diff --git a/core/quality/testdata/real_result_cases.bzl b/core/quality/testdata/real_result_cases.bzl index 39edc1faaa..2974fa2330 100644 --- a/core/quality/testdata/real_result_cases.bzl +++ b/core/quality/testdata/real_result_cases.bzl @@ -39,7 +39,7 @@ def _cc_case(tool, capability, name, target, contains, absent, config = "cc_synt "windows_arm64": True, } -def _iac_dirty_case(tool, cls, package, target, contains, config = "default"): +def _iac_dirty_case(tool, cls, package, target, contains, config = "default", windows_x86_64 = True): return { "name": "real_result_%s_dirty" % tool, "target": "//%s:%s" % (package, target), @@ -51,7 +51,7 @@ def _iac_dirty_case(tool, cls, package, target, contains, config = "default"): "absent": [], "linux_arm64": True, "macos_arm64": True, - "windows_x86_64": True, + "windows_x86_64": windows_x86_64, } def _ruff_tier_case(tier, name, contains, absent): @@ -232,7 +232,7 @@ REAL_RESULT_CASES = [ "contains": ["core/quality/testdata/ocaml_owned/shadow.ml", "shadows"], "absent": [], }, - _iac_dirty_case("ansible_lint", "ansible", "ansible/tests", "dirty", ["command-instead-of-shell"], "shared_standard"), + _iac_dirty_case("ansible_lint", "ansible", "ansible/tests", "dirty", ["command-instead-of-shell"], "shared_standard", windows_x86_64 = False), _iac_dirty_case("bicep", "bicep", "bicep/tests", "dirty", ["no-unused-params", "BCP033"], "shared_standard"), _iac_dirty_case("cfn_lint", "cloudformation", "cloudformation/tests", "dirty", ["E3002"]), _iac_dirty_case("cmakelint", "cmake", "cmake/tests", "dirty", ["readability/mixedcase"], "shared_standard"), From 39afecc9df406956bf3f4f288fa8afffe1a21c08 Mon Sep 17 00:00:00 2001 From: Martin Kuntz Jacobsen Date: Mon, 16 Nov 2026 12:27:24 +0100 Subject: [PATCH 2/2] preflight windows: short interpreter and worktree for clang-cl sdist builds, julia cli_test medium (part of #12277) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xut2hzwNN9Q3DFZx18pNic --- julia/tests/fixtures/julia-app/cli/BUILD.bazel | 1 + patches/rules_py/pep517_msvc.patch | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/julia/tests/fixtures/julia-app/cli/BUILD.bazel b/julia/tests/fixtures/julia-app/cli/BUILD.bazel index 9d9628d49d..a5bb3a4bc5 100644 --- a/julia/tests/fixtures/julia-app/cli/BUILD.bazel +++ b/julia/tests/fixtures/julia-app/cli/BUILD.bazel @@ -56,6 +56,7 @@ julia_test( julia_test( name = "cli_test", + size = "medium", srcs = ["cli_test.jl"], data = [":readings"], env = select({ diff --git a/patches/rules_py/pep517_msvc.patch b/patches/rules_py/pep517_msvc.patch index 98da8d6002..971e819a2b 100644 --- a/patches/rules_py/pep517_msvc.patch +++ b/patches/rules_py/pep517_msvc.patch @@ -225,6 +225,11 @@ diff -ru a/uv/private/pep517_whl/tools/build_helper.py b/uv/private/pep517_whl/t # helper still runs there; bare tool names deliberately remain on PATH. _absolutize_tool_paths(env) ++ if os.name == "nt" and len(sys.executable) >= 250: ++ # CreateProcess rejects a venv interpreter under the deep runfiles ++ # tree; run the short base interpreter against the venv packages. ++ env["PYTHONPATH"] = pathsep.join(entry for entry in sys.path if entry) ++ sys.executable = sys._base_executable + if msvc: + # setuptools finds cl.exe through PATH, INCLUDE and LIB from the + # toolchain, and only when it is told no Visual Studio is needed. @@ -233,11 +238,6 @@ diff -ru a/uv/private/pep517_whl/tools/build_helper.py b/uv/private/pep517_whl/t + env["DISTUTILS_USE_SDK"] = "1" + env["MSSdk"] = "1" + _add_cargo_and_ant(env, tmpdir) -+ if len(sys.executable) >= 250: -+ # CreateProcess rejects a venv interpreter under the deep runfiles -+ # tree; run the short base interpreter against the venv packages. -+ env["PYTHONPATH"] = pathsep.join(entry for entry in sys.path if entry) -+ sys.executable = sys._base_executable + return env + cc_path = _resolve_compiler_path(env, "CC", "cc") @@ -305,7 +305,7 @@ diff -ru a/uv/private/pep517_whl/tools/build_helper.py b/uv/private/pep517_whl/t t = path.join(tmp_root, "worktree") + msvc_root = None -+ if opts.msvc: ++ if opts.msvc or os.name == "nt": + msvc_root = _msvc_worktree_root(opts.output) + shutil.rmtree(msvc_root, ignore_errors=True) + t = path.join(msvc_root, "w")