Answer stability round 1: 0 🔴, 3 🟡 (0 misread); mutmut's copy keeps a link to a folder, the README place waits for item 300, and CRLF files are item 530
This commit is contained in:
@@ -46,13 +46,13 @@ class Folder:
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Ended:
|
||||
"""How mutmut's run in a folder ended. found is empty where the folder has no mutant, as none says why, or where mutmut crashed, as crash says how."""
|
||||
"""How mutmut's run in a folder ended. `found` is empty in two cases: the folder has no mutant, and `none` says why; or mutmut crashed, and `crash` says how."""
|
||||
folder: Folder
|
||||
found: dict[str, str] = dataclasses.field(default_factory=dict) # each mutant's status by mutmut's name of it
|
||||
copies: dict[str, str] = dataclasses.field(default_factory=dict) # mutmut's mutants/ copy of each of the folder's files it wrote one for
|
||||
none: str = ""
|
||||
crash: str = ""
|
||||
notes: str = "" # what the run left out, for the report
|
||||
notes: str = "" # the end of the report's line: that no test reaches the mutants, and the tests left out
|
||||
|
||||
|
||||
class Located(typing.NamedTuple):
|
||||
@@ -64,7 +64,7 @@ class Located(typing.NamedTuple):
|
||||
|
||||
|
||||
class Killed(typing.NamedTuple):
|
||||
"""A mutant the tests kill, by mutmut's name of it, with its file's path from the top and the lines it changes."""
|
||||
"""A mutant mutmut reports as caught, by the tests or its type check, by mutmut's name of it, with its file's path from the top and the lines it changes."""
|
||||
path: str
|
||||
name: str
|
||||
change: Change
|
||||
@@ -97,7 +97,8 @@ def killed_by_mutmut(top: str, paths: list[str], run: Run, jobs: int) -> list[Ki
|
||||
killed: list[Killed] = []
|
||||
for path, files in sorted(imported_by_file_name(top, by_folder(top, lines, CONFIGS), CONFIGS).items()):
|
||||
root = os.path.join(top, path)
|
||||
listed = [os.path.relpath(os.path.join(folder, name), root) for folder, _, names in os.walk(root) for name in names]
|
||||
# os.walk lists a link to a folder among the folders and doesn't enter it; the copy keeps it as a link, as it keeps one git lists.
|
||||
listed = [os.path.relpath(os.path.join(folder, name), root) for folder, folders, names in os.walk(root) for name in [*names, *(name for name in folders if os.path.islink(os.path.join(folder, name)))]]
|
||||
ended = mutate_folder(top, path, files, listed, run, jobs)
|
||||
if isinstance(ended, Failure) or ended.crash:
|
||||
return ended if isinstance(ended, Failure) else Failure(f"mutmut in {ended.folder.label} crashed with {ended.crash}")
|
||||
@@ -106,7 +107,7 @@ def killed_by_mutmut(top: str, paths: list[str], run: Run, jobs: int) -> list[Ki
|
||||
|
||||
|
||||
def mutate_folder(top: str, path: str, files: dict[str, frozenset[int]], listed: list[str], run: Run, jobs: int) -> Ended | Failure:
|
||||
"""Runs mutmut over the functions and methods the lines of files fall in, in a scratch copy of the folder at path that holds the files listed."""
|
||||
"""Runs mutmut over the functions and methods that the lines in `files` fall in. It runs in a scratch copy of the folder at `path`, and the copy holds the files in `listed`."""
|
||||
root = os.path.join(top, path)
|
||||
folder = read_folder(root, path, files)
|
||||
if isinstance(folder, Failure):
|
||||
|
||||
@@ -33,11 +33,11 @@ def x_triple__mutmut_2(n):
|
||||
]
|
||||
"""
|
||||
RESULTS = " calc.x_double__mutmut_1: killed\n calc.x_double__mutmut_2: survived\n calc.x_triple__mutmut_1: no tests\n calc.x_triple__mutmut_2: caught by type check\n"
|
||||
# pytest 9.2.0's report of four failed tests, the last on an error the code raised.
|
||||
# pytest 9.2.0's report of three failed tests, the last on an error the code raised.
|
||||
PYTEST_FAILURES = """============================= test session starts ==============================
|
||||
collected 5 items
|
||||
|
||||
test_calc.py .FFFF [100%]
|
||||
test_calc.py ..FFF [100%]
|
||||
|
||||
=================================== FAILURES ===================================
|
||||
_____________________________ TotalTest.test_adds ______________________________
|
||||
@@ -128,6 +128,19 @@ class KilledMutantsTest(unittest.TestCase):
|
||||
self.assertEqual(self.ran[1][0], ["mutmut", "results", "--all", "true"])
|
||||
self.assertEqual(sorted(path.name for path in self.top.iterdir()), ["README.md", "bin"])
|
||||
|
||||
def test_mutmuts_copy_keeps_a_link_to_a_folder_as_a_link(self):
|
||||
(self.top / "bin/shared").mkdir()
|
||||
(self.top / "bin/pkg/fixtures").symlink_to("../shared")
|
||||
links: list[str] = []
|
||||
mutmut = self.mutmut()
|
||||
|
||||
def run(argv: list[str], cwd: str) -> Ran:
|
||||
links.extend(str(path.relative_to(cwd)) for path in pathlib.Path(cwd).rglob("*") if path.is_symlink())
|
||||
return mutmut(argv, cwd)
|
||||
|
||||
killed_mutants(str(self.top), ["bin/pkg/calc.py"], run, 3)
|
||||
self.assertEqual(links[:1], ["pkg/fixtures"])
|
||||
|
||||
def test_a_file_without_a_function_has_no_mutant_and_mutmut_does_not_run(self):
|
||||
self.assertEqual(killed_mutants(str(self.top), ["bin/pkg/empty.py"], self.mutmut(), 3), [])
|
||||
self.assertEqual(self.ran, [])
|
||||
|
||||
@@ -306,7 +306,7 @@ class BenchTest(unittest.TestCase):
|
||||
self.assertEqual(report[0], f"task-bench: base {self.head[:12]}, head {self.head[:12]}. 1 bug, each run 1 time at each side by claude-haiku-5-5 in Claude Code 2.1.330.")
|
||||
self.assertEqual(report[4:6], ["| 1: calc.go:5:11 ARITHMETIC_BASE | base | 1/1 | 40 | 9000 | 52000 | 800 | 3 | 61.5 | 1 |", "| 1: calc.go:5:11 ARITHMETIC_BASE | head | 1/1 | 40 | 9000 | 52000 | 800 | 3 | 61.5 | 1 |"])
|
||||
|
||||
def test_fails_where_the_places_name_no_go_file_of_the_base(self):
|
||||
def test_fails_where_the_places_name_no_go_or_python_file_of_the_base(self):
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
found = main.bench({**self.given, "--base": "main"}, self.env, lambda home: "- `gone.go:1` `Gone`: removed\n- `README.md:1` `Calc`: thin\n", self.home)
|
||||
self.assertEqual(found, Failure("The places the seats found hard don't name any Go or Python file that the base holds, so there is nowhere to plant a bug."))
|
||||
@@ -380,7 +380,7 @@ class BenchTest(unittest.TestCase):
|
||||
# Tests that catch both mutants, at a head benched against itself, where each mutant's line stands.
|
||||
(self.repo / "calc_test.go").write_text(TESTS.replace("calc.go &&", "calc.go && grep -q '2 \\* a' calc.go &&"))
|
||||
self.commit("Tests that catch Twice")
|
||||
# The seed draws from the mutants in the order of their lines.
|
||||
# `drawn` sorts the mutants by path and line before the seed draws, so these stand in for the real ones.
|
||||
mutants = [Mutant("calc.go", line, "", (), ()) for line in (5, 9)]
|
||||
for seed in (1, 2, 3, 4):
|
||||
report = self.bench(**{"--base": "HEAD", "--bugs": "1", "--runs": "1", "--seed": str(seed)})
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
`Bar = 0.1`
|
||||
|
||||
`Next ID = 530`
|
||||
`Next ID = 531`
|
||||
|
||||
## Renamed
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
| 529 | 0.16.0 | 508 | owner | **Document a `task-bench` command for this repo in the README, with an image that holds what its tests need, so each scoring run benches it.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 2 | 0.7 |
|
||||
| 507 | 0.16.0 | | owner | **Bench rebuilding a feature the project shipped: revert its commit at the head, hand Haiku its item tagline, and check with the tests that commit added.** | 3 | 2 | 1 | 4 | 5 | 1.1 by 3 | 0.7 |
|
||||
| 524 | 0.16.0 | | owner | **Write fejkdata's first six bench features, each a spec, acceptance tests in Go and a reference patch that builds it, in the `bench-tasks` folder its config names.** | 3 | 2 | 1 | 4 | 6 | 1.1 by 3 | 0.5 |
|
||||
| 530 | 0.16.0 | | owner | **Plant a mutant in a Python file whose lines end in CRLF.** | 1 | 1 | 1 | 1 | 2 | 1.1 by 1 | 0.4 |
|
||||
| 526 | 0.16.0 | 508 | owner | **Plant bugs for `task-bench` in Rust, from the mutants cargo-mutants kills.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 1 | 0.3 |
|
||||
| 527 | 0.16.0 | 508 | owner | **Plant bugs for `task-bench` in TypeScript, from the mutants Stryker kills.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 1 | 0.3 |
|
||||
| 528 | 0.16.0 | 508 | owner | **Plant bugs for `task-bench` in PHP, from the mutants Infection kills.** | 3 | 2 | 1 | 4 | 4 | 1.1 by 1 | 0.3 |
|
||||
@@ -120,7 +121,7 @@
|
||||
|
||||
A killed mutant is the lines it changes and what it puts in their place, so one planter re-applies Gremlins' and mutmut's alike. Each language has a module that runs its mutation tool and reads its test runner's failure. Rust, TypeScript and PHP are items of their own, each blocked by this one; so is the bench command this repo documents for itself.
|
||||
|
||||
Split from the item for all four languages when a re-score put that at L 4: a milestone is split before it starts, and Python is the one language this repo can check for real.
|
||||
Split from the item for all four languages, which a re-score put at L 4. Python is the one language this repo can check for real.
|
||||
|
||||
### 506. Go over the bench features in each release review: reapply each reference patch, drop a feature that no longer breaks a goal, and add features until they cover the places the seats find hardest.
|
||||
|
||||
@@ -158,6 +159,15 @@ The second part of item 504, which says what a bench feature is and when a run c
|
||||
|
||||
Done when `task-bench` counts a run of each: its acceptance tests fail at fejkdata's base and head and pass with its reference patch. The six land in fejkdata's checkout or its config folder, wherever its `bench-tasks` setting points, so the item changes no file of this repo and carries no `Touches:` list. About 1,000 lines of Go and specs.
|
||||
|
||||
### 530. Plant a mutant in a Python file whose lines end in CRLF.
|
||||
|
||||
mutmut's planter reads a file as text, which turns `\r\n` into `\n`, and the planter re-applies a mutant to the file's bytes split on `\n` alone. So no mutant of a Python file with CRLF line ends ever re-applies, and the bench doesn't say why. A stability review of item 508 reproduced it. Compare the lines without their `\r`, and write the mutant's lines with the line end the file uses.
|
||||
|
||||
Touches:
|
||||
- `bin/task_bench/planted_mutant.py`: `mutated`
|
||||
- `bin/task_bench/python_bugs.py`: `killed_mutants`
|
||||
- `bin/task_bench/test_python_bugs.py`
|
||||
|
||||
### 526. Plant bugs for `task-bench` in Rust, from the mutants cargo-mutants kills.
|
||||
|
||||
cargo-mutants runs over the changed lines only today. Run it over the files that hold the seats' places, at the tree's top without git, and turn each killed mutant into the lines it changes, read from the diffs it writes under `mutants.out`. Tell Haiku the failure `cargo test` prints, without the test's name or file. Check the module against the tool's real output on a small project in a container, since this repo holds no Rust.
|
||||
|
||||
Reference in New Issue
Block a user