Description
When generating an xml report on Windows, the package element for a name is generated twice:
<coverage version="7.2.1" timestamp="1677844898119" lines-valid="848" lines-covered="807" line-rate="0.9517" branches-valid="201" branches-covered="166" branch-rate="0.8259" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.2.1 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>(...)</source>
</sources>
<packages>
<package name="cd.python" line-rate="0.9511" branch-rate="0.8259" complexity="0">
<classes>
(...)
</classes>
</package>
<package name="cd.python.interpreter" line-rate="1" branch-rate="1" complexity="0">
<classes>
(...)
</classes>
</package>
<package name="cd.python" line-rate="1" branch-rate="1" complexity="0">
<classes>
(...)
</classes>
</package>
</packages>
</coverage>
This is generating a problem, when the report needs to be read with the Jenskins Code Coverage API plugin, as only the last element with the same name is used. The last element usually only consists of one file.
On debugging the XMLReporter
it seems one package (with one file) is generated with a wrong package name:
This seems to be due to the fr.relative_filename()
missing the path name conversion.
I'll provide a pull request for this issue.
To Reproduce
As the code I am working on is proprietary, I have no code base to test this, but I hope my description was good enough.
Python version: Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)] on win32
Coverage version: 7.2.1
Expected behavior
Expected behavior is only one package element per individual package:
<coverage version="7.2.1" timestamp="1677844898119" lines-valid="848" lines-covered="807" line-rate="0.9517" branches-valid="201" branches-covered="166" branch-rate="0.8259" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.2.1 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>(...)</source>
</sources>
<packages>
<package name="cd.python" line-rate="0.9511" branch-rate="0.8259" complexity="0">
<classes>
(...)
</classes>
</package>
<package name="cd.python.interpreter" line-rate="1" branch-rate="1" complexity="0">
<classes>
(...)
</classes>
</package>
</packages>
</coverage>