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