xd009642 / tarpaulin

A code coverage tool for Rust projects
https://crates.io/crates/cargo-tarpaulin
Apache License 2.0
2.49k stars 176 forks source link

`couldn't be interpretted: missing section: CoverageFunctions` #1623

Open lcmgh opened 1 week ago

lcmgh commented 1 week ago

In my integration tests I am spawning my app via Command triggered cargo run.

When executing cargo tarpaulin --follow-exec I am getting some errors

2024-09-17T12:25:29.431195Z  INFO cargo_tarpaulin::statemachine::instrumented: For binary: target/debug/deps/app-7bb51c4783d6a2f3
2024-09-17T12:25:29.431211Z  INFO cargo_tarpaulin::statemachine::instrumented: Generated: target/tarpaulin/profraws/amdemo-7bb51c4783d6a2f3_5880590785421624853_0-11505.profraw
2024-09-17T12:25:29.431214Z  INFO cargo_tarpaulin::statemachine::instrumented: Merging coverage reports
2024-09-17T12:25:29.666884Z  INFO cargo_tarpaulin::statemachine::instrumented: Mapping coverage data to source
2024-09-17T12:25:29.678600Z ERROR llvm_profparser::coverage::coverage_mapping: /Users/app/target/debug/app couldn't be interpretted: missing section: CoverageFunction

Still I am getting

15.31% coverage, 81/529 lines covered, +15.31% change in coverage

tarpaulin 0.31.2 latest macos

xd009642 commented 1 week ago

The coverage functions section is the first one I try, so likely the spawned binaries haven't been built with the instrumentation enabled. If you add --print-rust-flags to your CLI prompt and then set that as your RUSTFLAGS env var before the spawned command is built you might get the coverage information as expected