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