Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc option "instrument-coverage" stabilized #790

Merged
merged 9 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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