Clamp the room for new chunks at 0, and test the held-items wording and the session option's target
This commit is contained in:
@@ -118,9 +118,8 @@ def start_chunks(loop_run: LoopRun, leaving: bool, paths: Paths, env: typing.Map
|
||||
if windows and (owned := tmux.owner(session, effects.tmux)) != loop_run.root:
|
||||
return Failure(f"the tmux session {session} runs the chunks of {owned or 'another checkout'}, whose key maps to the same session name; rename one of the two checkouts' folders")
|
||||
running = [window.name for window in windows if not window.dead and not (leaving and window.name == loop_run.chunk)]
|
||||
room = config.parallel_chunks - len(running)
|
||||
if room <= 0:
|
||||
return []
|
||||
# Below 0 where the config lowered parallel-chunks while more chunks ran.
|
||||
room = max(config.parallel_chunks - len(running), 0)
|
||||
# A loop that the human stopped, or that failed, keeps its window, dead, with its last lines and its items. Only the human's loop-claude <task> starts it again, before any other chunk.
|
||||
stopped = [window.name for window in windows if window.dead]
|
||||
chunks = [] if leaving else stopped[:room]
|
||||
|
||||
@@ -1448,6 +1448,7 @@ class StartChunks(unittest.TestCase):
|
||||
fake = FakeEffects(windows="item-5\t0\t@1\n")
|
||||
self.assertEqual(self.start(fake, owner=owner), Failure(f"the tmux session {self.session} runs the chunks of {named}, whose key maps to the same session name; rename one of the two checkouts' folders"))
|
||||
self.assertEqual(self.starts(fake), [])
|
||||
self.assertIn(["show-options", "-qv", "-t", f"={self.session}:", "@loop-root"], fake.tmux_calls)
|
||||
|
||||
def test_leaves_out_the_items_a_running_chunk_names_on_its_chunk_items_line(self):
|
||||
self.limit(2)
|
||||
@@ -1466,6 +1467,9 @@ class StartChunks(unittest.TestCase):
|
||||
self.limit(2)
|
||||
fake = FakeEffects(windows="item-5\t0\t@1\nitem-6 ?\t0\t@2\n")
|
||||
self.assertEqual((self.start(fake), self.planned, self.starts(fake)), ([], 0, []))
|
||||
# More chunks run than the limit allows, as after it was lowered; a stopped chunk still waits.
|
||||
fake = FakeEffects(windows="item-5\t0\t@1\nitem-6\t0\t@2\nitem-7\t0\t@3\nitem-8\t1\t@4\nitem-9\t1\t@5\n")
|
||||
self.assertEqual((self.start(fake), self.planned), ([], 0))
|
||||
|
||||
def test_a_finishing_chunks_own_window_counts_as_no_longer_running(self):
|
||||
fake = FakeEffects(windows="item-5\t0\t@1\n")
|
||||
@@ -1612,6 +1616,7 @@ class ChunkFacts(unittest.TestCase):
|
||||
said = chunk_start.chunk_facts(a_loop(fake.effects(), launcher=self.LAUNCHER))
|
||||
self.assertTrue(said.endswith("- A fact.\n\nOther chunks of this project, running or stopped, hold items 5, 9, 12. Leave those items out of this chunk, even where the facts above list them as items that may join it."), said)
|
||||
self.assertEqual(prompts.held_by_others([9]), "\n\nOther chunks of this project, running or stopped, hold item 9. Leave those items out of this chunk, even where the facts above list them as items that may join it.")
|
||||
self.assertTrue(prompts.held_by_others([4, 9]).startswith("\n\nOther chunks of this project, running or stopped, hold items 4, 9."))
|
||||
# A worker whose preflight failed is told them too.
|
||||
fake = FakeEffects(python=[ran(code=1, stderr="git could not start\n")], windows="item-9\t0\t@4\n")
|
||||
said = chunk_start.chunk_facts(a_loop(fake.effects(), launcher=self.LAUNCHER))
|
||||
|
||||
Reference in New Issue
Block a user