-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Invalid line coverage for multiple partially covered derive macros #404
Comments
cc @vmiklos |
(It doesn't resolve the underlying issue, but I guess the case itself could be resolved by using |
I think the root of the trouble is that llvm's JSON output tells us the line coverage percentage, so if it's complete or not is precise, but what lines are covered is not in the JSON explicitly. llvm's code is quite complex, tries to deal with c++ templates and macros.. My code here is obviously quite naive, but then with some iterations it turned out to be quite usable in practice. So if your problem is about the percentage reported, that's from llvm. If the percentage is <100, but you're not happy with the reported reported lines, then the JSON parsing code (in rust) can be tweaked. I guess the only important point is to make sure the percentage keeps coming from llvm, not our own calculation. Does this help? |
FWIW I filed llvm/llvm-project#126307, in case llvm-cov would give us which lines are not covered, then we could drop our own calculation, so you could not end up with a silly case where llvm-cov and 'cargo llvm-cov' disagrees if a line is covered or not. |
If multiple derive macros are used, and one is covered and one is uncovered, the results shown in the
llvm-cov
output will not match the output produced byjson.get_uncovered_lines()
. Whilellvm-cov
considers the line to be uncovered,json.get_uncovered_lines()
considers the line to be covered. So even if there is a missing line,--show-missing-lines
will not show the affected line and--fail-uncovered-lines 0
will have no effect.Here is a reproducer:
The function created by the
strum::EnumIter
macro is tested, while the function created by thestrum::Display
macro is not.llvm-cov
considers line 3 to be uncovered, but this line is considered to be covered byjson.get_uncovered_lines()
. This issue is caused by the following code, which was added to fix #181:cargo-llvm-cov/src/json.rs
Lines 268 to 270 in b7e5eb5
Unfortunately, I don't see a simple solution which wouldn't add a regression. Any ideas?
Using the JSON output for
--fail-uncovered-lines
would already be an improvement, so that at least the exit code would be correct, even if some lines in--show-missing-lines
are missing. What do you think?The text was updated successfully, but these errors were encountered: