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

[Windows] Tarpaulin creates lcov.info in the wrong folder #1147

Closed dkudlek closed 1 year ago

dkudlek commented 1 year ago

Describe the bug

When tarpaulin writes lcov.info it gets the wrong current directory. It writes the file into an subfolder instead of the root folder. Specifying --root or --output-dir did not help.

To Reproduce

Project structure: challenge-rust

root/Cargo.toml
root/explore_dungeon
root/find_unique_interval
root/level_buildings
root/start_chain_reaction
root/src

Workaround :link:

Software versions

xd009642 commented 1 year ago

This may be fixed in the develop branch if you don't mind giving it a test (hopefully by fixing your other issue earlier in the week)

dkudlek commented 1 year ago

I checked out develop (16bbf71ac1a2ba57b010045eaea3330f6bef4bd5), but this issue still persists. I ran the the same actions as in the opening post and got the same results. But thanks already for the hard work on the UNC issue!

AntoniosBarotsis commented 1 year ago

I am having the same issue.

The dev branch is indeed not working for me either, @dkudlek's workaround perhaps works for his use case but the issue is not lcov specific.

What I did instead is set output_dir to the root by default. I have no idea if this breaks something else that I did not consider but the output is correct for me now.

Edit: Ok 2 things;

Second edit: It seems that many tests are actually failing even on the last dev commit so definitely not all of them are caused by my change, that said you probably will have an easier time figuring out what's happening 😓

Hopefully this helps in some way

xd009642 commented 1 year ago

So this branch may fix it fix/report-dirs-windows (PR: https://github.com/xd009642/tarpaulin/pull/1190). I'll need to boot my windows laptop up some point today to find out but if you test it first that also works :ok_hand:

AntoniosBarotsis commented 1 year ago

This is the same as what I did in the referenced commit above so yes it should work. The only "catch" was some prints that seemed to still be using current dir although I'm not sure if that got fixed elsewhere.

I'll be home in a few minutes and I can try it then

xd009642 commented 1 year ago

Oh doh I missed that commit! I'll probably check it in an hour or 2

AntoniosBarotsis commented 1 year ago

Yes so it is essentially the same as with my commit, the output directory is correct but the info log is wrong.

Running in this project outputs the following:

Jan 21 15:40:23.919  INFO cargo_tarpaulin::report: Coverage Results:
|| Tested/Total Lines:
|| ..\cli\src\error.rs: 0/8 +0.00%
|| ..\cli\src\main.rs: 0/25 +0.00%
|| ..\common\src\lib.rs: 7/7 +0.00%
|| ..\common\src\logos.rs: 9/13 -30.77%
|| ..\lib\src\error.rs: 3/11 +0.00%
|| ..\lib\src\lib.rs: 87/87 +0.00%
|| src\endpoints.rs: 21/21 +0.00%
|| src\error.rs: 11/11 +0.00%
|| src\main.rs: 0/2 +0.00%
||
74.59% coverage, 138/185 lines covered, -8.84% change in coverage

Notice how the prints seem to be made inside of one of the project's crates (the server in my case which is likely the last one to run seeing as how that's where the report would be dropped prior to this fix).

The prints seem to happen in this function but the issue is likely with how some iteration happens.

xd009642 commented 1 year ago

I've realised what the printing is, it's related to me getting the paths from the llvm coverage files, hopefully a quick fix now I know where it's coming from. Then I'll aim to add this in, then fix globs for windows and cut a new release

xd009642 commented 1 year ago

And I've found it, once CI passes I'll merge meanwhile onward to globs!

xd009642 commented 1 year ago

And it's merged, just gonna close this now - and there should be a new tarpaulin version before weekend is over :smile:

dkudlek commented 1 year ago

I checked out 959c8bea76c5752b5a7aa4ebde28d974cc230190 and 1f40d9a84b7626f6205e63da61be2f7022738d03 on develop. My first two test cases work. This would work for me. ✔️

For the sake of completeness, the last use case still fails. Trying to change the output directory.

xd009642 commented 1 year ago

I think I see it - this should fix it https://github.com/xd009642/tarpaulin/pull/1193 @dkudlek

I can try tomorrow on my windows machine it's just getting late here so I won't test it out tonight

dkudlek commented 1 year ago

Looks good to me!