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]>
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.
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.
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.
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.
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.
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.