You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: site/src/book/test-coverage.md
+36-2Lines changed: 36 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -26,9 +26,43 @@ Install Rust with the `llvm-tools-preview` component, nextest, and llvm-cov in G
26
26
run: cargo llvm-cov nextest
27
27
```
28
28
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
30
30
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)
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).
0 commit comments