Skip to content

Commit a572065

Browse files
committed
Swift Test: Add HTML coverage report
Currently, `swift test` supports generating a JSON coverage report, which is great for ingesting into various systems. The JSON coverage report generation is processed by `llvm-cov`` where SwiftPM is simply orchestrating the command line invocation. The JSON, however, is not very "human consumable friendly" while iterating at-desk. This change adds an additional command line argument to swift test that allows specify whether to generate a JSON or HTML report. Selecting HTML will produce a `llvm-cov`` HTML report, that is more easily consumable by a developer at desk. Similar to the JSON coverage report, Swift Package Manager is only responsible for constructing the command line argument that will be passed to `llvm-cov``, which will produce the HTML report. Since `llvm-cov show` (which would produce the HTML) has numerous CLI arguments that allows configurations of the HTML report, this change supports a response file for configuring the `llvm-cov show` command. The response file is accessible from the Swift Package project.
1 parent 399ac4a commit a572065

File tree

8 files changed

+1095
-48
lines changed

8 files changed

+1095
-48
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--tab-size=10
2+
--coverage-watermark=80,20
3+
--enable-vtable-value-profiling
4+
--show-branch-summary
5+
--show-region-summary
6+
--show-branches=percent
7+
--show-mcdc-summary
8+
--show-expansions
9+
--show-instantiations
10+
--show-regions
11+
--show-directory-coverage
12+
--show-line-counts

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
11041104
// The 'swift-argument-parser' version declared here must match that
11051105
// used by 'swift-driver' and 'sourcekit-lsp'. Please coordinate
11061106
// dependency version changes here with those projects.
1107-
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.5.1")),
1107+
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.6.1")),
11081108
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "3.0.0")),
11091109
.package(url: "https://github.com/swiftlang/swift-syntax.git", branch: relatedDependenciesBranch),
11101110
.package(url: "https://github.com/apple/swift-system.git", from: "1.1.1"),

Sources/Commands/SwiftBuildCommand.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ struct BuildCommandOptions: ParsableArguments {
7676
var buildTests: Bool = false
7777

7878
/// Whether to enable code coverage.
79-
@Flag(name: .customLong("code-coverage"),
80-
inversion: .prefixedEnableDisable,
81-
help: "Enable code coverage.")
79+
@Flag(
80+
name: [
81+
.customLong("codecov"),
82+
.customLong("code-coverage"),
83+
.customLong("coverage"),
84+
],
85+
inversion: .prefixedEnableDisable,
86+
help: "Enable code coverage.",
87+
)
8288
var enableCodeCoverage: Bool = false
8389

8490
/// If the binary output path should be printed.

0 commit comments

Comments
 (0)