Commit Graph
15 Commits
Author SHA1 Message Date
Cursor AgentandRobert C. Martin b52159454d Find Swift mutation sites and join them to crapper's functions.
Swift needs the same operator decisions as Java, plus the ?? fallback
TypeScript already flips, and a negation of boolean conditions so guard
is covered. A logical ! and a unary - are deleted; a force-unwrap is not.
Statements and returns are not removed, because the other languages do
not remove them either. private and fileprivate declarations use defn-/.

A closure crapper does not report stays on the enclosing function, and a
stored closure is its own entry, so the snapshot namespace matches
.metrics/crap.edn.

Proved by tests/test_swift.py. Those tests failed first: only true/false
and 0/1 were sites, private funcs were defn/, and a run exited 0 because
the comparison and the guard negation were missing. They pass, and the
existing suite still passes (101 tests).

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:58:11 +00:00
Robert C. Martin 0136cf5557 Skip test directories only at the project root or under src/test.
Why: crapper.discover treats any test-named folder at any depth as a
test path. That silently skipped production fixtures such as
src/agnesse/slim/test/SymbolManagingTableTable.java, even when the file
was named directly, because "test" appeared in the path.

What: Mutator now walks the tree itself. A path relative to the project
root is a test path when its first component is a TEST_DIRS name (test,
tests, spec, specs, or __tests__), or when it sits under src/test or
src/tests, the Maven and Gradle layout. SKIP_DIRS are still skipped at
any depth. Filename-based test files are still detected by
crapper.discover.is_test_file, applied to the filename so the any-depth
directory check is not reused. crapper itself is unchanged. README and
--help describe the new rule.

Proof: 12 new tests in test_sources.py plus help assertions. 84 tests
were green before; 96 pass now. crapper on the changed files: every new
function is under 10 (iter_source_files 9.0, is_test_path 5.0,
is_mutable_source 5.0); parse_args remains 30.2, the existing
option-parser exception. dryer: no candidates. mutator on sources.py:
25 killed, 0 survived, 0 uncovered. Dry run against /tmp/agn at
58fd81c37: SymbolManagingTableTable.java is discovered along with 54
other files under src/agnesse/slim/test/; no files under test/ are.
2026-11-24 03:22:55 -06:00
Robert C. Martin 29afb42712 Retry worker cleanup when Gradle writes after the client exits.
Why: delete_tree walked the worker tree and called rmdir once. Gradle
can still be flushing a test report then, so a directory that looked empty
raises OSError [Errno 39] Directory not empty (or a file vanishes before
unlink) and the whole mutation run aborts.

What: delete_tree retries the walk, with injectable sleep and attempt
count so tests do not wait. A vanished file is unlinked with
missing_ok. Symlinks are still unlinked, never followed into the real
project.

Proof: six new tests (late file, vanished file, missing path, regular
file, symlink left alone, exhausted retries re-raise). 78 tests were
green before; 84 pass now. crapper: delete_tree 5.0, _delete_once 5.0,
every function in workers.py under 10. dryer: no candidates. mutator on
the nine changed sites: 9 killed, 0 survived, 0 uncovered.
2026-11-18 10:42:45 -06:00
Robert C. Martin 830ec7e9c3 Read Go coverage by module import path, the name go test gives a file.
Why: every Go run printed "No coverage data for <file>; its sites are
uncovered". `go test -coverprofile` keys files by import path
(`github.com/acme/tool/cmd/tool/main.go`); mutator looked them up by
absolute disk path (`/.../tool/cmd/tool/main.go`). Neither path ends with
the other, so no Go file ever matched and only --no-coverage ran sites.

What: `_go_lines` asks crapper's `go_import_name` for the profile's name
of the file (nearest go.mod module line plus path inside the module) and
`_lookup` tries that name as an exact key, then the existing suffix
match. Other languages pass no name and are unchanged. Needs crapper
c757ec7 or later.

Proof: two new specs (module at the root, module in a subdirectory with
a different name) failed with None first, now pass; 78 pass. crapper:
_go_lines 6.0, covered_lines 5.0, _lookup 4.0. dryer: no candidates.
mutator on the changed lines: one equivalent survivor (insert(0) vs
insert(1)) removed by appending the name; no survivors left.
2026-11-10 12:38:11 -06:00
Robert C. Martin a5a0cb803b Count multi-line statement sites as covered from their start line; skip TypeScript type positions 2026-10-21 14:33:45 -05:00
Robert C. Martin c57f03879a Bring every CRAP score under 10 except the option parser.
Rendering, mutation-site rules, coverage ranking, and the per-language test command are each a small function. parse_args stays the option switch.
2026-10-03 18:03:53 -05:00
Robert C. Martin ba4065f3f1 Stop shelling generated test commands and fail closed on git and coverage.
A package path is one argument. Git status uses NUL records and returns git's status. A failed coverage command leaves reports unread, coverage keeps the longest path match, and site walks no longer recurse.
2026-10-03 17:48:32 -05:00
Robert C. Martin 1bad4b908a Mutate ?? and ?. in TypeScript and JavaScript, including Express handlers. 2026-10-03 08:49:10 -05:00
Robert C. Martin 72b7581a37 Add the Zero-Clause BSD license. 2026-10-03 08:48:27 -05:00
Robert C. Martin bb9262a7b1 Record the bug where Python tests ran in mutator's virtualenv. 2026-10-02 10:36:31 -05:00
Robert C. Martin b35a9caf6f Run Python tests with the project's virtualenv.
Mutator's interpreter does not have the project installed, so the baseline failed before any mutant ran.
2026-10-02 10:29:11 -05:00
Robert C. Martin 4a9d0c0a5c Copy relative importers into the worker so Node loads the mutant.
Node resolves a relative import from the real path of the module. A symlinked test was loading the original source, so every mutant survived. Modules that reach the file under test are now real copies in the overlay.
2026-10-01 10:46:47 -05:00
Robert C. Martin 21d6d6f50b Run a file's mutants at the same time in symlink overlays.
Each worker keeps a private copy of the file under test and links the rest of the project, so the original tree stays put. The default is one worker per core, and --max-workers can set a lower cap.
2026-09-30 15:23:42 -05:00
Robert C. Martin 63fe452adb Add tests that kill the mutation survivors the suite can reach.
A self-run left covered gaps and live mutants. These cases exercise the real boundaries and leave equivalent mutants and lines coverage cannot see.
2026-09-30 14:39:16 -05:00
Robert C. Martin bf42bd22e7 Add a multi-language mutation tester that writes .metrics/mutate for uml-viewer. 2026-09-30 10:40:54 -05:00