Using coveragepy as a base for coverage reporting

Issue #607 closed
Former user created an issue

I've started to work on a parser to get coverage information from Vim scripts ((https://github.com/Vimjas/covimerage/tree/develop)), and am asking myself the question now if I should use coveragepy's infrastructure.

This would probably mean to use the coverage lib to generate the private data, so that all the coverage commands would work on it.

One issue I've seen already is that coveragepy's xmlreport does not support (expects) hit counts, which I would have in this case.

What do you think?

Comments (5)

  1. Ned Batchelder repo owner

    I don't understand what you are trying to build. If the measured language isn't Python, then I'm not sure anything in coverage.py will be useful to you.

  2. Daniel Hahler

    My idea is to have some coverage information and then just use the tools/infrastructure that coveragepy provides already.

    Most important is the xmlreport module, but to use other commands that coverage provides it would be good to just write .coverage in coveragepy's private format.

    My main interest is to get from some dictionary with source files mapped to lines with hit counts to integrating it with codecov etc.

    And I've imagined that it would be nice to just run "coverage report" etc on the gathered data, and get the same output as with reports from coveragepy directly.

  3. Ned Batchelder repo owner

    I think coverage.py is too intimately tied to Python source code to provide a reusable base for other languages' coverage tools.

  4. Daniel Hahler

    I've managed to integrate it using coverage.py's API to write the file, and a FileReporter plugin. It works quite well: https://github.com/Vimjas/covimerage/blob/551830bcc28198f9a29a458828715c439c4d7945/covimerage/init.py#L422 One downside is that coverage.py does not support hit counts internally, which I could provide. I will maybe look into improving this - currently lines is just a dict where the keys are used from, but could actually hold the number of hits instead of just None. Will this might not be useful by Python itself, it seems to make sense to support it on the API level.

    Feel free to close this issue, but I would appreciate your input on the line hit counts, of course.

  5. Log in to comment