Skip to content

Commit 8980561

Browse files
committed
[site] expand test coverage instructions
Fixes #1080.
1 parent 1f98ee6 commit 8980561

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

site/src/book/test-coverage.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,43 @@ Install Rust with the `llvm-tools-preview` component, nextest, and llvm-cov in G
2626
run: cargo llvm-cov nextest
2727
```
2828
29-
[See this in practice with nextest's own CI.](https://github.com/nextest-rs/nextest/blob/main/.github/workflows/coverage.yml)
29+
### Collecting coverage data from doctests
3030
31-
> TODO: provide instructions for other report forms like HTML, and for reporting to an external code coverage service.
31+
Nextest doesn't currently support doctests, so coverage data from nextest must be [merged](https://github.com/taiki-e/cargo-llvm-cov?tab=readme-ov-file#merge-coverages-generated-under-different-test-conditions) with doctest data.
32+
33+
Here's an example GitHub Actions configuration:
34+
35+
```yaml
36+
# Nightly Rust is required for cargo llvm-cov --doc.
37+
- uses: dtolnay/rust-toolchain@nightly
38+
with:
39+
components: llvm-tools-preview
40+
- uses: taiki-e/install-action@cargo-llvm-cov
41+
- uses: taiki-e/install-action@nextest
42+
43+
- name: Collect coverage data (including doctests)
44+
run: |
45+
cargo llvm-cov --no-report nextest
46+
cargo llvm-cov --no-report --doc
47+
cargo llvm-cov report --doctests --lcov --output-path lcov.info
48+
```
49+
50+
### Reporting to an external coverage service
51+
52+
External services like [Codecov.io](https://about.codecov.io/) can be used to collect and display coverage data. Codecov is free for open source projects, and supports `lcov.info` files.
53+
54+
After generating an `lcov.info` file, upload it to Codecov with:
55+
56+
```yaml
57+
- name: Upload coverage data to codecov
58+
uses: codecov/codecov-action@v3
59+
with:
60+
files: lcov.info
61+
```
62+
63+
### Example
64+
65+
Nextest itself uses the above mechanisms to collect coverage for its project. The config is located in [`.github/workflows/coverage.yml`](https://github.com/nextest-rs/nextest/blob/main/.github/workflows/coverage.yml).
3266

3367
## Integrating nextest into coverage tools
3468

0 commit comments

Comments
 (0)