XcodeCoverageConverter
XcodeCoverageConverter copied to clipboard
Fix cobertura coverage statistics when filtering packages or targets
Cobertura files include overall coverage statistics on the root <coverage> element of the file. When packages or targets are excluded via --exclude-packages, --exclude-targets these overall statistics are no longer valid. While it is possible to recalculate using the included <line> elements within the file it is much easier if xcc could do this automatically.
<!-- a single file is included with 100% coverage, due to excludes 50% is reported -->
<coverage line-rate="0.5" lines-covered="50" lines-valid="100">
<sources>
<source>/Developer/MyProject</source>
</sources>
<packages>
<package name="Developer.MyProject.Sources.Foo" line-rate="1">
<classes>
<class name="Developer.MyProject.Sources.Foo.Bar" line-rate="1">
<lines>
<line number="7" hits="6"/>
</lines>
</class>
</classes>
</package>
</coverage>
This PR recalculates the coverage statistics after any filters have been applied so the resulting cobertura files correctly reflect the statistics of the included files and targets.