Open
Description
I tried this code:
use tracing::warn;
#[tracing::instrument(level = "info", skip_all)]
fn fun() {
print!("Hello World!");
}
#[cfg(test)]
mod tests {
use crate::fun;
fn function() {
fun();
}
}
And created a coverage report of it with:
RUSTFLAGS="-C instrument-coverage" cargo test
rust-profdata merge -sparse -o 1.profdata **/*.profraw
rust-cov show target/debug/deps/coverage_mini-280555d4395f82aa --instr-profile 1.profdata main.rs
I expected to see the function fun
marked as covered.
Instead, it is shown as not being possible to cover:
1| 1|use tracing::warn;
2| |
3| 2|#[tracing::instrument(level = "info", skip_all)]
4| |fn fun() {
5| | print!("Hello World!");
6| |}
7| |
8| |#[cfg(test)]
9| |mod tests {
10| | use crate::fun;
11| |
12| 1| #[test]
13| 1| fn function() {
14| 1| fun();
15| 1| }
16| |}
Without the #[tracing::instrument(...)]
it works fine:
1| 1|use tracing::warn;
2| |
3| 1|fn fun() {
4| 1| print!("Hello World!");
5| 1|}
6| |
7| |#[cfg(test)]
8| |mod tests {
9| | use crate::fun;
10| |
11| 1| #[test]
12| 1| fn function() {
13| 1| fun();
14| 1| }
15| |}
Meta
rustc --version --verbose
:
rustc 1.71.0-nightly (7908a1d65 2023-04-17)
binary: rustc
commit-hash: 7908a1d65496b88626e4b7c193c81d777005d6f3
commit-date: 2023-04-17
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2