fix(democracy): skip worktrees with a running make in the stop-stage cleanup

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-10-31 17:14:53 +01:00
1 parent b69a7f85d9
commit ed0ea62b52
3 files changed
+36 -2

No files matched your search

+16
View File
@@ -66,6 +66,7 @@ class TestWatchCommands(unittest.TestCase):
"worktree_cleanup": [],
"worktrees_command": "true",
"worktree_marker": "Makefile",
"busy_processes": ["sleep"],
"cache_dirs": [str(self.cache)],
"cache_budget_percent": 3,
"slot_need_gb": {"swarm": 30, "test": 0.001},
@@ -158,6 +159,21 @@ class TestWatchCommands(unittest.TestCase):
self.assertEqual((marked / "cleaned").read_text(encoding="utf-8"), "x\n")
self.assertFalse((foreign / "cleaned").exists())
def test_full_cleanup_skips_a_worktree_where_a_busy_process_runs(self):
idle, gated = self.base / "idle", self.base / "gated"
for tree in (idle, gated):
(tree / "sub").mkdir(parents=True)
(tree / "Makefile").write_text("", encoding="utf-8")
gate = subprocess.Popen(["sleep", "60"], cwd=gated / "sub")
self.addCleanup(gate.wait)
self.addCleanup(gate.kill)
self.cfg["worktrees_command"] = f"echo {idle}; echo {gated}"
self.cfg["worktree_cleanup"] = ["echo x >> {worktree}/cleaned"]
self._write_config()
self.assertEqual(self._run("cleanup", "--full").returncode, 0)
self.assertTrue((idle / "cleaned").exists())
self.assertFalse((gated / "cleaned").exists())
def test_without_config_every_command_is_a_no_op(self):
self.config.unlink()
result = self._run("status")