Skip to content

Commit a8b81a8

Browse files
committed
updates.. still need to clean up
1 parent 3e7eec0 commit a8b81a8

File tree

1 file changed

+82
-52
lines changed

1 file changed

+82
-52
lines changed

proposals/0501-swiftpm-html-coverage-report.md

Lines changed: 82 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,6 @@ make use of LLVM's tools and construct the proper command line arguments to the
7070

7171
The proposted command line changes are as follows:
7272

73-
### Consolidate coverage option to use same argument "style"
74-
75-
Prior to this feature, there are 2 coverage options
76-
77-
```
78-
--show-codecov-path, --show-code-coverage-path, --show-coverage-path
79-
Print the path of the exported code coverage JSON
80-
--enable-code-coverage/--disable-code-coverage
81-
Enable code coverage. (default:
82-
--disable-code-coverage)
83-
```
84-
85-
There are 3 ways to show the coverage path. This proposal recommends to modify all
86-
coverage command line option to be a single, more useful option
87-
88-
```
89-
--show-coverage-path
90-
Print the path of the exported code coverage JSON
91-
--enable-coverage/--disable-coverage
92-
Enable code coverage. (default:
93-
--disable-coverage)
94-
```
95-
96-
This requires gracefully phasing out the previous option in favour of the new one.
97-
9873
### Format Selection
9974

10075
The `swift test` command line will have an option named `--coverage-format`,
@@ -114,45 +89,47 @@ The command line option will be similar to:
11489

11590
### Coverage Report configuration
11691

117-
`llvm-cov show` has several report configurability options. In order to
118-
prevent a "command line arguments" explosion to `swift test`, the configuration
119-
options will be read from a response file. The optional response file will be
120-
located in `<repo>/.swiftpm/configuration/coverage.html.report.args.txt`, which
121-
is the same location used by other SwiftPM features, such as registration and
122-
mirros configuration files. The response file will be supported.
92+
`llvm-cov show` has several report configurability options. In order to allow
93+
for HTML coverage report customization, and to prevent a "command linearguments"
94+
explosion to `swift test`, a `-Xcov` command line option will be added. These
95+
argument will be passed directly to the underlying `llvm-cov` executable in the
96+
order they appear.
97+
98+
Since multiple coverage report can be specified in a single `swift test` invocation,
99+
we must provide a way to ensure which argument is passed to one format, and not the other.
123100

124-
The user can include `--format=text`, or a variation thereof, in the response
125-
file. In order to ensure SwiftPM will always generate an HTML report, SwiftPM
126-
will add `--format=html` after the response file argument to ensure `llvm-cov`
127-
will generate an HTML report.
101+
Take this example
128102

103+
```
104+
swift test --enable-coverage --coverage-format html --coverage-format json -Xcov --title -Xcov "My title"
105+
```
106+
107+
The `-Xcov` arguments are ony supported when generating the HTML report. The value of `-Xcov` will have the following syntax
108+
109+
```
110+
-Xcov [<coverage-format>=]<value>
111+
```
112+
113+
Here are some examples:
114+
115+
- `-Xcov html=--title`: argument `--title` is only sent to the HTML coverage report generation
116+
- `-Xcov json=myarg`: argument `myarg` is only sent to the JSON coverage report
117+
- `-Xcov commonArg`: the argument `commonArg` is sent to all coverage format reports.
118+
- `-Xcov notASupportedFormat=value`: the argument `notASupportedFormat=value` is sent to all coverage format reports.
129119

130-
SwiftPM will not perform any validation on the response file contents, except
131-
to determine the output location.
132120

133121
### Coverage report location
134122

135123
By default, the HTML report will be created in location under the scratch path
136-
(ie: the build directory). However, this can be overridden using the response file.
124+
(ie: the build directory). However, this can be overridden using `-Xcov` argument.
137125

138126
Some CI system, such as [Jenkins](https://www.jenkins.io), only allow archiving
139127
contents files/directories that belong in a "sandbox" location. It can be a safe
140128
assumption that the CI system will have a copy of the repository in the "sandbox"
141129
location, allowing this system to upload the HTML report.
142130

143-
```
144-
--show-coverage-path [mode]
145-
Print the path of the exported code coverage files. The mode specifies how to
146-
display the paths of the selected code coverage file formats. (default: text)
147-
json - Display the output in JSON format.
148-
text - Display the output as plain text.
149-
--enable-coverage/--disable-coverage
150-
Enable code coverage. (default: --disable-codecov)
151-
--coverage-format <format>
152-
Format of the code coverage output. Can be specified multiple times. (values: json, html; default: Produces a JSON coverage report.)
153-
```
154-
155131
### Show coverage path
132+
156133
Prior to this proposal `swift test --show-coverage-path` would display a single
157134
absolute path location to the JSON coverage report.
158135

@@ -168,6 +145,15 @@ The `--show-coverage-path` command line argument will be modified to be an optio
168145
with a default value. The supported values are `json` or `text`, with the default
169146
being `text` to preverse existing behaviour.
170147

148+
The help test of the `--show-coverage-path` default as flage optional is:
149+
```
150+
--show-coverage-path [<mode>]
151+
Print the path of the exported code coverage files. The mode specifies how to
152+
display the paths of the selected code coverage file formats. (default: text)
153+
json - Display the output in JSON format.
154+
text - Display the output as plain text.
155+
```
156+
171157
A value of `json` will output a JSON object with the key representing the format,
172158
and the value representing the output location of said format.
173159

@@ -201,6 +187,50 @@ Build of product 'swift-test' complete! (0.40s)
201187
}
202188
```
203189

190+
### Consolidate coverage option to use same argument "style"
191+
192+
Prior to this feature, there are 2 coverage options
193+
194+
```
195+
--show-codecov-path, --show-code-coverage-path, --show-coverage-path
196+
Print the path of the exported code coverage JSON
197+
--enable-code-coverage/--disable-code-coverage
198+
Enable code coverage. (default:
199+
--disable-code-coverage)
200+
```
201+
202+
There are 3 ways to show the coverage path. This proposal recommends to modify all
203+
coverage command line option to be a single, more useful option
204+
205+
```
206+
--show-coverage-path [<mode>]
207+
Print the path of the exported code coverage files. The mode specifies how to
208+
display the paths of the selected code coverage file formats. (default: text)
209+
json - Display the output in JSON format.
210+
text - Display the output as plain text.
211+
--enable-coverage/--disable-coverage
212+
Enable code coverage. (default: --disable-coverage)
213+
```
214+
215+
This requires gracefully phasing out the previous option in favour of the new one.
216+
217+
### Coverage command line options
218+
219+
TODO: update this command line options.
220+
```
221+
COVERAGE OPTIONS:
222+
--show-coverage-path [<mode>]
223+
Print the path of the exported code coverage files. The mode specifies how to
224+
display the paths of the selected code coverage file formats. (default: text)
225+
json - Display the output in JSON format.
226+
text - Display the output as plain text.
227+
--enable-coverage/--disable-coverage
228+
Enable code coverage. (default: --disable-coverage)
229+
--coverage-format <format>
230+
Format of the code coverage output. Can be specified multiple times. (values: json, html; default: Produces a JSON coverage report.)
231+
-Xcov <Xcov> Pass flag through to the underlying coverage report tool. Syntax is `[<format>=]<value>`
232+
```
233+
204234
## Security
205235

206236
Since SwiftPM will use `llvm-cov show`, there may be security implications from
@@ -216,7 +246,7 @@ No impact is expected.
216246
## Alternatives considered
217247

218248

219-
### Using `-Xcov`-style argument
249+
<!-- ### Using `-Xcov`-style argument
220250
221251
In addition to the response file, the coverage report generation can support
222252
a command line argument similar to `-Xlinker`, `-Xcc` and others, which will
@@ -239,7 +269,7 @@ As a result, it was decided to only support a response file, where said response
239269
file is in a given location relative to the repository root.
240270
241271
Support for `-Xcov` (or similar) is to be made in a subsequent proposal.
242-
272+
-->
243273
### `--show-coverage-path` alternative
244274

245275
Instead of having a `--show-coverage-path` as a tri-state, we could preserve

0 commit comments

Comments
 (0)