You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bazel coverage should generate a coverage report for the python tests it runs. Ideally, it gathers the list of dependencies, and then computes coverage over that for a given test. When multiple tests are run in the same Bazel invocation, their reports should be merged into a single one.
I'm dropping this here mostly as a python-specific version of bazelbuild/bazel#1118. I know that the py_test rule is currently implemented natively in Bazel, and the implementation in rules_python just forwards there, but this is fundamentally a python issue, so this repo feels appropriate.
The general plan is to modify the python test runner within Bazel to use coverage.py to generate reports when running under coverage. I suspect it is a journey fraught with peril.
Alternatively, if it is possible to invoke coverage.py in ways other than modifying core Bazel, I'm open to suggestions.
Reacted by Alec Benzer, Chris Cummins, mihai-tiriplica-hs, Simon Toens, Daniel J. Beutel, Daniel Bryce Evans, penikala, Eugene Davis, Gytis Raciukaitis, Nigel Delaney and 20 more
Has this feature been implemented yet? If so, in what release version? It seems like coverage has been able to cover every other bit of our code repo except for all python files which is makes up most of our code base. Please let me know!
Reacted by RSam, Andrew Ring, Yasushi Saito, Sean Happenny, Matthew Jones, Sean Galantzan, Chris Carpita and jxramos
Reacted by Patrick Rice, Sean Galantzan and Chris Carpita
Is there a way to make bazel coverage //some_py_test not fail even if it does not collect coverage information. Currently, it fails because :lcov_merger attribute is not defined in py_test rules.
This is kind of important because we want to be able to run bazel coverage ... on a monorepo.
Reacted by Sean Happenny, Jason McFall, Sean Galantzan, Moshe Zada, Adam Azarchs, Aviv Stern and Mathieu Bosi
At this point upstream coveragepy has lcov support. I think the main piece that's missing is that there needs to be a way to specify a target for coveragepy in py_runtime for hermetic python toolchains.
Activity
mattmoor commentedon Nov 27, 2017
@damienmg assigning to you to redirect appropriately.
hwright commentedon Nov 27, 2017
fwiw, I've also been poking at this as documented here: https://groups.google.com/d/msg/bazel-discuss/LC97zBrMG84/cfVNdus-AwAJ
It's been slow going, as I'm pretty unfamiliar with Bazel internals, and haven't been able to get the ear of somebody who is.
brandjon commentedon Nov 9, 2018
Setting P4 because this isn't a blocker for 1.0 support.
JoshSullivan11 commentedon Jun 25, 2019
Has this feature been implemented yet? If so, in what release version? It seems like coverage has been able to cover every other bit of our code repo except for all python files which is makes up most of our code base. Please let me know!
siddharthab commentedon Aug 14, 2019
Is there a way to make
bazel coverage //some_py_testnot fail even if it does not collect coverage information. Currently, it fails because:lcov_mergerattribute is not defined in py_test rules.This is kind of important because we want to be able to run
bazel coverage ...on a monorepo.9 remaining items
EnergySRE commentedon Oct 28, 2021
Boop. We still desire this 🙂
mihaigalos commentedon Oct 28, 2021
Then implement it, perhaps? 🙃
adam-azarchs commentedon Apr 29, 2022
At this point upstream coveragepy has
lcovsupport. I think the main piece that's missing is that there needs to be a way to specify a target for coveragepy inpy_runtimefor hermetic python toolchains.feat(coverage): Register coverage.py to hermetic toolchains
chrislovecnm commentedon Jul 11, 2023
@aignas do we have more work to do on this?
sgammon commentedon Aug 20, 2023
this issue has been open for 6 years
aignas commentedon Aug 20, 2023
I think we can safely close it now as we have docs and there are quite a few versions supporting toolchain with coverage.py enabled.
sgammon commentedon Aug 20, 2023
@aignas I just set up a brand new project on top of rules_python, using Bazel 7 and Bzlmod, and coverage still doesn't work out of the box.
Where do you see toolchains supporting coverage?
adam-azarchs commentedon Aug 21, 2023
https://github.com/bazelbuild/rules_python/blob/main/docs/coverage.md
aignas commentedon Nov 5, 2023
See https://rules-python.readthedocs.io/en/latest/coverage.html
build(deps): bump secretstorage from 3.3.3 to 3.5.0 in /tools/publish (…
workflows: resolve code-scanning alerts and harden security guardrails (