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

DO-NOT-MERGE: Patched-on LCOV file format support for coveragepy v4.x #863

Closed
wants to merge 1 commit into from

Conversation

gpshead
Copy link

@gpshead gpshead commented Oct 29, 2019

This is gross as is, it was originally done in a way that minized diffs. :/

This PR is for discussion purposes only. I expect a new PR to be created by anyone interested on master to add lcov support in a non-hacky manner. :)

I'm making the PR on a branch of v4.5.x as our existing changes do not apply cleanly after some of the refactoring in the git master (v5) code.

We are using a patched 4.4.2 internally at the time of PR creation. This patch comes from Google where we've been carrying around some variant of this patch on top of coverage for a very long time. It clearly belongs upstream (starting that here), as the LCOV format seems to be supported by a variety of IDEs and other systems(?).

I don't expect to do future work in this PR itself. Follow #587 for actual details.

Lacking: Any LCOV format unittests. (sadface)

(I did not successfully run the coverage testsuite on this PR but that might have been my lack of trying and possibly a weird environment? They don't seem to run properly for me when following the v4.5.x branch howto.txt instructions but I didn't try to debug why)

This is gross, it was done in a way that minized diffs.  Reworking this
to be non-ugly code for proper support in coveragepy would be great.

I'm making the PR on a branch of v4.5.x as our existing changes do not
apply cleanly after some of the refactoring in the git master (v5) code.

We're still using patched 4.4.2 internally at the time of PR creation.
@nedbat
Copy link
Owner

nedbat commented Oct 29, 2019

@gpshead Thanks. I have to admit, when I saw you started with "this is gross," I thought, "come on, how gross could it be?" Then I looked at the diffs... :)

Is there a reference anywhere for the lcov file format? I found this: http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php

@nedbat
Copy link
Owner

nedbat commented Oct 29, 2019

Oops, that was already in #587 (slurps coffee).

@nedbat
Copy link
Owner

nedbat commented Oct 29, 2019

@gpshead a couple of questions:

  1. Your code outputs "BA" lines, but the man page describing the format doesn't mention them. Do other tools understand these lines? The comment in the code is helpful for understanding the semantics.
  2. This code is based on annotate, which is the least-used reporting method. It marks some lines executed that the other reporting methods do not. For example, non-blank lines in docstrings, or the def line after a decorator. Will it be OK if the real lcov support changes how these lines are marked?

ulfjack added a commit to ulfjack/bazel that referenced this pull request Dec 17, 2019
- Add lcov_merger as an attribute to the py_test rule so that it does
  not immediately fall over
- Add a small section to python_stub_template.txt to perform minimal
  setup for coverage integration

I was able to get this to work manually by using a modified version of
coverage.py, see:
nedbat/coveragepy#863

Note that the patch does not work out of the box.

It's basically ~impossible to add integration tests until we get a
working version of coverage.py, but this is the minimum change required
in Bazel to get a basic working version.
bazel-io pushed a commit to bazelbuild/bazel that referenced this pull request Jan 23, 2020
- Add lcov_merger as an attribute to the py_test rule so that it does
  not immediately fall over
- Add a small section to python_stub_template.txt to perform minimal
  setup for coverage integration

I was able to get this to work manually by using a modified version of
coverage.py, see:
nedbat/coveragepy#863

Note that the patch does not work out of the box.

It's basically ~impossible to add integration tests until we get a
working version of coverage.py, but this is the minimum change required
in Bazel to get a basic working version.

Closes #10433.

PiperOrigin-RevId: 291166690
@abitrolly
Copy link

Fixed by #1289 ?

@gpshead gpshead marked this pull request as draft January 23, 2022 10:07
@gpshead
Copy link
Author

gpshead commented Jan 23, 2022

oh boy! I can't wait to try that out and delete this ugly pile of code. :)

@gpshead gpshead closed this Jan 23, 2022
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

Successfully merging this pull request may close these issues.

3 participants