From 9680254825523ba122e2490946d7b0af8d8187dc Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Sun, 10 Aug 2025 04:40:41 +0400 Subject: [PATCH] test: increase delay on windows --- tests/common/mod.rs | 14 ++++++++------ tests/concurrent_execution_integration_test.rs | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 358ac26..3895456 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -700,8 +700,11 @@ impl BundlerTestHelper { // Build command to run the executable. #[cfg(windows)] let (exec_to_run, work_dir, _run_guard) = { - // Create a unique temp directory per invocation to avoid filename races - let run_dir = TempDir::new().context("Failed to create temp dir for run copy")?; + // Copy to a unique name in the same directory as the original to avoid policy issues with %TEMP% + let parent = executable_path.parent().ok_or_else(|| { + anyhow::anyhow!("Executable has no parent: {}", executable_path.display()) + })?; + let run_dir = TempDir::new_in(parent).unwrap_or_else(|_| TempDir::new().unwrap()); let mut base = executable_path .file_name() .map(|s| s.to_os_string()) @@ -712,20 +715,19 @@ impl BundlerTestHelper { let candidate = run_dir.path().join(&base); std::fs::copy(executable_path, &candidate).with_context(|| { format!( - "Failed to copy executable to temp dir: {} -> {}", + "Failed to copy executable to run dir: {} -> {}", executable_path.display(), candidate.display() ) })?; - // Small delay to allow AV/file indexing to settle std::thread::sleep(std::time::Duration::from_millis(50)); if !candidate.exists() { anyhow::bail!( - "Temp executable not found after copy: {}", + "Run executable not found after copy: {}", candidate.display() ); } - (candidate, run_dir.path().to_path_buf(), run_dir) + (candidate, parent.to_path_buf(), run_dir) }; #[cfg(not(windows))] diff --git a/tests/concurrent_execution_integration_test.rs b/tests/concurrent_execution_integration_test.rs index f98d90c..5670c00 100644 --- a/tests/concurrent_execution_integration_test.rs +++ b/tests/concurrent_execution_integration_test.rs @@ -59,7 +59,7 @@ async fn test_concurrent_first_launch() -> Result<()> { // Give the filesystem a moment to settle on Windows if cfg!(windows) { - std::thread::sleep(std::time::Duration::from_millis(100)); + std::thread::sleep(std::time::Duration::from_millis(250)); } // Clear any existing cache to ensure we test first launch @@ -85,7 +85,7 @@ async fn test_concurrent_first_launch() -> Result<()> { barrier.wait(); // Add a small staggered delay to reduce race conditions on Windows - std::thread::sleep(std::time::Duration::from_millis(i as u64 * 10)); + std::thread::sleep(std::time::Duration::from_millis(50 + i as u64 * 20)); let thread_start = Instant::now(); @@ -304,7 +304,7 @@ async fn test_cached_concurrent_execution() -> Result<()> { barrier.wait(); // Add a small staggered delay to reduce race conditions on Windows - std::thread::sleep(std::time::Duration::from_millis(i as u64 * 10)); + std::thread::sleep(std::time::Duration::from_millis(50 + i as u64 * 20)); let thread_start = Instant::now();