Skip to content

Commit

Permalink
Use and suggest using stable rustc option "instrument-coverage" (#790)
Browse files Browse the repository at this point in the history
Co-authored-by: Marco Castelluccio <[email protected]>
  • Loading branch information
kazuk and marco-c authored Apr 13, 2022
1 parent b4fd202 commit db909c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ jobs:
key: test-${{ runner.os }}-cargo-gcc-${{ matrix.gcc }}-clang-${{ matrix.clang }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build
env:
RUSTFLAGS: -Zinstrument-coverage
RUSTFLAGS: -Cinstrument-coverage
run: cargo build
- name: Test
env:
LLVM_PROFILE_FILE: grcov-%p-%m.profraw
RUSTFLAGS: -Zinstrument-coverage
RUSTFLAGS: -Cinstrument-coverage
run: cargo test
- name: Generate coverage
run: |
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ you can run `cargo install grcov`.

## Usage

**Nightly Rust is required** to use grcov for Rust coverage. Alternatively, you can `export
RUSTC_BOOTSTRAP=1`, which basically turns your stable rustc into a Nightly one.

### Example: How to generate source-based coverage for a Rust project

1. Install the llvm-tools or llvm-tools-preview component:
Expand All @@ -173,7 +170,7 @@ RUSTC_BOOTSTRAP=1`, which basically turns your stable rustc into a Nightly one.
2. Ensure that the following environment variable is set up:

```sh
export RUSTFLAGS="-Zinstrument-coverage"
export RUSTFLAGS="-Cinstrument-coverage"
```

3. Build your code:
Expand All @@ -198,6 +195,9 @@ Pass `--coverage` to `clang` or `gcc` (or for older gcc versions pass `-ftest-co

### Example: How to generate .gcda files for a Rust project

**Nightly Rust is required** to use grcov for Rust gcov-based coverage. Alternatively, you can `export
RUSTC_BOOTSTRAP=1`, which basically turns your stable rustc into a Nightly one.

1. Ensure that the following environment variables are set up:

```sh
Expand Down Expand Up @@ -265,11 +265,11 @@ before_install:
matrix:
include:
- os: linux
rust: nightly
rust: stable

script:
- rustup component add llvm-tools-preview
- export RUSTFLAGS="-Zinstrument-coverage"
- export RUSTFLAGS="-Cinstrument-coverage"
- cargo build --verbose
- LLVM_PROFILE_FILE="your_name-%p-%m.profraw" cargo test --verbose
- ./grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
Expand All @@ -287,7 +287,7 @@ before_install:
matrix:
include:
- os: linux
rust: nightly
rust: stable

script:
- export CARGO_INCREMENTAL=0
Expand Down

0 comments on commit db909c4

Please sign in to comment.