Kill the mutants that survived on the lines the release review changed
This commit is contained in:
@@ -177,6 +177,51 @@ class WindowStarts(unittest.TestCase):
|
||||
self.assertEqual(cycles, [(main.LoopRun(1, "/r", "do it", "", chunk="item-3"), loop), (main.LoopRun(2, "/r", "do it", "", chunk="item-3"), loop)])
|
||||
self.assertEqual(started, [(main.LoopRun(2, "/r", "do it", "", chunk="item-3"), True, loop.paths, env, launcher, effects)])
|
||||
|
||||
def window_loop(self, cycles, env, **doubles):
|
||||
"""run_loop's stop for item-3's window loop, and each step it took with what it handed that step. Each step answers as its double in `doubles` does, else as a cycle without a stop: next_cycle answers the next of `cycles`, run_cycle an unfinished verdict, and closed_cycle the run with one more unfinished verdict."""
|
||||
fake, calls, cycles = FakeEffects(git=["/r\n"]), [], list(cycles)
|
||||
effects, launcher, home = fake.effects(), pathlib.Path("/b/loop-claude"), paths.paths_from(self.HOME)
|
||||
self.unfinished = unittest.mock.Mock(verdict=unittest.mock.Mock(spec=Unfinished))
|
||||
answers = {"fingerprint": lambda *args: "print-1", "exec_if_edited": lambda *args: None, "next_cycle": lambda *args: cycles.pop(0), "run_cycle": lambda *args: self.unfinished,
|
||||
"closed_cycle": lambda run, *args: dataclasses.replace(run, unfinished_run=run.unfinished_run + 1), "check_routing": lambda *args: None, **doubles}
|
||||
|
||||
def step(name):
|
||||
return lambda *args: calls.append((name, *args)) or answers[name](*args)
|
||||
|
||||
stop = main.run_loop(["--chunk", "item-3", "do it"], env, home, launcher, CWD, effects, steps(lambda *args: self.fail(args), **{name: step(name) for name in answers}))
|
||||
self.loop = this_loop.Loop(root="/r", session=session.session_named("A r loop-claude item-3", self.HOME / ".claude" / "projects"), window=tmux.Window("loop-r", "item-3", "%4"), paths=home, env=env, launcher=launcher, effects=effects)
|
||||
return stop, calls
|
||||
|
||||
def test_a_window_loop_hands_each_step_of_a_cycle_what_the_steps_before_it_made(self):
|
||||
env = {"TMUX_PANE": "%4", "LOOP_CLAUDE_TRANSCRIPTS": "/t"}
|
||||
on_ladder = unittest.mock.Mock(project=OPUS_PROJECT, project_archive=pathlib.Path("/t/r"))
|
||||
off_ladder = unittest.mock.Mock(project=None, project_archive=pathlib.Path("/t/r"), route=unittest.mock.Mock(rung=Rung("my-model")))
|
||||
stop, calls = self.window_loop([on_ladder, off_ladder, Stop(2, "the human is needed")], env)
|
||||
self.assertEqual(stop, Stop(2, "the human is needed"))
|
||||
before, first, second, third = (main.LoopRun(number, "/r", "do it", "", unfinished_run=max(number - 1, 0), chunk="item-3") for number in range(4))
|
||||
self.assertEqual(calls, [
|
||||
("fingerprint", pathlib.Path("/b/loop-claude")),
|
||||
("exec_if_edited", self.loop, "print-1", before),
|
||||
("next_cycle", first, self.loop),
|
||||
("run_cycle", on_ladder),
|
||||
("closed_cycle", first, OPUS_PROJECT, self.unfinished, pathlib.Path("/t/r"), "loop-claude", self.loop),
|
||||
("check_routing", pathlib.Path("/t"), Rung("claude-opus-5-5", "medium"), self.loop),
|
||||
("exec_if_edited", self.loop, "print-1", dataclasses.replace(first, unfinished_run=1)),
|
||||
("next_cycle", second, self.loop),
|
||||
("run_cycle", off_ladder),
|
||||
("closed_cycle", second, None, self.unfinished, pathlib.Path("/t/r"), "loop-claude", self.loop),
|
||||
("check_routing", pathlib.Path("/t"), Rung("my-model"), self.loop),
|
||||
("exec_if_edited", self.loop, "print-1", dataclasses.replace(second, unfinished_run=2)),
|
||||
("next_cycle", third, self.loop),
|
||||
])
|
||||
|
||||
def test_a_window_loop_stops_with_the_stop_of_the_step_that_made_one(self):
|
||||
cycle = unittest.mock.Mock(project=OPUS_PROJECT, project_archive=pathlib.Path("/t/r"))
|
||||
for name, taken in (("exec_if_edited", 2), ("run_cycle", 4), ("closed_cycle", 5), ("check_routing", 6)):
|
||||
with self.subTest(step=name):
|
||||
stop, calls = self.window_loop([cycle], {"TMUX_PANE": "%4"}, **{name: lambda *args: Stop(1, f"{name} stopped")})
|
||||
self.assertEqual((stop, len(calls), calls[-1][0]), (Stop(1, f"{name} stopped"), taken, name))
|
||||
|
||||
def test_a_window_loop_given_no_task_prints_the_help(self):
|
||||
self.assertEqual(main.loop_run_from(["--chunk", "item-3"], CWD, FakeEffects(git=["/r\n"]).effects()), Stop(1, usage.HELP))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user