Skip to content
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

Cobertura report using --branch option is missing condition-coverage flag in generated XML #1029

Open
dlrobson opened this issue May 1, 2023 · 1 comment

Comments

@dlrobson
Copy link

dlrobson commented May 1, 2023

Hi all,

I was trying to use the cobertura output with branch coverage on C++ code. I was following the README, and generated the required .gcno and .gcda files.

Running grcov with branch coverage results in an xml file that results in line coverage results like so:

<line number="297" hits="4284" branch="true">

The template at the top of the XML file (<!DOCTYPE coverage SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-04.dtd'>).
Shows the condition-coverage within its template:

  <!ELEMENT line (conditions*)>
  <!ATTLIST line number CDATA #REQUIRED>
  <!ATTLIST line hits   CDATA #REQUIRED>
  <!ATTLIST line branch CDATA "false">
  <!ATTLIST line condition-coverage CDATA "100%">

Meanwhile, grcov omits this from its output. I think the culprit is in this function here, and it should be outputting the results in the function:

fn write_lines(writer: &mut Writer<Cursor<Vec<u8>>>, lines: &[Line]) {

This is the expected output (but with valid data):

<line number="297" hits="4284" branch="true" condition-coverage="100% (2/2)">

The reason why I'm bringing this up is because we're using the Jenkins Code Coverage plugin, and it crashes when calling recordCoverage:

Could not obtain attribute 'condition-coverage' from element '[Stax Event #1]'

We're calling recordCoverage like so:

recordCoverage checksAnnotationScope: 'ALL_LINES', qualityGates: [[criticality: 'FAILURE', metric: 'LINE', threshold: 83.0]], tools: [[parser: 'COBERTURA', pattern: 'coverage_*.xml']]

I think this is an error with the grcov output, because it's also listed in the cobertura output template. My short-term solution was to not use branch coverage with grcov, and that works fine. However, it would be nice to have that working.

@visu-suganya
Copy link

Yes I'm having the same issue.
I generates tags in my local but not in CI only.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants