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

Src file mapping not working properly with trybuild and proc-macro workspace member #140

Closed
teoxoy opened this issue Feb 24, 2022 · 6 comments · Fixed by #141
Closed

Src file mapping not working properly with trybuild and proc-macro workspace member #140

teoxoy opened this issue Feb 24, 2022 · 6 comments · Fixed by #141
Labels
C-bug Category: related to a bug.

Comments

@teoxoy
Copy link

teoxoy commented Feb 24, 2022

When running integration tests (via trybuild) for a proc-macro crate that is a workspace member, the following warning is output:

error: dep/dep/src/lib.rs: No such file or directory
warning: The file 'dep/dep/src/lib.rs' isn't covered.

cmd run:

cargo llvm-cov --workspace --html

The report ends up showing 2 entries for the same src file as seen below

image

You can find a small reproducible sample here: test.tar.gz

This seems to be happening even if trybuild::TestCases::new() is the only thing in the test fn (no calls to pass or compile_fail).
It also seems to work fine if the crate is a normal lib instead of a proc-macro lib.

I wasn't sure if this is an issue with cargo-llvm-cov or trybuild but having tried tarpaulin with success (same setup), I thought it might be an issue with cargo-llvm-cov.

@taiki-e
Copy link
Owner

taiki-e commented Feb 25, 2022

Thanks for the report!

This appears to be a bug in rustc's --remap-path-prefix. If I disable it, it works correctly (#141).

m

@taiki-e taiki-e added the C-bug Category: related to a bug. label Feb 25, 2022
@teoxoy
Copy link
Author

teoxoy commented Feb 25, 2022

I tested the PR and it seems to solve the issue.
Thanks for the quick response and fix!

Do you have any concerns with the change in the PR?
Also, should we report the bug upstream?

@taiki-e
Copy link
Owner

taiki-e commented Mar 1, 2022

The problem I am currently aware of is that our test suite does not work well because the reports show absolute paths.

/private/var/folders/r3/hm536h9x0nj5zfh1qtyt7hth0000gn/T/.tmpsGNoB8/src/lib.rs:

Another concern is that this may be a problem when merging coverage between different platforms. (I have not looked into this yet.)

So, for now, I'm starting to think it is reasonable to provide an option to disable --remap-path-prefix.

@taiki-e
Copy link
Owner

taiki-e commented Mar 5, 2022

According to ruifengx/rowantlr#3, this seems to be a regression introduced around 2021-11-30.

@teoxoy
Copy link
Author

teoxoy commented Mar 5, 2022

Maybe something to do with rust-lang/rust#83846 (merged on 2021-11-11)?

@taiki-e
Copy link
Owner

taiki-e commented Apr 8, 2022

Published 0.3.0 which includes the fix for this.

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

Successfully merging a pull request may close this issue.

2 participants