Kill the surviving mutants of the dry run: pin the tmux and git wrappers, the write log and the printed output
CI / tests (pull_request) Failing after 2m36s
CI / tests (pull_request) Failing after 2m36s
This commit is contained in:
+2
-2
@@ -138,9 +138,9 @@ def run(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launcher:
|
||||
if isinstance(config, Failure):
|
||||
return Stop(1, config.reason)
|
||||
store, record = backend(config, words[0])
|
||||
if dry_run_asked:
|
||||
return dry_run_printed(EpicRun(words[0], config, store, record, paths, env, launcher, effects, forge_at))
|
||||
epic = EpicRun(words[0], config, store, record, paths, env, launcher, effects, forge_at)
|
||||
if dry_run_asked:
|
||||
return dry_run_printed(epic)
|
||||
if status_asked:
|
||||
return status_printed(epic)
|
||||
return windows_opened(epic) if chunk is None else chunk_run(chunk, epic)
|
||||
|
||||
@@ -39,6 +39,25 @@ class TheRecordingTmux(unittest.TestCase):
|
||||
self.assertEqual(run(["list-windows", *LISTED]).stdout, "ABC-21\t0\t@dry1\n")
|
||||
self.assertEqual(run(["list-windows", "-t", "=epic-ABC-99", "-F", "x"]).stdout, "")
|
||||
|
||||
def test_answers_each_command_with_its_own_words_and_no_error(self) -> None:
|
||||
def refused(args: list[str]) -> subprocess.CompletedProcess[str]:
|
||||
return subprocess.CompletedProcess(args, 1, "junk", "no server")
|
||||
def fields(done: subprocess.CompletedProcess[str]) -> tuple[object, int, str, str]:
|
||||
return done.args, done.returncode, done.stdout, done.stderr
|
||||
run = dry_run.recording(refused)
|
||||
self.assertEqual(fields(run(START)), (START, 0, "@dry1\n", ""))
|
||||
self.assertEqual(fields(run(["kill-window", "-t", "@1"])), (["kill-window", "-t", "@1"], 0, "", ""))
|
||||
self.assertEqual(fields(run(["list-windows", *LISTED])), (["list-windows", *LISTED], 0, "ABC-21\t0\t@dry1\n", ""))
|
||||
self.assertEqual(fields(dry_run.recording(refused)(["list-windows", *LISTED])), (["list-windows", *LISTED], 0, "", ""))
|
||||
|
||||
def test_lists_every_window_it_would_start(self) -> None:
|
||||
run = dry_run.recording(tmux([], ""))
|
||||
run(START)
|
||||
run(["new-window", "-d", "-t", "=epic-ABC-12:", "-n", "ABC-22", "-c", "/code/web", "-P"])
|
||||
run(["new-window", "-d", "-t", "=epic-ABC-99:", "-n", "ABC-23", "-c", "/code/web", "-P"])
|
||||
self.assertEqual(run(["list-windows", *LISTED]).stdout, "ABC-21\t0\t@dry1\nABC-22\t0\t@dry2\n")
|
||||
self.assertEqual(run(["list-windows", "-a", "-F", "x"]).stdout, "epic-ABC-12\tABC-21\t0\t@dry1\t/code/api\nepic-ABC-12\tABC-22\t0\t@dry2\t/code/web\nepic-ABC-99\tABC-23\t0\t@dry3\t/code/web\n")
|
||||
|
||||
def test_answers_a_change_as_done_and_reads_the_real_tmux_for_a_read(self) -> None:
|
||||
calls: list[list[str]] = []
|
||||
run = dry_run.recording(tmux(calls))
|
||||
@@ -59,6 +78,17 @@ class TheGitThatClonesNothing(unittest.TestCase):
|
||||
self.assertEqual(git("remote", cwd="/c"), "ok")
|
||||
self.assertEqual(ran, [("remote",)])
|
||||
|
||||
def test_passes_every_option_on(self) -> None:
|
||||
seen: list[tuple[tuple[str, ...], dict[str, object]]] = []
|
||||
|
||||
def real(*args: str, **options: object) -> str | Failure:
|
||||
seen.append((args, options))
|
||||
return "ok"
|
||||
git = dry_run.without_clones(real) # type: ignore[arg-type]
|
||||
git("log", cwd="/c", timeout=5.0, guarded=True, errors="replace")
|
||||
git("log")
|
||||
self.assertEqual(seen, [(("log",), {"cwd": "/c", "timeout": 5.0, "guarded": True, "errors": "replace"}), (("log",), {"cwd": None, "timeout": None, "guarded": False, "errors": "strict"})])
|
||||
|
||||
|
||||
class TheEpicItCopies(unittest.TestCase):
|
||||
def test_copies_the_issues_and_the_closed_state_and_files_under_keys_jira_never_gives(self) -> None:
|
||||
@@ -72,13 +102,13 @@ class TheEpicItCopies(unittest.TestCase):
|
||||
|
||||
def test_notes_each_kind_of_write_in_order(self) -> None:
|
||||
epic = MemoryEpic("ABC-12", [issue("ABC-20"), issue("ABC-21")])
|
||||
epic.file("ABC-20", "Sub", "d", ("repo:api",), "ABC-21")
|
||||
epic.file("ABC-20", "Sub", "d", ("repo:api", "do-epic-claude"), "ABC-21")
|
||||
epic.add_label("ABC-21", "do-epic-claude")
|
||||
epic.rank("ABC-21", "ABC-20")
|
||||
epic.comment("ABC-20", " Why. ")
|
||||
epic.finish_issue("ABC-21")
|
||||
epic.close("All done")
|
||||
self.assertEqual(epic.writes, ["file ABC-102 under ABC-20: Sub, labelled repo:api, blocked by ABC-21", "label ABC-21 with do-epic-claude", "rank ABC-21 before ABC-20", "comment on ABC-20: Why.", "finish ABC-21", "close the epic: All done"])
|
||||
self.assertEqual(epic.writes, ["file ABC-102 under ABC-20: Sub, labelled do-epic-claude, repo:api, blocked by ABC-21", "label ABC-21 with do-epic-claude", "rank ABC-21 before ABC-20", "comment on ABC-20: Why.", "finish ABC-21", "close the epic: All done"])
|
||||
|
||||
def test_notes_no_write_that_fails(self) -> None:
|
||||
epic = MemoryEpic("ABC-12", [issue("ABC-20")])
|
||||
@@ -90,6 +120,12 @@ class TheEpicItCopies(unittest.TestCase):
|
||||
def test_fails_where_the_real_epic_cannot_be_read(self) -> None:
|
||||
self.assertEqual(dry_run.seeded(MemoryEpic("ABC-12", [], fails="Jira answered 503")), Failure("Jira answered 503"))
|
||||
|
||||
def test_fails_where_only_the_closed_state_cannot_be_read(self) -> None:
|
||||
class Unclosed(MemoryEpic):
|
||||
def closed(self) -> bool | Failure:
|
||||
return Failure("no state")
|
||||
self.assertEqual(dry_run.seeded(Unclosed("ABC-12", [issue("ABC-20")])), Failure("no state"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -267,7 +267,9 @@ MODELS = {"LOOP_CLAUDE_JUDGE_MODEL": "claude-opus-5-5", "LOOP_CLAUDE_WORKER_MODE
|
||||
class TheHumansRun(DoEpicTest):
|
||||
def test_shows_the_session_on_a_terminal_and_says_when_tmux_cannot(self) -> None:
|
||||
fake = FakeEffects(windows="ABC-21\t0\t@9\n")
|
||||
self.assertEqual(self.run_main(["ABC-12"], fake)[0], 0)
|
||||
code, out, err = self.run_main(["ABC-12"], fake)
|
||||
self.assertEqual((code, err), (0, ""))
|
||||
self.assertEqual(out, "<1790000000> started no chunk\n<1790000000> ABC-20 waits: it is a human's task\n")
|
||||
self.assertEqual(fake.tmux_calls[-1], ["attach-session", "-t", "=epic-ABC-12"])
|
||||
fake.effects = lambda made=fake.effects(): dataclasses.replace(made, tmux_on_terminal=lambda args: 1) # type: ignore[method-assign]
|
||||
code, _, err = self.run_main(["ABC-12"], fake, {"TMUX": "/tmp/tmux"})
|
||||
@@ -284,14 +286,14 @@ class TheHumansRun(DoEpicTest):
|
||||
def test_off_a_terminal_it_says_how_to_see_the_chunks(self) -> None:
|
||||
code, out, err = self.run_main(["ABC-12"], FakeEffects(on_terminal=False, windows="ABC-21\t0\t@9\n"))
|
||||
self.assertEqual((code, err), (0, ""))
|
||||
self.assertIn("not on a terminal; see the chunks with `tmux attach -t =epic-ABC-12`\n", out)
|
||||
self.assertTrue(out.endswith("not on a terminal; see the chunks with `tmux attach -t =epic-ABC-12`\n"))
|
||||
|
||||
def test_with_no_window_in_the_session_it_shows_none(self) -> None:
|
||||
self.issues = self.issues[:1]
|
||||
fake = FakeEffects()
|
||||
code, out, _ = self.run_main(["ABC-12"], fake)
|
||||
self.assertEqual(code, 0)
|
||||
self.assertIn("started no chunk\n", out)
|
||||
self.assertEqual(out, "<1790000000> started no chunk\n<1790000000> ABC-20 waits: it is a human's task\n")
|
||||
self.assertNotIn("attach-session", [args[0] for args in fake.tmux_calls])
|
||||
|
||||
def test_stops_without_its_settings_or_on_a_cap_it_cannot_read(self) -> None:
|
||||
@@ -1027,6 +1029,15 @@ class TheDryRun(DoEpicTest):
|
||||
self.assertIn("ABC-20 waits: missing is missing", out)
|
||||
self.assertEqual([what for seam, what in fake.calls if seam == "git" and "clone" in what], [])
|
||||
|
||||
def test_clones_no_missing_repo_and_says_so(self) -> None:
|
||||
shutil.rmtree(self.home / "code/web")
|
||||
self.issues = [issue("ABC-20", "repo:api"), issue("ABC-22", "repo:web")]
|
||||
fake = FakeEffects(on_terminal=False, git=["git@host.example:team/api.git", ""])
|
||||
code, out, err = self.run_main(["ABC-12", "--dry-run"], fake)
|
||||
self.assertEqual((code, err), (0, ""))
|
||||
self.assertEqual(out.replace("<1790000000> ", ""), f"dry run: nothing is written to Jira and no window starts\nplanning would write nothing to Jira\nwould start ABC-20\nABC-22 waits: cannot clone git@host.example:team/web to {self.home / 'code/web'}: a dry run clones nothing. Where does web live?\n")
|
||||
self.assertEqual([what for seam, what in fake.calls if seam == "git" and "clone" in what], [])
|
||||
|
||||
def test_stops_where_the_epic_cannot_be_read(self) -> None:
|
||||
store = MemoryEpic("ABC-12", [], fails="Jira answered 503")
|
||||
self.backend = lambda config, key: (store, EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
|
||||
|
||||
Reference in New Issue
Block a user