xd009642 / tarpaulin

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

Missing coverage when using passing +nightly in extra flags #862

Closed emarcotte closed 2 years ago

emarcotte commented 2 years ago

Describe the bug

I have a relatively small application that has just a couple of simple unit tests. I noticed that when I was trying to get my CI to start procuding JUnit and coverage XMLs I stopped getting coverage info.

My initial command which worked at some point in the past was:

export CARGO_TARPAULIN_TARGET_DIR="target/tarpaulin" 

cargo tarpaulin \
    --skip-clean \
    --out Xml \
    -- \
    +nightly -Z unstable-options \
    --format=json \
    --report-time \
    |& tee >( cargo2junit > junit-output.xml )

But it seems now any inclusion of -- +nightly reports 0 coverage.

Platform:

$ uname -a && rustc --version
Linux emarcotte-x1new 5.14.13-200.fc34.x86_64 #1 SMP Mon Oct 18 12:39:31 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
rustc 1.55.0 (c8dfcfe04 2021-09-06)

To Reproduce

run:

export CARGO_TARPAULIN_TARGET_DIR="target/tarpaulin" 

cargo tarpaulin \
        --verbose \
        --skip-clean 

observe coverage. run:

export CARGO_TARPAULIN_TARGET_DIR="target/tarpaulin" 

cargo tarpaulin \
        --verbose \
        --skip-clean \
        -- \
        +nightly

Observe no coverage

Expected behavior

Coverage matches when test is in nightly mode or not.

emarcotte commented 2 years ago

Hrm so it doesn't reproduce with:

❯ cat src/main.rs 
fn main() {
    println!("Hello, world!");
}

#[cfg(test)]
mod test {
    #[test]
    fn test_stuff() {
        assert!(1 == 1);
    }
}
❯ cat Cargo.toml 
[package]
name = "cov"
version = "0.1.0"
edition = "2021"

Will try to find what needs to be included for it to start falling appart.

emarcotte commented 2 years ago

:facepalm: Nevermind me. +nighttly after cargo works fine, but +nightly in the test flags doesn't. Not sure why it sometimes treats it like its a test filter and others it doesnt. Either way works fine after multiple attempts with it right after cargo. Sorry for spam!