Skip to content

The agent that grows with you

test(worktree): fold the include-symlink reclaim case into the startup test

kshitijk4poore55816a8a4b5
diff --git a/tests/hermes_cli/test_worktree_reclaim_revalidation.py b/tests/hermes_cli/test_worktree_reclaim_revalidation.py
index 8cb8ed2bb4a..82ef6b22460 100644
--- a/tests/hermes_cli/test_worktree_reclaim_revalidation.py
+++ b/tests/hermes_cli/test_worktree_reclaim_revalidation.py
@@ -52,34 +52,27 @@ def test_attended_reclaim_preserves_work_added_after_audit(repository, kind):
assert _git(root, "rev-parse", "--verify", "scratch")
[email protected]("kind", ["edit", "commit"])
[email protected]("kind", ["edit", "commit", "include-symlink"])
def test_startup_reclaim_preserves_work_added_after_classification(repository, kind):
from hermes_cli.worktree_ops import _classify_prune_candidates, _reap_prune_verdicts
root, tree = repository
+ if kind == "include-symlink": # our own scaffolding only: still reclaimed, target untouched
+ (root / "node_modules").mkdir()
+ (root / ".worktreeinclude").write_text("node_modules\n", encoding="utf-8")
+ (root / ".gitignore").write_text("node_modules/\n.worktrees/\n", encoding="utf-8")
+ os.symlink(root / "node_modules", tree / "node_modules")
verdicts = _classify_prune_candidates(str(root), [(tree, time.time() - 86400, False)])
assert verdicts[0][3] == "reap"
- _add_work(tree, kind)
-
- _reap_prune_verdicts(str(root), verdicts, stale_work_cutoff=0)
-
- assert tree.is_dir()
- assert (tree / "README.md").read_text(encoding="utf-8") == "new work after audit\n"
- assert _git(root, "rev-parse", "--verify", "scratch")
-
-
-def test_startup_reclaim_still_removes_include_symlink_only_tree(repository):
- from hermes_cli.worktree_ops import _classify_prune_candidates, _reap_prune_verdicts
-
- root, tree = repository
- (root / "node_modules").mkdir()
- (root / ".worktreeinclude").write_text("node_modules\n", encoding="utf-8")
- (root / ".gitignore").write_text("node_modules/\n.worktrees/\n", encoding="utf-8")
- os.symlink(root / "node_modules", tree / "node_modules")
- verdicts = _classify_prune_candidates(str(root), [(tree, time.time() - 86400, False)])
- assert verdicts[0][3] == "reap"
+ added_work = kind in {"edit", "commit"}
+ if added_work:
+ _add_work(tree, kind)
_reap_prune_verdicts(str(root), verdicts, stale_work_cutoff=0)
- assert not tree.exists()
- assert (root / "node_modules").is_dir()
+ assert tree.is_dir() is added_work
+ if added_work:
+ assert (tree / "README.md").read_text(encoding="utf-8") == "new work after audit\n"
+ assert _git(root, "rev-parse", "--verify", "scratch")
+ else:
+ assert (root / "node_modules").is_dir()