From 388d5f9a04734251131a89dc2f1bb76c1af51214 Mon Sep 17 00:00:00 2001 From: CodeGraph Test Date: Thu, 1 Oct 2026 13:35:10 +0800 Subject: [PATCH] test: keep two Windows-only flakes off the release gate Main CI failed on Windows twice in this alignment, each time in a test the change under test never touched: - definition_grouping named its temp project by pid and nanoseconds only, and parallel tests in the file shared the prefix; Windows' clock gave two of them the same nanosecond, so the second `init` found the first's namespace. A sequence number keeps the directories apart. - the watcher's root .gitignore reload test waited two seconds for a full reconcile, which a loaded Windows runner has exceeded. It now waits ten; the assertions are unchanged. --- crates/codegraph-cli/tests/definition_grouping.rs | 11 +++++++++-- crates/codegraph-watch/src/watcher.rs | 9 +++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/codegraph-cli/tests/definition_grouping.rs b/crates/codegraph-cli/tests/definition_grouping.rs index 01e42bc..18760a1 100644 --- a/crates/codegraph-cli/tests/definition_grouping.rs +++ b/crates/codegraph-cli/tests/definition_grouping.rs @@ -3,18 +3,25 @@ use std::fs; use std::path::{Path, PathBuf}; use std::process::Command; +use std::sync::atomic::{AtomicU64, Ordering}; struct TestDir(PathBuf); +/// Parallel tests in this file share a name prefix, and Windows' clock can hand +/// two of them the same nanosecond, so a sequence number keeps each directory +/// apart (a shared one failed `init` with "namespace already exists"). +static NEXT_DIR: AtomicU64 = AtomicU64::new(0); + impl TestDir { fn new() -> Self { let path = std::env::temp_dir().join(format!( - "codegraph-cli-definition-groups-{}-{}", + "codegraph-cli-definition-groups-{}-{}-{}", std::process::id(), std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) .expect("clock") - .as_nanos() + .as_nanos(), + NEXT_DIR.fetch_add(1, Ordering::Relaxed) )); fs::create_dir_all(&path).expect("create temp project"); Self(path) diff --git a/crates/codegraph-watch/src/watcher.rs b/crates/codegraph-watch/src/watcher.rs index fe67c6d..024cf55 100644 --- a/crates/codegraph-watch/src/watcher.rs +++ b/crates/codegraph-watch/src/watcher.rs @@ -2046,6 +2046,9 @@ mod tests { watcher.stop(); } + /// How long a test waits for a full reconcile to report. + const FULL_SYNC_WAIT: Duration = Duration::from_secs(10); + #[test] fn root_gitignore_reload_reconciles_and_readmits_sources() { let _env = crate::test_env::env_guard(); @@ -2072,8 +2075,10 @@ mod tests { watcher.ingest_event_for_tests(".gitignore"); watcher.ingest_event_for_tests("generated/drop.ts"); watcher.flush_for_tests(); + // A full reconcile rescans and rewrites the index; a loaded Windows + // runner has taken over two seconds for it. let removed = outcome_rx - .recv_timeout(Duration::from_secs(2)) + .recv_timeout(FULL_SYNC_WAIT) .expect("gitignore-removal full sync"); assert_eq!(removed.files_removed, 1); assert_eq!(removed.trigger_paths, vec![".gitignore".to_string()]); @@ -2082,7 +2087,7 @@ mod tests { watcher.ingest_event_for_tests(".gitignore"); watcher.flush_for_tests(); let readmitted = outcome_rx - .recv_timeout(Duration::from_secs(2)) + .recv_timeout(FULL_SYNC_WAIT) .expect("gitignore-readmission full sync"); assert_eq!(readmitted.files_reindexed, 1); assert!(