Repository navigation
Releases
Releases · mutastic/mutastic-swift
v1.5.0
Card changes
- A suggested test for a condition made always true is named for its edge. For
if total >= 30,
the test of an order below it isloyaltyCreditJustBelowTheTotalEdge, not
loyaltyCreditWithTotal29, as the other editions name it: the mutant's operands are its
comparison's sides,totaland30, where they were empty. - A suggested test for an XCTest file says to add
import Testing. The test a card writes is a
Swift Testing@Test, and a file that imports only XCTest doesn't build with it pasted in. Its
place now says so, as the Rust edition's says when a#[cfg(test)] mod testsis to be added:
// in Tests/PricingTests/PricingTests.swift, adding import Testing.
Scoring changes
- A catch by a test that depends on its order counts only if the test fails alone with the
mutant too. Swift Testing runs a process's tests side by side, in an order that differs from
run to run, so a test that fails after another has run (swift-log's, once its global logger is
set up) failed in some mutants' runs whatever the mutant did: an equivalent mutant read as caught
about one run in seven. Once the tests are listed, the suite now runs once one test at a time
with no mutant in, and when tests fail there the run says so:tests depend on order: 23 fail when run one at a time in declaration order (…), so a catch by one of them counts only if it fails alone with the mutant too. A mutant's failure by one of those tests that passes alone
with the mutant in is dropped; the test isn't named flaky, and its other catches stand. Each
drop is a line inruns/swift-testing/order.log. Scores can fall where such catches were false;
a package whose suite passes one at a time runs nothing more. - A statement on a line with others after it,
{ x += 1; return x }, now gets its mutants. Its
arm took the statement's;with it, leaving the next statement on the line unseparated, so its
mutants didn't compile and were skipped as unviable. The;now stays after the arm. Those
mutants now run and count, so a score with them can move; in the corpus, swift-collections has
four, all on one line. - A comparison inside a guard that its sides differ is skipped as equivalent, as the Java and
Rust editions skip it. Afterguard distance != 0 else { return i },distance > 0made
distance >= 0differs only whendistanceis 0, which the guard rules out, so it's skipped with
its reason (equivalent: differs only when distance is 0. That can't happen because the guard distance != 0 before it rules it out.), and so is any other change to that comparison that
differs only when its sides are equal. The guard can be theiforguardaround or before it,
theelseof anif a == b, anif a == bbefore it that leaves, an earlier condition of the
sameif, or the left of an&&or||. Each side must be an integer literal, or a whole number
that can't change: a parameter or aletwith its integer type written, bound once, or alet
stored property. On the corpus it skips 13 mutants in swift-algorithms, 9 in swift-collections
and 2 in swift-protobuf, none of them caught before. - A boundary where both sides give the same value at the edge is skipped as equivalent, as the
Java and Rust editions skip it. Inif x > largest { largest = x },>made>=stores, at
x == largest, the value already there, and ina < b ? a : beither side is the same there, so
the mutant is skipped (equivalent: both sides give the same value at the edge). The comparison
must be the whole condition of anifor a?:, deciding one thing: an assignment of one side to
the other, or one side in each branch. Each side must be an integer literal or a whole number of
a type the source writes, and the side stored to a local, a parameter or a stored property no
observer, wrapper or subclass sees written. Swift code mostly callsminandmaxfor this: on
the corpus it skips none. - A comparison of an unsigned value with 0 is skipped as equivalent where it can't differ, as
the Java and Rust editions skip it.n == 0maden <= 0,n > 0maden != 0andn >= 0
made always true differ only whennis below 0, which aUIntnever is, so each is skipped with
its reason (equivalent: differs only when n is below 0. That can't happen because `n` is a `UInt`.). The value must be one the source proves unsigned: a type writtenUIntorUInt8to
UInt64(a parameter, a binding or a stored property), a value made one,UInt(x), or arithmetic
on those. A collection'scountisn't proved: a type of the project's own can give it as it
likes. On the corpus it skips 15 mutants in swift-collections, 5 in swift-subprocess, 4 in
swift-nio, 2 each in swift-argument-parser and swift-protobuf, and 1 in swift-service-lifecycle,
none of them caught before.
Additions
mutastic-swift runruns a package's mutants, on Linux. It copies the package, finds its
sites with the site finder, writes every mutant into the copy and settles the build, runs the
tests once unmutated, refusing a red baseline, then once with each mutant live, within a limit
from the baseline's times. It prints a line for each mutant the tests missed and the score, and
exits 1 below the threshold (--threshold=N, 80 unless set). Tests run with the same hash seed
every time, so a dictionary's order can't make a mutant look caught.just run [package]builds
the site finder and the engine and runs it, on the pricing sample unless one is named.mutastic-swift runruns on macOS too. Swift Testing's tests run through Xcode's
swiftpm-testing-helper, given the bundle's binary, with Xcode's frameworks, private ones too,
on its paths; XCTest's throughxcrun xctest, read from stderr, since the helper asked for XCTest
exits 0 having run nothing. Xcode is the onexcode-select -pnames. A mutant whose run starts
none of the tests of a library the baseline ran is not run, never missed, on either platform.
And a run prints a line for each mutant that timed out, as for each it missed.mutastic.yaml, ignores,--onlyandverify. A run readsmutastic.yamlas every edition
does, and runs itsoperators:, or--operators, or the defaults, the Rust edition's where
Swift has the shape (stronger,extendedandalladd the rest). A mutant in
.mutastic/ignores.yamlis skipped with its reason.--onlyruns some mutants by id, and
verifysays of each whether a test catches it now, passing when every one is. Every other
command a card offers names itself as still being built.- A check of a C call's result is arid.
precondition(err == 0, …)afterlet err = pthread_mutex_init(…)checks that the C library didn't fail, which no test can make it do, so
its mutants, and the check's own removal, were misses no test could catch: most of swift-log's
inLocks.swift. They're made and markedarid: only checks a C call's result, and left out of
the score with the other arid mutants. A C call is told by its shape (a free function named in
lower case with an underscore, or a few POSIX names), so a check of Swift's own values stays.
mutastic.yamlnames the rulemutastic:c-results, as the other editions do. - A run is the core's, as the Rust edition's is. The build, the tests run once with no mutant
in while the runtime records which mutants each reaches, then each mutant against only the tests
that reach it, on several workers (--workers, half the cores up to 4 unless set), the check of
each catch, the records the next run compares with, and the report. A mutant no test reaches is
"not covered". Pricing runs 14 tests for its 11 mutants, where it ran 33. - Every command the other editions have runs on Swift.
explain,ignore,next,
mutants,baselineandgatejoinrunandverify, with every option they take,--shard
and--from-shardsamong them. A command that can't find the site finder says where it looked
and how to build it. --atruns the mutants on some lines.run --at=Sources/Pricing/Pricing.swift:12-13, and
mutantswith it, take the mutants a file's lines hold, as every edition does. A line with none
is refused, with the nearest lines that have one and the command that lists them; a file outside
the targets mutastic mutates is named as such.- A package that needs an argument to build gets it. What follows
--on the line goes to
swift build,mutastic run -- -Xswiftc -DPOSTGRES --traits Redis, as doMUTASTIC_BUILD_ARGS
andmutastic.yaml'sbuild:args:when nothing is typed, the first given used whole. An
option that fights how mutastic builds, such as-c release,--tripleor--scratch-path, is
refused by name. The commands mutastic offers end in what was typed; a record of a run with other
arguments is never compared with this one, and shares built with other defines or traits aren't
put together. - A number that only sizes a collection is arid.
colors.reserveCapacity(size * size),
Dictionary(minimumCapacity: n * 2)andData(capacity: n)store the same elements whatever
the number, so its mutants, and those of the arithmetic that works it out, were misses no test
could catch. They're made and markedarid: only sizes a collection's first allocation, the
rulemutastic.yamlnamesmutastic:capacity, as the other editions do. Removing the call
stays counted, as does a number that sizes the contents,Array(repeating:count:)'s. - An Xcode project is run. A directory with an
.xcodeprojor.xcworkspaceand no
Package.swiftis a project: its scheme is the only one with tests for macOS or iOS, or the one
--schemenames, and with several and none named, it names them, each with the command that
chooses it. The targets its tests test are mutated, built onc...