Skip to content

Commit 08c523c

Browse files
committed
no-mistakes(review): Guard all remaining HOME-reading tests with shared env lock
1 parent 1ce5fc5 commit 08c523c

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

crates/codegraph-server/src/daemon.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ mod tests {
413413
fn heartbeat_path_is_slug_json_under_daemons_dir() {
414414
// heartbeat_path only fails if no HOME/USERPROFILE is set; in the test
415415
// environment one is always present.
416+
let _guard = crate::test_env::lock();
416417
let path = heartbeat_path("my-slug").expect("home is set in test env");
417418
assert_eq!(path.file_name().unwrap(), "my-slug.json");
418419
assert_eq!(path.parent().unwrap(), daemons_dir().unwrap());
@@ -423,6 +424,7 @@ mod tests {
423424
fn write_read_remove_round_trip() {
424425
// Use a distinctive slug so we never collide with a real daemon file,
425426
// and clean it up regardless of assertion outcome ordering.
427+
let _guard = crate::test_env::lock();
426428
let slug = "codegraph-unit-test-daemon-rw";
427429
let mut hb = DaemonHeartbeat::new(PathBuf::from("/tmp/round-trip-ws"), slug.to_string());
428430
hb.mark_indexed();
@@ -442,6 +444,8 @@ mod tests {
442444

443445
#[test]
444446
fn live_daemon_for_returns_fresh_and_prunes_stale() {
447+
let _guard = crate::test_env::lock();
448+
445449
// Fresh heartbeat: live_daemon_for surfaces it.
446450
let fresh_slug = "codegraph-unit-test-daemon-fresh";
447451
let mut fresh = DaemonHeartbeat::new(PathBuf::from("/tmp/live-ws"), fresh_slug.to_string());
@@ -463,6 +467,7 @@ mod tests {
463467
#[test]
464468
fn no_daemon_when_heartbeat_absent() {
465469
// A slug that was never written has no live daemon and reads as None.
470+
let _guard = crate::test_env::lock();
466471
let slug = "codegraph-unit-test-daemon-never-written";
467472
DaemonHeartbeat::remove(slug).ok();
468473
assert!(DaemonHeartbeat::read(slug).is_none());

crates/codegraph-server/src/memory.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ mod tests {
719719
#[test]
720720
fn test_project_data_dir_format() {
721721
// Uses a path that exists so canonicalize works
722+
let _guard = crate::test_env::lock();
722723
let dir = project_data_dir(Path::new("/tmp")).unwrap();
723724
let dir_str = dir.to_string_lossy();
724725

@@ -744,13 +745,15 @@ mod tests {
744745

745746
#[test]
746747
fn test_project_data_dir_different_paths_different_hashes() {
748+
let _guard = crate::test_env::lock();
747749
let dir1 = project_data_dir(Path::new("/tmp/project-a")).unwrap();
748750
let dir2 = project_data_dir(Path::new("/tmp/project-b")).unwrap();
749751
assert_ne!(dir1, dir2);
750752
}
751753

752754
#[test]
753755
fn test_project_data_dir_same_name_different_parent() {
756+
let _guard = crate::test_env::lock();
754757
let dir1 = project_data_dir(Path::new("/tmp/a/app")).unwrap();
755758
let dir2 = project_data_dir(Path::new("/tmp/b/app")).unwrap();
756759
// Same base name but different hashes
@@ -773,8 +776,10 @@ mod tests {
773776

774777
#[tokio::test]
775778
#[ignore = "requires model files"]
779+
#[allow(clippy::await_holding_lock)]
776780
async fn test_memory_manager_lifecycle() {
777781
use tempfile::TempDir;
782+
let _guard = crate::test_env::lock();
778783
let temp_dir = TempDir::new().unwrap();
779784
let manager = MemoryManager::new(None);
780785

0 commit comments

Comments
 (0)