diff --git a/bin/chunk_preflight/test_indentation.py b/bin/chunk_preflight/test_indentation.py index 8eedaaa6..340d3ad4 100644 --- a/bin/chunk_preflight/test_indentation.py +++ b/bin/chunk_preflight/test_indentation.py @@ -62,7 +62,7 @@ class SpaceIndentation(unittest.TestCase): def test_counts_only_the_first_code_files_git_lists(self): first = {f"a{number:03}.py": TABBED for number in range(SAMPLE)} self.assertIsNone(space_indented(self.checkout(**first, **{"b1.py": SPACED * 400}))) - self.assertIsNone(space_indented(self.checkout(**{f"a{number:03}.py": SPACED for number in range(SAMPLE + 1)}, **{".editorconfig": "indent_style = space\n"}))) + self.assertIsNone(space_indented(self.checkout(**{f"a{number:03}.py": SPACED for number in range(SAMPLE + 1)}, **{"z__.editorconfig": "indent_style = space\n"}))) def test_stays_silent_for_a_repo_without_code(self): self.assertIsNone(space_indented(self.checkout(**{"README.md": SPACED, "data.json": SPACED, "ci.yml": SPACED}))) diff --git a/bin/task_bench/main.py b/bin/task_bench/main.py index fe8fa4fd..467ed46b 100644 --- a/bin/task_bench/main.py +++ b/bin/task_bench/main.py @@ -591,8 +591,8 @@ def rust_tests_of(bench: Bench) -> RustTests: return on_disk("read the Rust files", lambda: [rust_test_files(tree) for tree in bench.trees.values()]) -def planted(bench: Bench, number: int, mutant: Mutant, rust_tests: typing.Callable[[], RustTests] | None = None) -> Task | Failure | None: - """The task of fixing mutant, with its planted tree at each side; None where the mutant doesn't become a bug at one side or the other. rust_tests is what `rust_tests_of` finds for bench, read from the trees where the caller hands none.""" +def planted(bench: Bench, number: int, mutant: Mutant, rust_tests: typing.Callable[[], RustTests]) -> Task | Failure | None: + """The task of fixing mutant, with its planted tree at each side; None where the mutant doesn't become a bug at one side or the other. rust_tests reads what `rust_tests_of` finds for bench.""" diff = bench.git("diff", "-U0", "--no-color", "--no-ext-diff", "--no-textconv", bench.sides["base"], bench.sides["head"], "--", mutant.path, cwd=bench.checkout, errors="replace") if isinstance(diff, Failure): return diff @@ -605,7 +605,7 @@ def planted(bench: Bench, number: int, mutant: Mutant, rust_tests: typing.Callab return None # ... and the Rust test files of each side's tree, which it keeps only where it finds every one. A mutant in one of them is no bug. if mutant.path.endswith(".rs"): - standing = (rust_tests or functools.partial(rust_tests_of, bench))() + standing = rust_tests() if isinstance(standing, Failure): return standing if any(tests is None or mutant.path in tests for tests in standing): diff --git a/bin/task_bench/test_task_bench.py b/bin/task_bench/test_task_bench.py index 62b84276..9205c16a 100644 --- a/bin/task_bench/test_task_bench.py +++ b/bin/task_bench/test_task_bench.py @@ -3,6 +3,7 @@ fix is checked in, and the proxy that reaches only the API.""" import asyncio import contextlib import dataclasses +import functools import io import json import os @@ -96,6 +97,10 @@ NAME, USER = "task-bench-0123456789ab", "1234:5678" PLACES = "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\nJunior A, hardest first:\n\n- `calc.go:3` `Add`: long\n- `gone.go:1` `Gone`: removed since\n- `README.md:1` `Calc`: thin\n" +def planted(bench, mutant): + return main.planted(bench, 1, mutant, functools.partial(main.rust_tests_of, bench)) + + class BenchTest(unittest.TestCase): def setUp(self): folder = tempfile.TemporaryDirectory() @@ -547,11 +552,11 @@ class RunOutcomesTest(unittest.TestCase): def test_a_mutant_whose_tests_run_out_of_time_is_passed_over(self): late = TimedOut("docker run still ran after 30 min") - self.assertIsNone(main.planted(self.bench(late), 1, self.MUTANT)) + self.assertIsNone(planted(self.bench(late), self.MUTANT)) def test_a_mutant_whose_tests_docker_could_not_run_fails_the_bench(self): broke = Failure("docker could not start: No such file or directory") - self.assertEqual(main.planted(self.bench(broke), 1, self.MUTANT), broke) + self.assertEqual(planted(self.bench(broke), self.MUTANT), broke) def assertFailsWith(self, found, start: str): self.assertIsInstance(found, Failure) @@ -595,7 +600,7 @@ class RunOutcomesTest(unittest.TestCase): assert_not_root(self) (self.tree / "calc.go").chmod(0) self.addCleanup((self.tree / "calc.go").chmod, 0o644) - self.assertFailsWith(main.planted(self.bench(), 1, self.MUTANT), "could not read calc.go: ") + self.assertFailsWith(planted(self.bench(), self.MUTANT), "could not read calc.go: ") def test_a_digest_quoting_half_of_a_surrogate_pair_is_written_with_a_question_mark_in_its_place(self): # Claude Code may cut a string between the halves of an emoji's pair, and JSON parses the half it keeps into a lone surrogate. @@ -607,12 +612,12 @@ class RunOutcomesTest(unittest.TestCase): head = self.folder / "head" head.mkdir() bench = dataclasses.replace(self.bench(), trees={"base": str(self.tree), "head": str(head)}) - self.assertIsNone(main.planted(bench, 1, self.MUTANT)) + self.assertIsNone(planted(bench, self.MUTANT)) def test_a_rust_mutant_in_a_file_whose_test_module_cannot_be_told_apart_is_passed_over(self): (self.tree / "lib.rs").write_text("pub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n#[cfg(test)]\nmod tests {\n") mutant = Mutant("lib.rs", 2, "lib.rs:2:7 replace + with -", (b" a + b",), (b" a - b",)) - self.assertIsNone(main.planted(self.bench(), 1, mutant)) + self.assertIsNone(planted(self.bench(), mutant)) def rust_bench(self, files: dict[str, str], *runs: Ran | Failure) -> main.Bench: for path, text in files.items(): @@ -626,21 +631,22 @@ class RunOutcomesTest(unittest.TestCase): def test_a_rust_mutant_in_a_test_file_of_its_own_is_passed_over(self): bench = self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": "fn t() { assert!(1 + 1 == 2); }\n"}) mutant = Mutant("src/tests.rs", 1, "src/tests.rs:1:20 replace + with -", (b"fn t() { assert!(1 + 1 == 2); }",), (b"fn t() { assert!(1 - 1 == 2); }",)) - self.assertIsNone(main.planted(bench, 1, mutant)) + self.assertIsNone(planted(bench, mutant)) def test_a_rust_mutant_in_a_tree_whose_declared_test_file_is_not_found_is_passed_over(self): - self.assertIsNone(main.planted(self.rust_bench({"src/lib.rs": self.ADD}), 1, self.ADDING)) + self.assertIsNone(planted(self.rust_bench({"src/lib.rs": self.ADD}), self.ADDING)) def test_a_rust_mutant_in_code_beside_a_test_file_goes_on_to_the_tests(self): broke = Failure("docker could not start: No such file or directory") - self.assertEqual(main.planted(self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": ""}, broke), 1, self.ADDING), broke) + self.assertEqual(planted(self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": ""}, broke), self.ADDING), broke) def test_a_rust_mutant_in_a_tree_whose_rust_file_cannot_be_read_fails_the_bench_naming_the_file(self): assert_not_root(self) bench = self.rust_bench({"src/lib.rs": self.ADD, "src/tests.rs": "", "src/other.rs": ""}) (self.tree / "src/other.rs").chmod(0) self.addCleanup((self.tree / "src/other.rs").chmod, 0o644) - self.assertFailsWith(main.planted(bench, 1, self.ADDING), "could not read the Rust files: ") + self.assertFailsWith(planted(bench, self.ADDING), "could not read the Rust files: ") + self.assertFailsWith(main.planted_tasks(bench, [self.ADDING], 1, 1), "could not read the Rust files: ") class ContainersTest(unittest.TestCase):