diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-22 01:53:32 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-04-22 01:53:32 +0300 |
| commit | 5bd939fbfc92a8073d0eac11dfb02a31ea638b15 (patch) | |
| tree | a846d270800425c5e7a93c165fd547959b638c72 /tests | |
| parent | 5063cdf6d183d1abefb88cc1886170fed57516d4 (diff) | |
fix: clean up shared-checkout test servers
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/support/mod.rs | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 7342fde3..52a05578 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -223,7 +223,7 @@ fn iter_worktree_server_pids() -> std::io::Result<Vec<u32>> { continue; } - if is_worktree_herdr_server_process(pid) { + if is_test_herdr_server_process(pid) { pids.push(pid); } } @@ -231,12 +231,12 @@ fn iter_worktree_server_pids() -> std::io::Result<Vec<u32>> { Ok(pids) } -fn is_worktree_herdr_server_process(pid: u32) -> bool { +fn is_test_herdr_server_process(pid: u32) -> bool { let Some(exe_path) = proc_link_target(pid, "exe") else { return false; }; - if !is_worktree_herdr_binary(&exe_path) { + if !is_test_herdr_binary(&exe_path) { return false; } @@ -296,11 +296,12 @@ fn runtime_dir_owner_alive(runtime_dir: &Path) -> bool { process_exists(owner_pid) } -fn is_worktree_herdr_binary(path: &Path) -> bool { - path.ends_with("target/debug/herdr") - && path - .components() - .any(|component| component.as_os_str() == "herdr-worktrees") +fn current_checkout_root() -> &'static Path { + Path::new(env!("CARGO_MANIFEST_DIR")) +} + +fn is_test_herdr_binary(path: &Path) -> bool { + path.ends_with("target/debug/herdr") && path.starts_with(current_checkout_root()) } extern "C" fn run_atexit_cleanup() { @@ -421,4 +422,21 @@ mod tests { "missing runtime dirs that are session-owned should be considered killable" ); } + + #[test] + fn test_binary_matcher_accepts_current_checkout_debug_binary() { + let binary = current_checkout_root().join("target/debug/herdr"); + assert!( + is_test_herdr_binary(&binary), + "current checkout debug binary should be considered test-owned" + ); + } + + #[test] + fn test_binary_matcher_rejects_installed_binary() { + assert!( + !is_test_herdr_binary(Path::new("/home/can/.local/bin/herdr")), + "installed binaries must not be considered test-owned" + ); + } } |
