Skip to content

Commit

Permalink
[docs] update test coverage section, put up an example in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshowers committed Mar 18, 2022
1 parent a46682f commit 803c75f
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 20 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
push:
branches: [ main, auto, canary ]
pull_request:
branches:
- main

name: Test coverage

jobs:
coverage:
name: Collect test coverage
runs-on: ubuntu-latest
# nightly rust might break from time to time
continue-on-error: true
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
with:
# By default actions/checkout checks out a merge commit. Check out the PR head instead.
# https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: llvm-tools-preview
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c

- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Collect coverage data
run: cargo llvm-cov nextest
# TODO: generate HTML report and upload it
# (requires https://github.com/taiki-e/cargo-llvm-cov/pull/144#issuecomment-1072736931 to be addressed)
2 changes: 1 addition & 1 deletion site/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
- [Target runners](book/target-runners.md)
- [Other options](book/other-options.md)
- [Environment variables](book/env-vars.md)
- [Coverage](book/coverage.md)
- [Machine-readable output](book/machine-readable.md)
- [Configuration](book/configuration.md)
- [JUnit support](book/junit.md)
- [Test coverage](book/test-coverage.md)
---
- [Stability policy](book/stability.md)
- [Experimental features](book/experimental-features.md)
Expand Down
18 changes: 0 additions & 18 deletions site/src/book/coverage.md

This file was deleted.

2 changes: 1 addition & 1 deletion site/src/book/pre-built-binaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ To install a version series or specific version, use this instead:

Install pre-built binaries on other CI systems by downloading and extracting the respective archives, using the commands above as a guide. See [Release URLs](release-urls.md) for more about how to specify nextest versions and platforms.

> If you've made it easy to install nextest on another CI system, feel free to [submit a pull request].
> If you've made it easy to install nextest on another CI system, feel free to [submit a pull request] with documentation.
[submit a pull request]: https://github.com/nextest-rs/nextest/pulls
29 changes: 29 additions & 0 deletions site/src/book/test-coverage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Test coverage

Test coverage support is provided by third-party tools that wrap around nextest.

## llvm-cov

[cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) supports nextest. To generate llvm-cov data with nextest, run:

```
cargo install cargo-llvm-cov
cargo llvm-cov nextest
```

### Using llvm-cov in GitHub Actions

Install both nextest and llvm-cov in GitHub Actions, then run `cargo llvm-cov nextest`.

```yaml
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@nextest
```
## Integrating nextest into coverage tools
Most coverage tools work by setting a few environment variables such as `RUSTFLAGS` or `RUSTC_WRAPPER`. Nextest runs Cargo for the build, which will read those environment variables as usual. This means that it should generally be quite straightforward to integrate nextest into other coverage tools.

> If you've integrated nextest into a coverage tool, feel free to [submit a pull request] with documentation.

[submit a pull request]: https://github.com/nextest-rs/nextest/pulls

0 comments on commit 803c75f

Please sign in to comment.