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

Include return line in coverage report #1007

Closed zhiburt closed 2 years ago

zhiburt commented 2 years ago

Describe the bug

Hi @xd009642 I have noticed that return line doesn't included in a coverage report, which is supposed to be as I understand.

Likely it's not included in a traces map?

Screenshot_2022-05-14_13-38-49

I am not sure if it's a duplicate. Sorry if it is.

To Reproduce

fn foo(n: usize) -> usize {
    let n = n + 3;
    n
}

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        let result = super::foo(1);
        assert_eq!(result, 4);
    }
}
cargo tarpaulin --out Html

Expected behavior

The return must be included in coverage.

xd009642 commented 2 years ago

When I had ptrace breakpoints on the instruction for the returns like that normally they were never hit during execution resulting in a lot of false negatives. Changing it so they were ignored as you know it's covered in this instance if the function is hit felt like a better UX than false uncovered lines.

I've tried to make it better on the ptrace code but it's a tricky issue (but work is going into improving things just takes a lot of time).

I'm going to close this one as duplicated as return based issues have been mentioned in https://github.com/xd009642/tarpaulin/issues/351 :eyes: