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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user