aantron / bisect_ppx

Code coverage for OCaml and ReScript
http://aantron.github.io/bisect_ppx/demo/
MIT License
301 stars 60 forks source link

Add <packages> to cobertura format #420

Closed maxim092001 closed 1 year ago

maxim092001 commented 1 year ago

This PR adds <packages> to cobertura format.

Issue

aantron commented 1 year ago

Thank you!

@arvidj, @sir4ur0n, @vch9, would this be fine for your usage of the Cobertura reports, which is, I understand, in GitLab CI? I think you could directly try it by using Bisect_ppx from this branch, https://github.com/maxim092001/bisect_ppx.git#master.

Hey!

Proposal:

I would like to add <packages> around packages.

For example current report generated by bisect_ppx looks like:

<?xml version="1.0"?>
<coverage lines-valid="282" lines-covered="79"
line-rate="0.280142">
  <sources>
    <source>.</source>
  </sources>
  <package name="." line-rate="0.280142">
    <classes>
      <class name="lib/message.ml" filename="lib/message.ml"
      line-rate="0.250000">
        <lines>
          <line number="4" hits="4" />
          <line number="6" hits="0" />
          <line number="7" hits="0" />
          <line number="8" hits="0" />
        </lines>
      </class>
    </classes>
  </package>
</coverage>

And I would like it to be as:

<?xml version="1.0"?>
<coverage lines-valid="282" lines-covered="79"
line-rate="0.280142">
  <sources>
    <source>.</source>
  </sources>
  <packages>
    <package name="." line-rate="0.280142">
      <classes>
        <class name="lib/message.ml" filename="lib/message.ml"
        line-rate="0.250000">
          <lines>
            <line number="4" hits="4" />
            <line number="6" hits="0" />
            <line number="7" hits="0" />
            <line number="8" hits="0" />
          </lines>
        </class>
      </classes>
    </package>
  </packages>
</coverage>

Why:

Some tools used to generate HTML or any other representation of report require <packages>. For example: pycobertura

Also, in main cobertura repo they also have <packages>.

Also, <packages> is a part of some kind of official specification that was considered in initial PR.

Would you be ok with such contribution? @aantron

Thanks!

aantron commented 1 year ago

Thank you! I will release this shortly. I guess we will find out retroactively if this breaks anything, but I expect that it won't, because the <packages> element appears to be standard.

maxim092001 commented 1 year ago

Thank you! I will release this shortly. I guess we will find out retroactively if this breaks anything, but I expect that it won't, because the <packages> element appears to be standard.

Thanks! I will close the issue then.

arvidj commented 1 year ago

Hello, a bit late to the party, sorry about that. I've tested the bisect_ppx version from this branch and it seems to work fine in our setup. Thanks for the patch!