Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/codegraph-cli/tests/definition_grouping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions crates/codegraph-watch/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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()]);
Expand All @@ -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!(
Expand Down
Loading