Kill the mutants that survived on the epic branch's changed lines
CI / tests (pull_request) Successful in 3m45s

This commit is contained in:
Lilleman
2026-11-20 20:47:46 +01:00
parent e3a964a73f
commit 525f3f8836
9 changed files with 187 additions and 8 deletions
+67
View File
@@ -1000,6 +1000,19 @@ class StepwiseStore:
return self.store.move_issue(key, status)
class LaggingStore:
"""A store whose every read answers `read`, as a search that doesn't show the latest move yet; every other call is the wrapped store's."""
def __init__(self, store: typing.Any, read: typing.Any) -> None:
self.store, self.answer = store, read
def __getattr__(self, name: str) -> typing.Any:
return getattr(self.store, name)
def read(self) -> typing.Any:
return self.answer
class AnEpicsWorkingBranch(DoEpicTest):
"""A chunk in a repo whose config sets `epic-branch`, so its pull request goes into the branch ABC-12."""
@@ -1033,6 +1046,19 @@ class AnEpicsWorkingBranch(DoEpicTest):
self.assertEqual(self.git_calls, [(args, self.checkout) for args in (("symbolic-ref", "--short", "refs/remotes/origin/HEAD"), ("fetch", "--quiet", "origin"), ("rev-parse", "--quiet", "--verify", "refs/remotes/origin/ABC-12"), ("rev-list", "--count", "origin/ABC-12..origin/main"), ("config", "branch.ABC-20.chunk-base", "ABC-12"))])
self.assertIn("origin/ABC-12 already holds origin/main; ABC-20's pull request goes into ABC-12\n", out.getvalue())
def test_says_the_default_branchs_whole_name_however_it_ends(self) -> None:
out = io.StringIO()
with contextlib.redirect_stdout(out):
main.epic_based("ABC-20", self.checkout, self.epic_run(self.with_git(FakeEffects(), symbolic_ref="origin/BOX\n")))
self.assertIn("origin/ABC-12 already holds origin/BOX; ABC-20's pull request goes into ABC-12\n", out.getvalue())
def test_a_folder_no_checkout_holds_stops_with_the_reason_its_config_cannot_be_found(self) -> None:
elsewhere = self.home / "elsewhere"
elsewhere.mkdir()
unnamed = main.config_located(str(elsewhere), self.home)
assert isinstance(unnamed, Failure), unnamed
self.assertEqual(main.epic_based("ABC-20", str(elsewhere), self.epic_run(self.with_git(FakeEffects()))), main.Stop(1, unnamed.reason))
def test_a_repo_whose_config_sets_no_epic_branch_has_none_and_runs_no_git(self) -> None:
self.repo_config.write_text(self.repo_config.read_text(encoding="utf-8").replace('epic-branch = "{epic}"\n', ""), encoding="utf-8")
self.assertIsNone(main.epic_based("ABC-20", self.checkout, self.epic_run(self.with_git(FakeEffects()))))
@@ -1069,6 +1095,47 @@ class AnEpicsWorkingBranch(DoEpicTest):
self.assertIn("parked: pull request #7 awaits an approval\n", out)
self.assertIn("the chunk finished; started ABC-22\n", out)
self.assertIn("The chunk's pull request goes into the epic's working branch `ABC-12`", prompts[0])
self.assertIn(("config", "branch.ABC-20.chunk-base", "ABC-12"), [args for args, _ in self.git_calls])
def test_an_issue_that_cannot_move_to_the_open_status_says_so_and_its_chunk_goes_on(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-open-status = "Code Review"\njira-pull-request-merged-status = "Release Ready"\n')
self.backend = lambda config, key: (StepwiseStore(self.store, {"Code Review": "QA"}), EpicRecord(Description(self.description))) # type: ignore[method-assign,arg-type]
self.forges = [awaiting(), awaiting(), awaiting(decision="APPROVED")]
fake = self.with_git(FakeEffects(streams=[self.worker(), self.worker()], claude=[judged("finished"), judged("finished")], windows=PARKED_WINDOW))
code, out, err = self.run_main(["--chunk", "ABC-20", "ABC-12"], fake, MODELS)
self.assertEqual(code, 0, err)
self.assertIn("ABC-20 did not move to 'Code Review' though its pull request is open: ABC-20 has no transition to 'Code Review' from its status 'To Do'\n", out)
def test_a_finished_chunk_whose_issue_has_no_pull_request_into_the_epic_branch_moves_it_to_done(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
with contextlib.redirect_stdout(io.StringIO()):
self.assertEqual(main.handed_on("ABC-20", self.epic_run(FakeEffects(windows="")), humans=True).code, 0)
self.assertEqual((self.store.issues[0].status, self.store.issues[0].done), ("Done", True))
# A chunk not marked as in a repo moves its issue to done itself, even where the automation moves issues.
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n')
self.store.change("ABC-22", status="Release Ready")
with contextlib.redirect_stdout(io.StringIO()):
self.assertEqual(main.handed_on("ABC-22", self.epic_run(FakeEffects(windows=""))).code, 0)
self.assertEqual((self.store.issues[1].status, self.store.issues[1].done), ("Done", True))
def test_a_read_that_does_not_show_the_move_yet_still_counts_the_issue_moved(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
before = self.store.read()
lagging = LaggingStore(self.store, before)
out = io.StringIO()
with contextlib.redirect_stdout(out):
stop = main.handed_on("ABC-20", dataclasses.replace(self.epic_run(FakeEffects(windows="")), store=lagging), in_repo=True, to_epic_branch=True)
self.assertEqual(stop.code, 0, stop.reason)
self.assertIn("the chunk finished; started ABC-22\n", out.getvalue())
unread = LaggingStore(self.store, Failure("Jira answered 503"))
stop = main.handed_on("ABC-22", dataclasses.replace(self.epic_run(FakeEffects(windows="")), store=unread), in_repo=True, to_epic_branch=True)
self.assertEqual(stop, main.Stop(1, "the chunk finished, but the next could not start: Jira answered 503"))
def test_the_epics_finishing_is_due_once_every_issue_has_the_merged_status(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-pull-request-merged-status = "Release Ready"\n')
for each in ("ABC-20", "ABC-22"):
self.store.change(each, status="Release Ready")
self.assertIsInstance(main.chunk_work("ABC-12", None, "English", self.epic_run(FakeEffects())), tuple)
def test_without_a_merged_status_a_finished_chunk_stops_where_automation_moves_issues_and_is_done_where_it_doesnt(self) -> None:
self.settings('jira-unblocking-statuses = ["Release Ready"]\njira-automation-moves-issues = true\n')