mozilla / grcov

Rust tool to collect and aggregate code coverage data for multiple source files
Mozilla Public License 2.0
1.18k stars 148 forks source link

Failed to create a symlink of profraw on nightly-msvc #561

Closed tcztzy closed 2 years ago

tcztzy commented 3 years ago

I followed the manual from README, both .profraw and .gcda. And then I try to run following command to generate coverage report have the same panic

grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/
07:44:41 [ERROR] A panic occurred grcov-0.6.1\src\producer.rs:296: Failed to create a symlink "${workspace}\\default.profraw" -> "${tmpdir}\\default_1.profraw"

I also read this issure, but I need some Windows specified dependecies so I do pin nightly-msvc.

Is there any walkaround for this problem?

marco-c commented 3 years ago

Are both source-based coverage and gcov-based coverage failing?

Before running cargo test, can you make sure you remove all .profraw and .gcda files that are in your source tree?

  1. Remove all profraw and gcda files
  2. cargo build
  3. cargo test
  4. Run grcov

If it still fails, can you try running grcov PATHTOPROFRAW1 PATHTOPROFRAW2 ... -s . instead of grcov . -s .?

lolo32 commented 3 years ago

I got the same problem, and I just tried what you asked: remove, guild, test, grcov

I found a temporary solution:

Open the CMD with Administrator right

corebreaker commented 2 years ago

Yes, me too, it's urgent to fixt it, right ?

marco-c commented 2 years ago

@corebreaker does the workaround @lolo32 suggested work for you?

corebreaker commented 2 years ago

i found a better one, i used tarpaulin instead, plus too many problem with grcov, some line should be covered (like empty lines with no code around), tarpaulin didn't make these error. Lcov works better but tarpaulin is easier.

marco-c commented 2 years ago

Strange, there shouldn't be any difference in coverage results between lcov and grcov when using gcov-based coverage. The coverage instrumentation is in Rust itself. If you have a reproducible example, please file a new issue.

Tarpaulin is very different as it uses a custom instrumentation, not the standard one in the Rust compiler, and as far as I can tell it doesn't support Windows.

All in all, you should get the best results with source-based coverage and grcov (lcov doesn't support source-based coverage).

marco-c commented 2 years ago

Duplicate of #462.

marco-c commented 2 years ago

720 should fix this.