refactor: add execution retries on windows

This commit is contained in:
zhom
2025-08-10 00:47:52 +04:00
parent 6cc27ec5b2
commit 999eb165ec
2 changed files with 69 additions and 17 deletions
+27 -3
View File
@@ -675,7 +675,31 @@ impl BundlerTestHelper {
}
// Build command to run the executable.
let mut cmd = Command::new(executable_path);
// On Windows CI, concurrent CreateProcess on the same path may fail sporadically.
// Copy the binary to a unique temp dir to shorten the path and avoid races.
#[cfg(windows)]
let (exec_path_owned, _temp_guard) = {
let tmp = TempDir::new().context("Failed to create temp dir for executable copy")?;
let file_name = executable_path
.file_name()
.ok_or_else(|| anyhow::anyhow!(
"Executable path missing file name: {}",
executable_path.display()
))?;
let dest = tmp.path().join(file_name);
std::fs::copy(executable_path, &dest).with_context(|| {
format!(
"Failed to copy executable to temporary directory: {} -> {}",
executable_path.display(),
dest.display()
)
})?;
(dest, tmp)
};
#[cfg(not(windows))]
let exec_path_owned = executable_path.to_path_buf();
let mut cmd = Command::new(&exec_path_owned);
cmd.args(args);
@@ -685,14 +709,14 @@ impl BundlerTestHelper {
println!(
"Executing: {} with args: {:?}",
executable_path.display(),
exec_path_owned.display(),
args
);
let output = cmd.output().with_context(|| {
format!(
"Failed to execute command: {}\nArgs: {:?}\nEnv vars: {:?}\nWorking directory: {:?}",
executable_path.display(),
exec_path_owned.display(),
args,
env_vars,
std::env::current_dir().unwrap_or_else(|_| "<unknown>".into())