Closed
Description
TL;DR:
Older nightly toolchain gives an expected code coverage: rustup default nightly-2021-11-11
UPDATE: Regression is reproduced below #100125 (comment)
Prerequisites
I have a GitHub workflow which generates a code coverage report with nightly toolchain +grcov
, then sending it to https://coveralls.io.
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
export RUSTDOCFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
rustup default nightly
cargo test --all-features
curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf -
mkdir coverage
./grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" \
--excl-line '#\[|=> panic!|unreachable!|Io\(std::io::Error\)' \
--excl-br-line '#\[|=> panic!|unreachable!|assert_..!' -o ./coverage/lcov.info
I expected to see 100% code coverage on a simple file, e.g. see older coverage result: https://coveralls.io/builds/43003664/source?filename=src%2Ferror.rs - error.rs
has 100% code coverage.
Instead, this happened:
- https://coveralls.io/builds/51398291/source?filename=src%2Ferror.rs - 9% coverage.
- https://coveralls.io/builds/51398291/source?filename=src%2Flib.rs - coverage goes over comment lines
Version it worked on
At least nightly-2021-11-11 toolchain works:
rustup default nightly-2021-11-11
However, I have not narrowed down the most recent version this worked on.
Version with regression
rustc --version --verbose
:
rustc 1.64.0-nightly (0f4bcadb4 2022-07-30)
binary: rustc
commit-hash: 0f4bcadb46006bc484dad85616b484f93879ca4e
commit-date: 2022-07-30
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6