kotlinx-kover
kotlinx-kover copied to clipboard
[XML] Inaccurate coverage for files with same name, but from different source sets
Describe the bug
XML report generates inaccurate coverage for files with same name, but from different source sets.
Take the following project structure as an example:
where KoverFile.kt
will contain:
-
KoverCommonClass
forcommonMain
source set -
KoverJvmClass
forjvmMain
source set.
Generated XML report will look the following way:
<?xml version="1.0" ?>
<report name="Intellij Coverage Report">
<package name="kover/reproducer">
<class name="kover/reproducer/KoverCommonClass" sourcefilename="KoverFile.kt">
...
</class>
<class name="kover/reproducer/KoverJvmClass" sourcefilename="KoverFile.kt">
...
</class>
<sourcefile name="KoverFile.kt">
<line nr="3" mi="0" ci="2" mb="0" cb="0"/>
<line nr="3" mi="0" ci="2" mb="0" cb="0"/>
<line nr="5" mi="0" ci="4" mb="0" cb="0"/>
<line nr="5" mi="0" ci="4" mb="0" cb="0"/>
<counter type="INSTRUCTION" missed="0" covered="12"/>
<counter type="BRANCH" missed="0" covered="0"/>
<counter type="LINE" missed="0" covered="4"/>
</sourcefile>
...
</package>
...
</report>
As you can see, both classes lead to the same source file, the description for which duplicates line numbers. Because the code is the same in both classes, the duplicated lines are the same, but I imagine if the code is vastly different, it'll be a mess.
This leads to codecov.io ignoring such files altogether, presumably because it doesn't know how to map it to project's git structure. See codecov report. This, in turn, affects calculated coverage. Umbrella issue: https://github.com/Kotlin/kotlinx-kover/issues/16
This problem does not exists in HTML reports as it doesn't offer file-based coverage.
(additional files CommonFile
and JvmFile
are added to demonstrate that codecov sees Kotlin files otherwise)
Expected behavior
Not sure what could be done in this situation as it seems to be a limitation of XML report's structure, but maybe some additional kover-specific tags could be added, or some other way to differentiate between source sets.
Reproducer
Project (notice the branch): https://github.com/IgnatBeresnev/kover-reproducers/tree/mpp-same-filename
There are instructions in the README on how the report can be generated and uploaded to codecov.io
Reports Gist with XML report: https://gist.github.com/IgnatBeresnev/418ab0514b699fea7473cb2d4d275480
Environment
- Kover Gradle Plugin version: 0.6.1
- Gradle version: 7.4.2
- Kotlin project type: Kotlin/Multiplatform with Common and JVM source set