Letting coverage report generate XML
For integration with Gitlab (so it can show coverage info in a PR) we need to get the XML coverage output. The only solution currently seems to use custom scripts, duplicating most of the builtin configuration, which looks very suboptimal. Discussion on this topic was launched without much success.
What would the best solution look like to integrate this?
- Have a
--cover-xmltoggle run a newcov-xmlscript? AFAICT that would break all configurations that do use custom scripts, until they add a customcov-xml(unless the custom-scripts system is first changed to avoid having to repeat entries we don't need to change, but one way or the other user expectations will be broken) - Just being able to override a single script with
cov-combine = ["coverage combine", "coverage xml"]would already be a massive improvement - Other ideas?
Just being able to override a single script
for sure, that’s the biggest issue here.
it’s easy to run custom commands in the test environment, but it’s hard to make small modifications to the default scripts.
If something similar to #1477 is merged, to generate an XML report could involve adding the following to hatch.toml
[envs.hatch-test]
reporting = "xml"
This should already be possible with hatch, coverage has its own header for configuration in pyproject.toml so you can have
[tool.coverage.xml]
output = mydir/foo/bar.xml
which will then output xml to the specified output location and does not require changing anything with the hatch default scripts at all. See https://coverage.readthedocs.io/en/7.10.7/config.html#sample-file
No, that just configures how coverage xml behaves. You still have to call it.