-
Notifications
You must be signed in to change notification settings - Fork 46
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
Fix BRDA syntax in lcov files #517
Comments
More context: flutter/flutter#108313 (comment) Branch coverage is the +/- symbols on the left, and line coverage is the hilited lines: The lcov.info for this looks like:
Historically, the VM only showed coverage information on function calls. This meant that cases like that This is not how other coverage tools define "branch coverage". We can continue to ignore the block field (it's not relevant in Dart), but there should be multiple BRDA tags on the same line with different expr fields. It's considered weird/exceptional/problematic to have only 1 BRDA tag for a line, because it implies the control flow isn't really branching at all. Some tools will ignore these tags. Instead we should give all the BRDA tags for a branch point the same line field, and distinguish them by their expr field (and probably just omit BRDA tags when there isn't actually a branch). Our example lcov.info should look more like this:
The else case's BRDA tag has moved to the if line. This is probably less readable for users, but we're supposed to be able to make the expr tag a human readable string. For example we could call them "if" and "else" instead. Unfortunately this doesn't seem to work in genhtml (BRDA lines with non-integer block or expr fields are ignored), so we'll need to investigate a bit more. Change 1: To fix this we just have to tweak the RecordCoverage instruction and source_report.cc to change the line that's being reported for else cases, and other bits of control flow like switch statements. We might need to add another flag to the instruction to indicate it's a branch coverage flag, and/or an int to indicate which branch it is. This may also require changes to the getSourceReport RPC and package:coverage to support it. Details TBD. Change 2: It's probably still useful to keep the RecordCoverage instructions on every basic block, since there's a lot of lines that are marked as uncoverable atm. Instead we should report these non-branching RecordCoverage instructions as ordinary line coverage, so we continue to get the improved line coverage that these instructions give us:
Change 3: We're still missing coverage on that conditional expression, so as a stretch goal we should also try to add branching RecordCoverage instructions there. With change 2 that would give us both branch and line coverage for these expressions:
Change 4: It was also mentioned on those context bugs that branch coverage for simple if/else cases isn't very interesting. As an extra-stretchy stretch goal, it would be even better if early out statements also included branch coverage. In our example,
Change 5: Unfortunately change 4 would be really unreadable for users unless we solve the expr naming issue I mentioned. genhtml surfaces the expression index/name to users when they hover over the +/-, so it would be good to give them a human readable name:
@henry2cox How does that plan sound? cc @a-siva |
Yes and no. As mentioned in the other issue: I had (inadertently) lied to you about the BRDA syntax for branch expressions. I believe the feature works. There is a lot of branch expression discussion elsewhere regarding reachability and realistic branch targets. Henry |
FWIW: gcc/llvm would not mark the 'else' keyword as a line (statement).
is a statement - but only because the 'if' statement is on the same line as the label. This likely doesn't matter either way - as long as the treatment is consistent. |
@liamappelbe @henry2cox All tests have passed successfully. I have opened a PR for this: Fixed in PR #2033. |
@Victowolf this bug can't be fixed purely in package:coverage. Most of the changes I mentioned in my comment above are in the Dart VM. Specifically, the most important change would be to alter the RecordCoverage instruction in the VM, and the VM Service API, so that the branch coverage for an else statement is somehow associated with the corresponding if statement. I don't think package:coverage has enough information to make that association currently. From your PR description, it's not really clear to me what actual changes you've made, it just says you fixed the BRDA syntax. How does your PR fix the syntax? |
This comment has been minimized.
This comment has been minimized.
@Victowolf - this looks like AI-generated content; as per #522 (comment), please refrain from posting this type of content. |
@devoncarew I thought using A.I to enhance the comments would help out in keeping things more formal and effective... |
See linux-test-project/lcov#221
The text was updated successfully, but these errors were encountered: