Skip to content

Releases

v1.5.0

Choose a tag to compare

@github-actions github-actions released this 02 Dec 15:00
c4316d1

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 is loyaltyCreditJustBelowTheTotalEdge, not
    loyaltyCreditWithTotal29, as the other editions name it: the mutant's operands are its
    comparison's sides, total and 30, 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 tests is 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 in runs/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. After guard distance != 0 else { return i }, distance > 0 made
    distance >= 0 differs only when distance is 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 the if or guard around or before it,
    the else of an if a == b, an if a == b before it that leaves, an earlier condition of the
    same if, or the left of an && or ||. Each side must be an integer literal, or a whole number
    that can't change: a parameter or a let with its integer type written, bound once, or a let
    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. In if x > largest { largest = x }, > made >= stores, at
    x == largest, the value already there, and in a < b ? a : b either 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 an if or 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 calls min and max for 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 == 0 made n <= 0, n > 0 made n != 0 and n >= 0
    made always true differ only when n is below 0, which a UInt never 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 written UInt or UInt8 to
    UInt64 (a parameter, a binding or a stored property), a value made one, UInt(x), or arithmetic
    on those. A collection's count isn'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 run runs 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 run runs 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 through xcrun xctest, read from stderr, since the helper asked for XCTest
    exits 0 having run nothing. Xcode is the one xcode-select -p names. 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, --only and verify. A run reads mutastic.yaml as every edition
    does, and runs its operators:, or --operators, or the defaults, the Rust edition's where
    Swift has the shape (stronger, extended and all add the rest). A mutant in
    .mutastic/ignores.yaml is skipped with its reason. --only runs some mutants by id, and
    verify says 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, …) after let 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
    in Locks.swift. They're made and marked arid: 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.yaml names the rule mutastic: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, baseline and gate join run and verify, with every option they take, --shard
    and --from-shards among them. A command that can't find the site finder says where it looked
    and how to build it.
  • --at runs the mutants on some lines. run --at=Sources/Pricing/Pricing.swift:12-13, and
    mutants with 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 do MUTASTIC_BUILD_ARGS
    and mutastic.yaml's build: args: when nothing is typed, the first given used whole. An
    option that fights how mutastic builds, such as -c release, --triple or --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) and Data(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 marked arid: only sizes a collection's first allocation, the
    rule mutastic.yaml names mutastic: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 .xcodeproj or .xcworkspace and no
    Package.swift is a project: its scheme is the only one with tests for macOS or iOS, or the one
    --scheme names, 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...
Read more