Cover the mutation sites the suite never reached.

git status can fail after rev-parse succeeds, and that empty-stderr
message was never executed. A non-numeric LCOV branch count never
reaches the hit check, so the dead handler is gone and the record
ignores it. JaCoCo's missing counter field and the Go report paths
were split onto lines the coverage report records. A callback stored
in a binding or passed to new stays inside its function, and an npm
coverage script does not install Vitest. mutator --mutate-all on the
changed Python files: 709 killed, 0 survived, 0 uncovered.

Co-authored-by: Robert C. Martin <[email protected]>
This commit is contained in:
Cursor Agent
2026-11-26 00:11:55 +00:00
co-authored by Robert C. Martin
parent c0ba1e13ba
commit 8e491a636a
5 changed files with 67 additions and 12 deletions
+10
View File
@@ -273,6 +273,16 @@ def test_changed_files_follow_git_status(tmp_path, monkeypatch, capsys):
_changed_files(tmp_path)
assert silent.value.code == 128
def status_fails(args, **kwargs):
if "rev-parse" in args:
return _Completed(0, f"{tmp_path.resolve()}\n")
return _Completed(1, "", "")
monkeypatch.setattr("crapper.cli.subprocess.run", status_fails)
with pytest.raises(GitError, match="git status failed") as status:
_changed_files(tmp_path)
assert status.value.code == 1
def test_relative_paths_are_resolved_under_the_project_root(tmp_path):
_write(tmp_path, "src/demo/core.clj", "(ns demo.core)\n\n(defn choose [x]\n (if x 1 0))\n")
+7
View File
@@ -58,6 +58,13 @@ def test_lcov_branch_records_override_line_hits():
assert bundle.percent_for(scored) == 50.0
def test_a_branch_count_that_is_not_a_number_is_ignored():
text = "SF:src/demo/app.ts\nDA:3,1\nBRDA:3,0,0,nope\nend_of_record\n"
parsed = parse_lcov(text)["src/demo/app.ts"]
assert parsed[3] == (1, 1)
assert 3 not in parsed.branches
def test_a_branchless_span_keeps_line_coverage():
text = "SF:src/demo/app.ts\nDA:2,1\nDA:3,0\nBRDA:8,0,0,1\nBRDA:8,0,1,0\nend_of_record\n"
bundle = CoverageBundle(lcov=parse_lcov(text))
+20
View File
@@ -76,6 +76,26 @@ def test_existing_coverage_script_is_left_alone(tmp_path):
assert command == ["npm", "run", "coverage"]
def test_an_npm_coverage_script_does_not_install_a_provider(tmp_path, monkeypatch):
_write(
tmp_path,
"package.json",
json.dumps({"scripts": {"coverage": "vitest run --coverage"}}),
)
source = _write(tmp_path, "src/app.ts", "export function view() { return 1 }\n")
commands = []
monkeypatch.setattr(
"crapper.runners.run_shell",
lambda command, cwd: commands.append(list(command)) or 0,
)
monkeypatch.setattr(
"crapper.runners._ensure_vitest_coverage",
lambda package: (_ for _ in ()).throw(AssertionError(package)),
)
assert run_coverage(tmp_path, [source], None) == 0
assert commands == [["npm", "run", "coverage"]]
def test_node_test_script_still_uses_c8(tmp_path):
_write(tmp_path, "package.json", json.dumps({"scripts": {"test": "node --test"}}))
report_dir = tmp_path / "target" / "coverage" / "typescript"
+14
View File
@@ -69,6 +69,20 @@ export function text() {
]
def test_a_callback_outside_a_call_stays_inside_its_function():
source = """
export function outer(flag: boolean) {
const local = (n: number) => (n > 0 ? 1 : 0);
if (flag) return new Handler((req) => (req.ok ? 1 : 0));
return 0;
}
"""
functions = functions_in_source(source, "src/demo/box.ts", "/proj")
assert [(fn.namespace, fn.name, fn.complexity) for fn in functions] == [
("demo.box", "outer", 4)
]
def test_express_handlers_are_entries_and_leave_the_parent():
source = """
export function mount(app) {