Commit Graph
12 Commits
Author SHA1 Message Date
Cursor AgentandRobert C. Martin 0cfa995431 Copy asset catalogs into an Xcode worker.
actool does not follow a symlinked .xcassets, so the worker build fails
with a missing AppIcon and a mutant that still compiles is reported
killed. Copy the catalog, including resources that were themselves
links, and keep linking other files.

Proved by the worker overlay test and a stand-in xcodebuild that
rejects a symlinked catalog. 127 passed, 1 skipped.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 02:49:35 +00:00
Cursor Agent b1d53b0085 Merge Swift region coverage.
A covered llvm-cov region now marks every line from its start through
its end. line_covered keeps a nested zero-count region uncovered.
Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 02:20:21 +00:00
Cursor AgentandRobert C. Martin 9a3d4a353f Count every line of a Swift coverage region.
crapper now reports a region as (start, end, count). The join still
unpacked (line, count), so the Swift coverage tests crashed, and a
mutation on the last line of a covered region was left uncovered.

line_covered decides each line. A nested region with count zero stays
uncovered, and a line in no region stays uncovered. An xccov summary
is unchanged.

The file-wide mutator run then found six older survivors in the path
join. A trailing slash still marks the file, the first of two equal
paths keeps its hits, and a shorter prefix beats a shorter suffix.
Comparisons that could not change a result are gone.

Proved by pytest (125 passed, 1 skipped; swift is not installed).
crapper's worst score besides parse_args is _prepare_coverage at 9.4;
_swift_hits is 6.0. dryer --threshold 0.8 reports no candidates.
mutator on src/mutator/coverage.py killed 49, with 0 survived and 0
uncovered.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 02:20:07 +00:00
Cursor AgentandRobert C. Martin eb14237127 Merge Swift mutation testing.
Swift uses the same operator decisions as Java, plus ?? and negation of
boolean conditions. swift test runs a package. xcodebuild runs an Xcode
or iOS project from the working directory, and the worker keeps a real
copy of the project so the mutant is what gets compiled.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 01:04:35 +00:00
Cursor AgentandRobert C. Martin 8118590503 Kill the Clojure site survivors instead of leaving them.
A reader quote is a quoting_lit, so '(+ 1 0) was not covered by the
(quote ...) test. The skip returned True there and the mutant survived.
A + inside a vector is not a call, a symbol True is not a boolean, and
the anchor of a Clojure site is its own line.

_clojure_text repeated its type check with a child-count clause, and
_is_head's final return never ran because the symbol is a child of its
list. Both are gone.

Proved by the Clojure site tests. mutator on src/mutator/sites.py then
scored 66 killed, 0 survived, 0 uncovered. The suite passes (119 tests,
and the SwiftPM run is skipped because swift is not installed).

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 01:04:26 +00:00
Cursor AgentandRobert C. Martin b494411b07 Compile the Xcode mutant instead of the original project.
xcodebuild was given the absolute path of the real project, and the worker
only symlinked that bundle. The tool realpaths the project, so every mutant
compiled the unmutated tree and survived.

The command now names the project relative to the working directory, which
the worker maps onto its overlay. The overlay copies an .xcodeproj or
.xcworkspace instead of linking it, so realpath stays on the copy that holds
the mutant. A file that only ends in .xcodeproj stays a link.

Proved by a fake xcodebuild that realpaths the project and reads the Swift
file the project names. The comparison and the negated condition are killed,
and a constant survives. The same check uses a workspace. A baseline that
exits 1 records no kills. The tests failed first on an absolute path, then
on a symlink that escaped the worker. The suite passes (118 tests, and the
SwiftPM run is skipped because swift is not installed).

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 00:26:05 +00:00
Cursor AgentandRobert C. Martin b918439902 Kill equivalent Swift mutants and prove a SwiftPM run.
Stopping a guard at else was the same as stopping at the following brace,
and the binding flag started false only to be cleared by the keyword. Those
edits survived because no test could see a difference, so the duplicate
paths are gone. *Tests.swift stays crapper's filename rule; this check only
adds Tests directories.

A tiny package run with swift test records killed and survived on Demo.place
and restores the source. The test skips when swift is not installed. The
full suite, including that run on Swift 6.4.3, passed (115 tests).

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 00:09:27 +00:00
Cursor AgentandRobert C. Martin 883a611b68 Document Swift mutation, discovery, and the Mac test commands.
The README and --help now name Swift with the other languages, list the
operators (including which edits are not made), and say how Tests,
*Tests.swift, .build, .swiftpm, and DerivedData are skipped. They also
give swift test, xcodebuild test, --xcode-scheme, and --xcode-destination,
and say an iOS run needs a Mac with Xcode.

Proved by the help test, which checks that --help names swift test,
xcodebuild, and *Tests.swift.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 00:01:19 +00:00
Cursor AgentandRobert C. Martin 3f6dc5bb7c Read Swift coverage from the reports crapper already parses.
llvm-cov JSON and xccov JSON land in target/coverage/swift. crapper
turns those into regions or function summaries. A region with a hit
marks that line covered. An xccov summary has no lines, so the function
line is covered when the summary's covered count is above zero. A file
missing from the report stays uncovered and is not run.

Proved by tests/test_coverage.py, which failed first because a Swift
file with a report still returned no lines, and by a scan that marks
an unhit line uncovered. The reports are the same JSON shapes crapper
reads; mutator does not parse them itself.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 00:00:50 +00:00
Cursor AgentandRobert C. Martin 7c72d9deba Run swift test or xcodebuild, and keep Swift build output private.
A SwiftPM package is tested with swift test from the directory that
holds Package.swift. An Xcode or iOS project is tested with xcodebuild
test. The scheme is --xcode-scheme, otherwise the first shared scheme,
otherwise the project name. --xcode-destination is one argument, so a
simulator name with spaces is not split. A file inside a package is not
also sent to xcodebuild. iOS still needs a Mac with Xcode; the command
is only constructed here.

Workers no longer link .build, .swiftpm, or DerivedData. A symlink would
make swift test and xcodebuild write the real tree's build products,
and parallel workers would share them.

Proved by tests/test_swift.py. The command tests failed first because
Swift returned false, xcode_destination was not a parameter, and a
worker linked .build. A run with fake swift and xcodebuild on PATH then
showed swift test and xcodebuild test -destination with the scheme.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-26 00:00:21 +00:00
Cursor AgentandRobert C. Martin 23b7d47936 Skip Swift test targets when choosing source files.
crapper treats Tests, AppTests, and *Tests.swift as tests, but mutator
only asked is_test_file about the filename. That kept a file such as
Tests/DemoTests/Board.swift, so a run would mutate the test suite.
.build, .swiftpm, and DerivedData were already SKIP_DIRS.

A Swift path is now a test path when a directory component ends with
Tests, or the file name ends with Tests.swift. A deeper directory named
test, the Java fixture layout, is still mutated.

Proved by the source walk and by selecting Sources/Demo/Box.swift next
to Tests/DemoTests/Board.swift and BoxTests.swift. The walk failed first
because those three Tests paths were still chosen. Both tests pass.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:58:57 +00:00
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