Swiftpack.co - Package - mattpolzin/swift-test-codecov

swift-test-codecov

I'm writing this because tooling that can ingest the code coverage report produced by swift test --enable-code-coverage is shockingly hard to find.

Usage

Library

The library has a pretty small and straight forward interface. I have not had time to write about it here in the README, but taking a look at how the executable target uses the library target should be pretty informative.

Tool

swift-test-codecov <codecov-filepath> [--metric <metric>] [--minimum <minimum-coverage>] [--table] [--sort <sort>] [--dependencies]

ARGUMENTS:
  <codecov-filepath>      the location of the JSON file output by `swift test --enable-code-coverage`. 
        You will find this in the build directory.

        For example, if you've just performed a debug build, the file will be located at
        `./.build/debug/codecov/<package-name>.json`.

OPTIONS:
  -m, --metric <metric>   The metric over which to aggregate. One of lines, functions, instantiations (default: lines)
  -v, --minimum <minimum-coverage>
                          The minimum coverage allowed. A value between 0 and 100. Coverage below the minimum will result in
                          exit code 1. (default: 0)
  -t, --table             Prints an ascii table of coverage numbers. 
  -s, --sort <sort>       Set the sort order for the coverage table. One of filename, +cov, -cov (default: filename)
  -d, --dependencies      Include dependencies in code coverage calculation. 
  -h, --help              Show help information.

Building Docker Image

Run docker build -t swift-test-codecov . to build the docker image.

Github

link
Stars: 4

Dependencies

Used By

Total: 0

Releases

Add option to sort coverage table. -

Adds an option to sort the coverage table by filename (default) or ascending or descending coverage percent.

Also moves to the latest version of Argument Parser.

Bumps Argument Parser dependency to latest version. -

Thanks to @cgrindel for updating the executable to support the latest version of Argument Parser.

Fix compilation prior to Swift 5.2 -

I had used some Swift 5.2 syntax -- fixed in this release!

Thanks to @justAnotherDev for the fix.

Switch Argument Parser, combine table outputs. -

Switches to using Swift Argument Parser library.

Combines the output of the two tables (source file coverage and test file coverage) into one table with a divider line.

Add Dockerfile -

Fix folder name casing. -

Added option to include dependencies -

Added flag --dependencies that tells the app to include package dependencies in code coverage calculations. :warning: By default, this flag will be off, making this a divergence from the previous default behavior.

Swift Tools 5.1 required, fixed for Swift 5.1 test coverage files -

Add --table flag. -

Use the new --table flag to print a table with all test coverage numbers by file.

Use the new --metric flag to choose a metric other than the default (line count).

Initial Release. Just dumps overall test coverage by line count. -