Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
test(remove): retry the drain when a forked child still holds the trash lock (#4530)
Worktrunk Bota4a3063c71da
diff --git a/src/commands/configure_shell.rs b/src/commands/configure_shell.rsindex 12c182cb0..fe8c3ea31 100644--- a/src/commands/configure_shell.rs+++ b/src/commands/configure_shell.rs@@ -2191,7 +2191,11 @@ mod tests {.unwrap();assert!(contender.try_lock_exclusive().is_err());drop(locked);- contender.try_lock_exclusive().unwrap();+ // A child that a concurrent test forks while `locked` is open inherits+ // the lock until it execs, so the release can take an instant to land.+ worktrunk::testing::wait_for("the rc lock to be released", || {+ contender.try_lock_exclusive().is_ok()+ });}#[test]diff --git a/src/git/remove.rs b/src/git/remove.rsindex 00752b4c6..242f4fce3 100644--- a/src/git/remove.rs+++ b/src/git/remove.rs@@ -878,8 +878,13 @@ mod tests {assert!(staged.exists(), "the lock holder owns the deletion");drop(holder);- drain_trash(&trash).unwrap();- assert!(staged_trash_entries(&trash).is_empty());+ // A child that a concurrent test forks while `holder` is open inherits+ // the lock until it execs, so a drain can still find it held for an+ // instant and leave the deletion to that phantom holder.+ crate::testing::wait_for("a drain to delete the staged entries", || {+ drain_trash(&trash).unwrap();+ staged_trash_entries(&trash).is_empty()+ });assert!(foreign.exists());assert!(staged_trash_entries(&temp.path().join("missing")).is_empty());}