pants icon indicating copy to clipboard operation
pants copied to clipboard

Python raw coverage report shows 0%

Open idan-at opened this issue 1 year ago • 4 comments

Describe the bug When generating a raw coverage report, it shows all files as 0% covered.

Pants version 2.17.0

OS MacOS

Additional info Reproducing repository with instructions: https://github.com/idan-at/pants-coverage-test

idan-at avatar Dec 24 '23 08:12 idan-at

Hi,

You are missing relative_files = true under your [run] section in .coveragerc. Per the documentation, this is required for Pants to work. Adding this produces the expected output in your HTML report generated by check.py in your repository:

Screenshot 2023-12-24 at 3 55 08 PM

jensenja avatar Dec 24 '23 21:12 jensenja

Thanks John, I totally missed the docs for that. Closing this issue.

idan-at avatar Dec 25 '23 07:12 idan-at

Hm, I think there's something deeper going on here: Pants attempts to set that property itself, but that is seemingly not working: https://github.com/pantsbuild/pants/blob/e4aaf382459c4362450440b8c20518af446f686c/src/python/pants/backend/python/goals/coverage_py.py#L276-L298

As such, reopening.

huonw avatar Jan 09 '24 21:01 huonw

I've tried updating the filename of the config from the example above to end with .toml, didn't help

idan-at avatar Jan 10 '24 08:01 idan-at