From e8edfef3607ec56fbf12b9c61cf4a222c353fcd6 Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Thu, 3 Mar 2022 08:01:57 +0900 Subject: [PATCH 1/5] rustc option "instrument-coverage" stabilized https://github.com/rust-lang/rust/pull/90132 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0dddb968b..3066ae313 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,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="-C instrument-coverage" ``` 3. Build your code: From f16b0ecae2b3e8cc21540da556d5f054552be7cd Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Thu, 3 Mar 2022 08:36:25 +0900 Subject: [PATCH 2/5] fix CICD.yml --- .github/workflows/CICD.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 617f7e793..eccad310e 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -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: | From 2e81ff78d08c24ab6934da16a2a174d4a49045ff Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Fri, 8 Apr 2022 07:47:18 +0900 Subject: [PATCH 3/5] we can use to STABLE rust update using Nightly to Stable. --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3066ae313..266a4c654 100644 --- a/README.md +++ b/README.md @@ -160,8 +160,7 @@ 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. +Build your code with rust compiler flag `-C instrument-coverage`. and run with `LLWM_PROFILE_FILE` environment variable. ### Example: How to generate source-based coverage for a Rust project @@ -266,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 @@ -288,7 +287,7 @@ before_install: matrix: include: - os: linux - rust: nightly + rust: stable script: - export CARGO_INCREMENTAL=0 From 195d91a24b0fdb002f78dd41253cdc24639306a3 Mon Sep 17 00:00:00 2001 From: kazuhiko kikuchi Date: Wed, 13 Apr 2022 06:52:14 +0900 Subject: [PATCH 4/5] Update README.md Co-authored-by: Marco Castelluccio --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eff277efc..2d103c93b 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ Build your code with rust compiler flag `-C instrument-coverage`. and run with ` 2. Ensure that the following environment variable is set up: ```sh - export RUSTFLAGS="-C instrument-coverage" + export RUSTFLAGS="-Cinstrument-coverage" ``` 3. Build your code: From b976c89527f8f3464d017d89ad70b7de901203ef Mon Sep 17 00:00:00 2001 From: Kazuhiko Kikuchi Date: Wed, 13 Apr 2022 07:08:49 +0900 Subject: [PATCH 5/5] move Nightly rust requirement to gcov based coverage --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eff277efc..d047d917a 100644 --- a/README.md +++ b/README.md @@ -159,8 +159,6 @@ you can run `cargo install grcov`. ## Usage -Build your code with rust compiler flag `-C instrument-coverage`. and run with `LLWM_PROFILE_FILE` environment variable. - ### Example: How to generate source-based coverage for a Rust project 1. Install the llvm-tools or llvm-tools-preview component: @@ -197,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