Kill the mutants that survived on the epic branch's changed lines
CI / tests (pull_request) Successful in 3m45s
CI / tests (pull_request) Successful in 3m45s
This commit is contained in:
@@ -88,7 +88,7 @@ class Checkout:
|
||||
|
||||
def __call__(self, command: list[str]) -> str | Failure:
|
||||
if command[:3] == ["git", "config", "--get"] and command[3].endswith(".chunk-base"):
|
||||
return self.chunk_base
|
||||
return self.chunk_base if command[3] == f"branch.{str(self.answers[('git', 'symbolic-ref', '--short', 'HEAD')]).strip()}.chunk-base" else ""
|
||||
self.ran.append(command)
|
||||
if command[0] == ("tea" if self.github else "gh"):
|
||||
return Failure(f"{command[0]} on the wrong forge")
|
||||
@@ -1087,6 +1087,42 @@ class EpicBranch(unittest.TestCase):
|
||||
checkout.answers[tuple(self.COMMENT_GH)] = Failure("gh pr comment: denied")
|
||||
self.assertEqual(step(["ready"], checkout, checkout.config), Failure("marked pull request #12 ready, but could not ask for a review: gh pr comment: denied"))
|
||||
|
||||
def test_a_pull_request_the_forge_does_not_mark_ready_gets_no_review_request(self):
|
||||
checkout = self.checkout()
|
||||
checkout.answers[("gh", "pr", "ready", "12")] = Failure("gh pr ready: denied")
|
||||
self.assertEqual(step(["ready"], checkout, checkout.config), Failure("gh pr ready: denied"))
|
||||
self.assertNotIn(self.COMMENT_GH, checkout.ran)
|
||||
|
||||
def test_a_push_whose_review_request_fails_says_the_branch_was_pushed_and_why_no_review_was_asked_for(self):
|
||||
refused = self.checkout()
|
||||
refused.answers[tuple(self.COMMENT_GH)] = Failure("gh pr comment: denied")
|
||||
unconfigured = self.checkout()
|
||||
unconfigured.answers[(PROJECT_CONFIG, "review-request-comment")] = Failure("no config names the checkout")
|
||||
for checkout, reason in ((refused, "gh pr comment: denied"), (unconfigured, "no config names the checkout")):
|
||||
with self.subTest(reason):
|
||||
self.assertEqual(step(["push"], checkout, checkout.config), Failure(f"pushed item-7, but could not ask for a review: {reason}"))
|
||||
self.assertIn(PUSH, checkout.ran)
|
||||
|
||||
def detached_on_second_read(self, checkout: Checkout) -> Run:
|
||||
"""checkout, whose HEAD reads as detached from the second time the branch checked out is read."""
|
||||
reads: list[list[str]] = []
|
||||
|
||||
def run(command: list[str]) -> str | Failure:
|
||||
if command == ["git", "symbolic-ref", "--short", "HEAD"]:
|
||||
reads.append(command)
|
||||
if len(reads) > 1:
|
||||
return Failure("git symbolic-ref: HEAD is detached")
|
||||
return checkout(command)
|
||||
return run
|
||||
|
||||
def test_a_branch_that_cannot_be_read_again_fails_the_push_review_request_and_the_merge(self):
|
||||
checkout = self.checkout()
|
||||
self.assertEqual(step(["push"], self.detached_on_second_read(checkout), checkout.config), Failure("pushed item-7, but could not ask for a review: git symbolic-ref: HEAD is detached"))
|
||||
self.assertNotIn(self.COMMENT_GH, checkout.ran)
|
||||
checkout = self.checkout()
|
||||
self.assertEqual(step(["merge"], self.detached_on_second_read(checkout), checkout.config), Failure("git symbolic-ref: HEAD is detached"))
|
||||
self.assertNotIn(["gh", "pr", "merge"], [command[:3] for command in checkout.ran])
|
||||
|
||||
def test_push_pushes_the_branch_and_asks_for_a_review_of_the_new_head(self):
|
||||
checkout = self.checkout()
|
||||
self.assertEqual(step(["push"], checkout, checkout.config), "Pushed item-7, and asked for a review of pull request #12 with “@reviewer review”.")
|
||||
@@ -1125,8 +1161,17 @@ class EpicBranch(unittest.TestCase):
|
||||
checkout.answers[("git", "rev-list", "--count", "origin/ABC-1..origin/main")] = "3\n"
|
||||
checkout.answers[("git", "merge-tree", "--write-tree", "origin/ABC-1", "origin/main")] = "7ree\n"
|
||||
checkout.answers[("git", "commit-tree", "7ree", "-p", "origin/ABC-1", "-p", "origin/main", "-m", "Merge remote-tracking branch 'origin/main' into ABC-1")] = "c0mm17\n"
|
||||
self.assertIn("Merged origin/main into origin/ABC-1. Opened", str(step(["open-epic", "ABC-1", "Ship the epic"], checkout, checkout.config)))
|
||||
self.assertEqual(step(["open-epic", "ABC-1", "Ship the epic"], checkout, checkout.config), "Merged origin/main into origin/ABC-1. Opened the pull request from ABC-1 into main, which a person merges.")
|
||||
self.assertIn(["git", "push", "--quiet", "origin", "c0mm17:refs/heads/ABC-1"], checkout.ran)
|
||||
self.assertEqual(checkout.acted()[-1], ["gh", "pr", "create", "--head", "ABC-1", "--base", "main", "--title", "Ship the epic", "--body", ""])
|
||||
|
||||
def test_open_epic_returns_a_failed_fetch_or_create(self):
|
||||
unfetched = self.epic()
|
||||
unfetched.answers[tuple(FETCH)] = Failure("git fetch: offline")
|
||||
self.assertEqual(step(["open-epic", "ABC-1", "Ship the epic"], unfetched, unfetched.config), Failure("git fetch: offline"))
|
||||
uncreated = self.epic()
|
||||
uncreated.answers[("gh", "pr", "create", "--head", "ABC-1", "--base", "main", "--title", "Ship the epic", "--body", "")] = Failure("gh pr create: denied")
|
||||
self.assertEqual(step(["open-epic", "ABC-1", "Ship the epic"], uncreated, uncreated.config), Failure("gh pr create: denied"))
|
||||
|
||||
def test_open_epic_leaves_a_conflict_with_the_default_branch_to_a_person_and_opens_nothing(self):
|
||||
checkout = self.epic()
|
||||
@@ -1155,10 +1200,11 @@ class EpicBranch(unittest.TestCase):
|
||||
self.assertEqual(unset.ran, [])
|
||||
checkout = self.epic()
|
||||
self.assertEqual(step(["open-epic", "ABC-1", "Ship\nit"], checkout, checkout.config), Failure("give a title of one line"))
|
||||
self.assertEqual(step(["open-epic", "ABC-1"], checkout, checkout.config), Failure(USAGE))
|
||||
for malformed in (["open-epic", "ABC-1"], ["open-epic", "ABC-1", "Ship it", "Body", "More"], ["open-epic", "--help", "Ship it"], ["open-epic", "ABC-1", "-Ship it"]):
|
||||
with self.subTest(malformed):
|
||||
self.assertEqual(step(malformed, checkout, checkout.config), Failure(USAGE))
|
||||
self.assertEqual(step(["open-epic", "abc/../1", "Ship it"], checkout, checkout.config), Failure("'abc/../1' is no epic's key, such as ABC-123"))
|
||||
self.assertEqual(checkout.ran, [])
|
||||
self.assertEqual(checkout.ran, [])
|
||||
|
||||
|
||||
class Launcher(unittest.TestCase):
|
||||
|
||||
@@ -626,6 +626,11 @@ class EpicBranchWorktree(unittest.TestCase):
|
||||
self.assertTrue(made.reason.startswith("none made: origin/main doesn't merge into origin/ABC-1 cleanly, so a person merges it"), made.reason)
|
||||
self.assertFalse((self.repo.temp / "proj-ABC-8").exists())
|
||||
|
||||
def test_a_worktree_path_that_holds_something_else_makes_no_worktree_off_the_epic_branch(self):
|
||||
taken = self.repo.temp / "proj-ABC-7"
|
||||
taken.mkdir()
|
||||
self.assertEqual(item_worktree(self.repo.root, "ABC-7", "origin/main", 30, "ABC-1"), Failure(f"none made, since {taken} exists and holds no worktree on the branch ABC-7"))
|
||||
|
||||
def test_names_the_epic_branch_by_the_plans_epic_and_none_where_the_config_sets_no_template(self):
|
||||
config = ProjectConfig("proj", pathlib.Path("/config"), pathlib.Path("/checkout"), {}, epic=Epic("https://acme.atlassian.net", "ABC-1"), epic_branch="epic/{epic}")
|
||||
self.assertEqual(epic_branch_of(config), "epic/ABC-1")
|
||||
|
||||
@@ -51,6 +51,18 @@ class Failing(unittest.TestCase):
|
||||
self.assertEqual(MemoryEpic("ABC-12", fails="Jira is down").start_issue("ABC-100"), Failure("Jira is down"))
|
||||
self.assertEqual(MemoryEpic("ABC-12").start_issue("ABC-100"), Failure("ABC-100 is not one of the child issues of the epic ABC-12, so it cannot be started"))
|
||||
|
||||
def test_a_move_fails_with_the_reason_given_and_one_outside_the_epic_says_so(self) -> None:
|
||||
self.assertEqual(MemoryEpic("ABC-12", fails="Jira is down").move_issue("ABC-100", "Done"), Failure("Jira is down"))
|
||||
self.assertEqual(MemoryEpic("ABC-12").move_issue("ABC-100", "Done"), Failure("ABC-100 is not one of the child issues of the epic ABC-12, so it cannot be moved"))
|
||||
|
||||
|
||||
class Moving(unittest.TestCase):
|
||||
def test_an_issue_moved_to_done_in_any_case_reads_as_done_and_one_moved_elsewhere_as_open(self) -> None:
|
||||
store = MemoryEpic("ABC-12")
|
||||
done, review = store.file("ABC-12", "Count the runs.", "", ()), store.file("ABC-12", "Ship the later thing.", "", ())
|
||||
self.assertEqual([store.move_issue(done, "DONE"), store.move_issue(review, "Code Review")], [None, None])
|
||||
self.assertEqual({issue.key: (issue.status, issue.done) for issue in store.issues}, {done: ("DONE", True), review: ("Code Review", False)})
|
||||
|
||||
|
||||
class Blocking(unittest.TestCase):
|
||||
def test_refuses_a_blocker_that_is_an_issue_of_another_epic(self) -> None:
|
||||
|
||||
@@ -411,6 +411,8 @@ class Jira(Case):
|
||||
store = self.new_store()
|
||||
key = store.file("ABC-12", "Count the runs.", "", ())
|
||||
self.assertEqual(store.move_issue(key, "Code Review"), Failure(f"{key} has no transition to the status 'Code Review' from its status 'To Do', only 'Mark as done' to 'Done'"))
|
||||
self.jira.workflow.append({"id": "11", "name": "Start", "to": {"name": "In Progress", "statusCategory": {"key": "indeterminate"}}})
|
||||
self.assertEqual(store.move_issue(key, "Code Review"), Failure(f"{key} has no transition to the status 'Code Review' from its status 'To Do', only 'Mark as done' to 'Done' and 'Start' to 'In Progress'"))
|
||||
self.jira.workflow = []
|
||||
self.assertEqual(store.move_issue(key, "Code Review"), Failure(f"{key} has no transition to the status 'Code Review' from its status 'To Do', nor any other the account may make"))
|
||||
self.assertEqual(self.jira.transitioned, [])
|
||||
@@ -419,7 +421,10 @@ class Jira(Case):
|
||||
store = self.new_store()
|
||||
key = store.file("ABC-12", "Count the runs.", "", ())
|
||||
transitions = f"{ISSUES}/{key}/transitions"
|
||||
status = f"{ISSUES}/{key}?fields=status"
|
||||
for answers, reason in (
|
||||
({("GET", status): Failure("Jira answered 503")}, f"cannot read {key} to move it: Jira answered 503"),
|
||||
({("GET", status): {"key": key, "fields": {}}}, f"{key} is not in the shape Jira Cloud's REST API version 3 documents: KeyError('status')"),
|
||||
({("GET", transitions): Failure("Jira answered 503")}, f"cannot read {key}'s transitions: Jira answered 503"),
|
||||
({("GET", transitions): {"transitions": [{"id": "21"}]}}, f"Jira answered {key}'s transitions in a shape other than the one it documents"),
|
||||
({("POST", transitions): Failure("Jira answered 400")}, f"cannot move {key} to 'Done': Jira answered 400"),
|
||||
@@ -428,6 +433,19 @@ class Jira(Case):
|
||||
self.jira.answers = answers
|
||||
self.assertEqual(store.move_issue(key, "Done"), Failure(reason))
|
||||
|
||||
def test_a_move_says_which_issue_jira_cannot_read_and_refuses_one_outside_the_epic(self) -> None:
|
||||
store = self.new_store()
|
||||
child = store.file("ABC-12", "Count the runs.", "", ())
|
||||
task = store.file(child, "Count them in the api.", "", ())
|
||||
self.jira.issues.append({"key": "ABC-61", "fields": {"summary": "Other.", "description": None, "labels": [], "assignee": None, "status": TO_DO, "parent": None, "issuelinks": []}})
|
||||
self.assertEqual(store.move_issue("ABC-61", "Done"), Failure("ABC-61 is not one of the child issues of the epic ABC-12, so it cannot be moved"))
|
||||
self.jira.answers[("GET", f"{ISSUES}/{task}?fields=parent,status")] = Failure("Jira answered 503")
|
||||
self.assertEqual(store.move_issue(task, "Done"), Failure(f"cannot read {task} to move it: Jira answered 503"))
|
||||
del self.jira.answers[("GET", f"{ISSUES}/{task}?fields=parent,status")]
|
||||
self.jira.answers[("GET", f"{ISSUES}/{child}?fields=parent,status")] = Failure("Jira answered 503")
|
||||
self.assertEqual(store.move_issue(task, "Done"), Failure(f"cannot read {child} to move its sub-task: Jira answered 503"))
|
||||
self.assertEqual(self.jira.transitioned, [])
|
||||
|
||||
def test_finishes_an_issue_by_the_transition_the_settings_name(self) -> None:
|
||||
store = self.new_store()
|
||||
key = store.file("ABC-12", "Count the runs.", "", ())
|
||||
|
||||
@@ -170,7 +170,7 @@ class ConfigTest(unittest.TestCase):
|
||||
def test_refuses_a_pull_request_status_that_is_no_name_and_a_merged_one_that_does_not_unblock(self) -> None:
|
||||
self.write(SETTINGS + 'jira-pull-request-open-status = " "\njira-pull-request-merged-status = 5\n')
|
||||
self.assertIn("`jira-pull-request-open-status` is ' ', not the name Jira shows, such as \"Code Review\"; `jira-pull-request-merged-status` is 5, not the name Jira shows, such as \"Release Ready\"", self.failure())
|
||||
for unblocking in ("", 'jira-unblocking-statuses = ["Shipped"]\n'):
|
||||
for unblocking in ("", 'jira-unblocking-statuses = ["Shipped"]\n', "jira-unblocking-statuses = 5\n"):
|
||||
with self.subTest(unblocking=unblocking):
|
||||
self.write(SETTINGS + unblocking + 'jira-pull-request-merged-status = "Release Ready"\n')
|
||||
self.assertIn("`jira-pull-request-merged-status` is 'Release Ready', so `jira-unblocking-statuses` must list it: an issue at any other status reads as open, and its chunk would start again", self.failure())
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -470,18 +470,21 @@ class TheFirstPrompt(unittest.TestCase):
|
||||
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", config)
|
||||
self.assertIn("The chunk's pull request goes into the epic's working branch `epic/ABC-12`, not into the default branch", task)
|
||||
self.assertIn("make the chunk's worktree and branch off `origin/epic/ABC-12`", task)
|
||||
self.assertIn("`chunk-pr merge` merges into `epic/ABC-12` without waiting for a person", task)
|
||||
self.assertIn("`chunk-pr merge` merges into `epic/ABC-12` without waiting for a person. Where the chunk's tests run", task)
|
||||
self.assertNotIn("leaves the pull request ready for a person to merge", task)
|
||||
self.assertIn("Where the chunk's tests run other repos of the epic, run each at its branch `epic/ABC-12` where it has one, else at its default branch, and name in the chunk's summary each repo that ran at its default branch.", task)
|
||||
self.assertNotIn("chunk-pr push", task)
|
||||
self.assertIn(f"{chunk_prompt.shipping(config)} {chunk_prompt.epic_branch_rule(config, 'ABC-12')} Its summary: ", task)
|
||||
|
||||
def test_a_repo_whose_reviewer_is_asked_by_a_comment_is_told_to_push_with_chunk_pr(self) -> None:
|
||||
config = dataclasses.replace(CONFIG, epic_branch="{epic}", review_request_comment="@reviewbot review")
|
||||
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", config)
|
||||
self.assertIn("After `chunk-pr ready`, push each commit with `chunk-pr push`, which asks the repo's auto-reviewer to review the new head, and wait for that review.", task)
|
||||
self.assertIn("`chunk-pr merge` merges into `ABC-12` without waiting for a person. After `chunk-pr ready`, push each commit with `chunk-pr push`, which asks the repo's auto-reviewer to review the new head, and wait for that review. Where the chunk's tests run", task)
|
||||
|
||||
def test_a_repo_without_an_epic_branch_is_told_nothing_of_one(self) -> None:
|
||||
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", dataclasses.replace(CONFIG, merge="human"))
|
||||
config = dataclasses.replace(CONFIG, merge="human")
|
||||
task = chunk_prompt.task(issue("ABC-20"), "ABC-12", {}, "/code/api", pathlib.Path("/b/do-epic"), "Swedish", config)
|
||||
self.assertEqual(chunk_prompt.epic_branch_rule(config, "ABC-12"), "")
|
||||
self.assertNotIn("working branch", task)
|
||||
self.assertIn("leaves the pull request ready for a person to merge", task)
|
||||
|
||||
|
||||
@@ -125,6 +125,18 @@ class Levelled(unittest.TestCase):
|
||||
self.assertEqual(levelled("ABC-1", "origin/main", run=scripted(calls, push=declined)), declined)
|
||||
self.assertEqual([args[0] for args in calls], ["fetch", "rev-parse", "rev-list", "merge-tree", "commit-tree", "push"] * 2)
|
||||
|
||||
def test_every_call_to_origin_stops_after_the_timeout_given(self) -> None:
|
||||
for answers, origin_calls in (({"rev_parse": Failure("git rev-parse: no such ref")}, ["fetch", "push", "fetch"]), ({"push": Failure("git push: rejected")}, ["fetch", "push", "fetch", "push"])):
|
||||
with self.subTest(origin_calls=origin_calls):
|
||||
timed: list[tuple[str, float | None]] = []
|
||||
answering = scripted([], **answers)
|
||||
|
||||
def run(*args: str, cwd: str | None = None, timeout: float | None = None, guarded: bool = False, errors: str = "strict") -> str | Failure:
|
||||
timed.append((args[0], timeout))
|
||||
return answering(*args, cwd=cwd, timeout=timeout, guarded=guarded, errors=errors)
|
||||
levelled("ABC-1", "origin/main", timeout=5, run=run)
|
||||
self.assertEqual([(name, timeout) for name, timeout in timed if name in ("fetch", "push")], [(name, 5) for name in origin_calls])
|
||||
|
||||
|
||||
class ChunkBase(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
@@ -146,6 +158,20 @@ class ChunkBase(unittest.TestCase):
|
||||
self.assertIsNone(git_repo.chunk_base(cwd=str(self.clone)))
|
||||
self.assertEqual(git_repo.default_ref(cwd=str(self.clone)), "origin/main")
|
||||
|
||||
def test_a_guarded_read_of_the_recorded_base_runs_every_git_call_guarded(self) -> None:
|
||||
calls: list[tuple[tuple[str, ...], bool]] = []
|
||||
answers = {"remote": "origin\n", "symbolic-ref": "ABC-2\n", "config": "ABC-1\n"}
|
||||
|
||||
def run(*args: str, cwd: str | None = None, timeout: float | None = None, guarded: bool = False, errors: str = "strict") -> str | Failure:
|
||||
calls.append((args, guarded))
|
||||
return answers[args[0]]
|
||||
self.assertEqual(git_repo.default_ref(guarded=True, run=run), "origin/ABC-1")
|
||||
self.assertEqual(calls, [(("remote",), True), (("symbolic-ref", "--quiet", "--short", "HEAD"), True), (("config", "--get", "branch.ABC-2.chunk-base"), True)])
|
||||
|
||||
def test_a_base_git_cannot_record_fails_with_gits_reason(self) -> None:
|
||||
refused = Failure("git config branch.ABC-2.chunk-base ABC-1: could not lock config file")
|
||||
self.assertEqual(git_repo.record_chunk_base("ABC-2", "ABC-1", run=lambda *args, **more: refused), refused)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -290,6 +290,8 @@ class LoadTest(ConfigCase):
|
||||
self.assertIn("`review-request-comment` is ' ', not one line of text", self.failure())
|
||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = "--help"\n')
|
||||
self.assertIn("`review-request-comment` is '--help', not one line of text that doesn't start with `-`", self.failure())
|
||||
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = "@coderabbitai\\nreview"\n')
|
||||
self.assertIn("`review-request-comment` is '@coderabbitai\\nreview', not one line of text", self.failure())
|
||||
|
||||
def test_a_jira_plan_may_name_the_transition_and_status_that_finish_an_item(self) -> None:
|
||||
self.write("acme", JIRA_CLIENT)
|
||||
|
||||
Reference in New Issue
Block a user