Skip to content

Commit f17b23d

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 f8451c1 commit f17b23d

File tree

10 files changed

+1600
-115
lines changed

10 files changed

+1600
-115
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
@@ -1108,7 +1108,7 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
11081108
// utils/update_checkout/update-checkout-config.json
11091109
// They are used to build the official swift toolchain.
11101110
.package(url: "https://github.com/swiftlang/swift-syntax.git", branch: relatedDependenciesBranch),
1111-
.package(url: "https://github.com/apple/swift-argument-parser.git", revision: "1.5.1"),
1111+
.package(url: "https://github.com/apple/swift-argument-parser.git", revision: "1.6.1"),
11121112
.package(url: "https://github.com/apple/swift-crypto.git", revision: "3.12.5"),
11131113
.package(url: "https://github.com/apple/swift-system.git", revision: "1.5.0"),
11141114
.package(url: "https://github.com/apple/swift-collections.git", revision: "1.1.6"),

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)