Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-workspace path dependencies are included in reports and totals #303

Open
detly opened this issue Aug 21, 2023 · 0 comments
Open

Non-workspace path dependencies are included in reports and totals #303

detly opened this issue Aug 21, 2023 · 0 comments
Labels
C-bug Category: related to a bug.

Comments

@detly
Copy link

detly commented Aug 21, 2023

If I have a workspace package that also has non-workspace path dependencies, the coverage report from cargo llvm-cov --workspace includes the non-workspace sources. I don't know if this is expected or not, but it was surprising to me, and whether it happens is affected by details of the code.

Here's an example project if it helps. The structure this:

.
├── Dockerfile
├── one
│  ├── Cargo.toml
│  ├── ones-child
│  │  ├── Cargo.toml
│  │  └── src
│  │     └── lib.rs
│  └── src
│     └── lib.rs
└── two
   ├── Cargo.toml
   └── src
      └── lib.rs

The only interesting manifest is one/Cargo.toml:

[package]
name = "one"
version = "0.1.0"
edition = "2021"

[dependencies]
ones-child = { path = "ones-child" }
two = { path = "../two" }

[workspace]
members = [
    "ones-child",
]

If one never calls two, two's sources are not included in the report (example project job #4908791850):

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ones-child/src/lib.rs               4                 0   100.00%           3                 0   100.00%           8                 0   100.00%           0                 0         -
src/lib.rs                          4                 0   100.00%           3                 0   100.00%           8                 0   100.00%           0                 0         -

If one DOES call two, two's sources ARE included (job #4910063504):

Filename                      Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
one/ones-child/src/lib.rs           4                 0   100.00%           3                 0   100.00%           8                 0   100.00%           0                 0         -
one/src/lib.rs                      4                 0   100.00%           3                 0   100.00%           8                 0   100.00%           0                 0         -
two/src/lib.rs                      1                 0   100.00%           1                 0   100.00%           3                 0   100.00%           0                 0         -

The totals are a bit variable too - if one's tests cover two's code, even if two has zero coverage itself, it will be reported as 100% covered.

Seems related to #31.

  • Rust 1.71.1
  • cargo-llvm-cov 0.5.27
  • run in Docker image rust:1.71.1-slim (Debian Bullseye)
@taiki-e taiki-e added the C-bug Category: related to a bug. label Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants