-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Everything is highlihted as uncovered #4
Comments
OK, I think I've found the source of the issue. Let me try to explain a bit. The project I'm testing this on is compiled as a The source <(cargo llvm-cov show-env --export-prefix)
export CARGO_TARGET_DIR="$${CARGO_LLVM_COV_TARGET_DIR}"
cargo llvm-cov clean --workspace
cargo build --workspace \
&& cargo test --workspace \
&& cargo llvm-cov report --json --output-path=coverage.json The issue in this case seems to be that the functions Then the logic in merge_function_info kicks in and marks all these lines as The end result is that the only lines highlighted as I know nothing about llvm-cov report format so I can't tell if the |
Thank you for the bug report and addition of further context. I never did external tests in my projects, thus simply never encountered the situation. But I was recently playing with the idea of adding an option that disables the function invocation overlay. Sadly, llvm-cov uses some internal structures that are not the same as the JSON output, so I can't fully map the logic in llvm-cov-pretty. Plus, the LLVM code is pretty complex, and I'm not a C++ expert 😓. Therefore, the behavior in llvm-cov-pretty is the result of putting JSON and HTML report next to each other and try to make sense of the numbers in the JSON format until it seems to match with the HTML report. One big difference is that the function coverage in llvm-cov is inline, whereas I mark the whole line as uncovered if the coverage reports Just let me confirm whether I understand correctly: you'd like to be able to disable the function instantiation overlay that's being done over the regular file coverage? If that's the case, it aligns with my idea of adding a CLI flag that allows to disable said overlay. |
Sorry, I'm confused, what is the "function instantiation overlay"? |
So llvm-cov splits the coverage information into certain categories. As you can see in the overview page that llvm-cov-pretty generates, it splits coverage into line, function and region coverage. There is a fourth, branch coverage, but that isn't currently supported for Rust. In the coverage JSON file, there are the file coverages which represent the line coverage information. Then there is function instantiation coverage which represents the function and region coverage. For the coverage on the source code, it first applies the line coverage, and then uses the function coverage on top of that. That behavior is the same in the regular llvm-cov output, where you can see it as individual bits (like a specific function call), that are marked as covered/uncovered within a single line (or multiple). I agree the term "function instantiation" is odd, as you don't really instantiate a function but rather call it... It's the terminology used inside LLVM code 🤷. How about I simply add that flag, and you try it out to see if that's what you need. I was playing with the idea to add that flag anyway. It'd skip the |
I was in fact confused by the term "overlay". The way I understand the term "instanciation" is related to generics, i.e.: // Given a generic function:
fn foo<T>(param: T) {}
// The following is an instanciation of foo<T> as foo<&'static str>
let _ = foo("bar");
// The following is an instanciation of foo<T> as foo<u8>
let _ = foo(42u8);
// Thus llvm-cov reports:
// count = 1 for foo<&'static str>
// count = 1 for foo<u8>
// Unexecuted instanciation for foo<_> (for any other T) In the source view of the In the source view of the
Now - correctly if I'm wrong as I just glanced over the code - maybe the issue is that |
True, as you get a version of the generic function with each type it's used with.
I feel it's neither right nor wrong 😅. In the original llvm-cov report, it's still marked as red if the variant is missing, just not for the whole line. I wanted to avoid having it look too good, giving a false sense of security as it would show as covered even though there are some instantiations that weren't called. But only marking it as uncovered if all of those are uncovered is a good idea. Maybe it's worth introducing another color (yellow) to mark a line as partially covered, for when some of them are not covered. By the way, you can get similar annotations with the |
In fact it turns out my issue is not related to generics. It seems related to the fact that the report is collected in several passes, i.e. one pass with Since a But a library function will have one entry when run w/ Given all the former, I agree that:
And that:
👍🏻 |
You might be able to merge the coverage data with Just, Looking at the implementation of But that's just an idea to get all the coverage data into one file. Might not even work in the end. As for the 2 improvements I mentioned, I'll work on those and let you know once I make a new release. |
Sorry, a little late with the ping. I released a new version a bit ago, which marks partially covered lines as yellow now, and adds a new flag to disable the function coverage override. Have you had any success with the |
Describe the bug
Hi,
I just installed
llvm-cov-pretty
, and ran it on a project.At first glance the metrics seem to match the
cargo llvm-cov
html report.However in the file source view, everything single executable line is highlighted as uncovered (wrapped in a
<td class="uncovered">
). That's a lot of red.Expected behavior
Lines should be highlighted correctly.
What operating system are you using?
Linux
Additional context
Here's the formatted JSON object for a small file showing 100% line coverage:
The text was updated successfully, but these errors were encountered: