From be7cbbb7623b853872b031cc3a735c8e503a400d Mon Sep 17 00:00:00 2001 From: "Sergey.Shanshin" Date: Thu, 13 Jan 2022 04:54:00 +0300 Subject: [PATCH] Added reports filtering Resolves #17 --- README.md | 39 +++++++++++- .../functional/cases/ReportsFilteringTests.kt | 62 +++++++++++++++++++ .../kover/test/functional/core/Builder.kt | 2 +- src/main/kotlin/kotlinx/kover/KoverPlugin.kt | 5 -- .../kotlinx/kover/api/KoverTaskExtension.kt | 8 ++- .../kotlinx/kover/engines/commons/Reports.kt | 21 +++++++ .../kover/engines/intellij/IntellijAgent.kt | 23 +------ .../kover/engines/intellij/IntellijReports.kt | 43 ++++++++++--- .../kotlinx/kover/tasks/KoverHtmlReport.kt | 4 ++ .../kotlinx/kover/tasks/KoverMergedTask.kt | 25 ++++++++ .../kotlinx/kover/tasks/KoverProjectTask.kt | 26 ++++++++ .../kotlinx/kover/tasks/KoverVerification.kt | 54 +++++----------- .../kotlinx/kover/tasks/KoverXmlReport.kt | 4 ++ 13 files changed, 236 insertions(+), 80 deletions(-) create mode 100644 src/functionalTest/kotlin/kotlinx/kover/test/functional/cases/ReportsFilteringTests.kt diff --git a/README.md b/README.md index 604196f3..22694cbe 100644 --- a/README.md +++ b/README.md @@ -204,11 +204,17 @@ the project in which the plugin is applied (usually this is the root project): tasks.koverMergedHtmlReport { isEnabled = true // false to disable report generation htmlReportDir.set(layout.buildDirectory.dir("my-merged-report/html-result")) + + includes = listOf("com.example.*") // inclusion rules for classes + excludes = listOf("com.example.subpackage.*") // exclusion rules for classes } tasks.koverMergedXmlReport { isEnabled = true // false to disable report generation xmlReportFile.set(layout.buildDirectory.file("my-merged-report/result.xml")) + + includes = listOf("com.example.*") // inclusion rules for classes + excludes = listOf("com.example.subpackage.*") // exclusion rules for classes } ``` @@ -220,11 +226,17 @@ tasks.koverMergedXmlReport { tasks.koverMergedHtmlReport { enabled = true // false to disable report generation htmlReportDir.set(layout.buildDirectory.dir("my-merged-report/html-result")) + + includes = ['com.example.*'] // inclusion rules for classes + excludes = ['com.example.subpackage.*'] // exclusion rules for classes } tasks.koverMergedXmlReport { enabled = true // false to disable report generation xmlReportFile.set(layout.buildDirectory.file("my-merged-report/result.xml")) + + includes = ['com.example.*'] // inclusion rules for classes + excludes = ['com.example.subpackage.*'] // exclusion rules for classes } ``` @@ -241,11 +253,17 @@ the corresponding tasks in this project: tasks.koverHtmlReport { isEnabled = true // false to disable report generation htmlReportDir.set(layout.buildDirectory.dir("my-project-report/html-result")) + + includes = listOf("com.example.*") // inclusion rules for classes + excludes = listOf("com.example.subpackage.*") // exclusion rules for classes } tasks.koverXmlReport { isEnabled = true // false to disable report generation xmlReportFile.set(layout.buildDirectory.file("my-project-report/result.xml")) + + includes = listOf("com.example.*") // inclusion rules for classes + excludes = listOf("com.example.subpackage.*") // exclusion rules for classes } ``` @@ -257,11 +275,16 @@ tasks.koverXmlReport { tasks.koverHtmlReport { enabled = true // false to disable report generation htmlReportDir.set(layout.buildDirectory.dir("my-project-report/html-result")) + + includes = ['com.example.*'] // inclusion rules for classes + excludes = ['com.example.subpackage.*'] // exclusion rules for classes } tasks.koverXmlReport { enabled = true // false to disable report generation xmlReportFile.set(layout.buildDirectory.file("my-project-report/result.xml")) + includes = ['com.example.*'] // inclusion rules for classes + excludes = ['com.example.subpackage.*'] // exclusion rules for classes } ``` @@ -308,7 +331,7 @@ kover { coverageEngine.set(kotlinx.kover.api.CoverageEngine.INTELLIJ) // change instrumentation agent and reporter intellijEngineVersion.set("1.0.640") // change version of IntelliJ agent and reporter jacocoEngineVersion.set("0.8.7") // change version of JaCoCo agent and reporter - generateReportOnCheck.set(true) // false to do not execute `koverMergedReport` task before `check` task + generateReportOnCheck = true // false to do not execute `koverMergedReport` task before `check` task disabledProjects = setOf() // setOf("project-name") to disable coverage for project with name `project-name` instrumentAndroidPackage = false // true to instrument packages `android.*` and `com.android.*` runAllTestsForProjectTask = false // true to run all tests in all projects if `koverHtmlReport`, `koverXmlReport`, `koverReport`, `koverVerify` or `check` tasks executed on some project @@ -325,7 +348,7 @@ kover { coverageEngine.set(kotlinx.kover.api.CoverageEngine.INTELLIJ) // change instrumentation agent and reporter intellijEngineVersion.set('1.0.640') // change version of IntelliJ agent and reporter jacocoEngineVersion.set('0.8.7') // change version of JaCoCo agent and reporter - generateReportOnCheck.set(true) // false to do not execute `koverMergedReport` task before `check` task + generateReportOnCheck = true // false to do not execute `koverMergedReport` task before `check` task disabledProjects = [] // ["project-name"] to disable coverage for project with name `project-name` instrumentAndroidPackage = false // true to instrument packages `android.*` and `com.android.*` runAllTestsForProjectTask = false // true to run all tests in all projects if `koverHtmlReport`, `koverXmlReport`, `koverReport`, `koverVerify` or `check` tasks executed on some project @@ -349,6 +372,9 @@ is applied (usually this is the root project): ```kotlin tasks.koverMergedVerify { + includes = listOf("com.example.*") // inclusion rules for classes + excludes = listOf("com.example.subpackage.*") // exclusion rules for classes + rule { name = "Minimum number of lines covered" bound { @@ -380,6 +406,9 @@ tasks.koverMergedVerify { ```groovy tasks.koverMergedVerify { + includes = ['com.example.*'] // inclusion rules for classes + excludes = ['com.example.subpackage.*'] // exclusion rules for classes + rule { name = "Minimum number of lines covered" bound { @@ -413,6 +442,9 @@ To add rules for code coverage checks for the code of one specific project, you ```kotlin tasks.koverVerify { + includes = listOf("com.example.*") // inclusion rules for classes + excludes = listOf("com.example.subpackage.*") // exclusion rules for classes + rule { name = "Minimal line coverage rate in percent" bound { @@ -428,6 +460,9 @@ tasks.koverVerify { ```groovy tasks.koverVerify { + includes = ['com.example.*'] // inclusion rules for classes + excludes = ['com.example.subpackage.*'] // exclusion rules for classes + rule { name = "Minimal line coverage rate in percent" bound { diff --git a/src/functionalTest/kotlin/kotlinx/kover/test/functional/cases/ReportsFilteringTests.kt b/src/functionalTest/kotlin/kotlinx/kover/test/functional/cases/ReportsFilteringTests.kt new file mode 100644 index 00000000..c40ceea9 --- /dev/null +++ b/src/functionalTest/kotlin/kotlinx/kover/test/functional/cases/ReportsFilteringTests.kt @@ -0,0 +1,62 @@ +package kotlinx.kover.test.functional.cases + +import kotlinx.kover.test.functional.cases.utils.* +import kotlinx.kover.test.functional.core.* +import kotlinx.kover.test.functional.core.BaseGradleScriptTest +import kotlin.test.* + +internal class ReportsFilteringTests : BaseGradleScriptTest() { + + @Test + fun testExclude() { + builder("Test exclusion of classes from XML report") + .languages(GradleScriptLanguage.KOTLIN, GradleScriptLanguage.GROOVY) + .sources("simple") + .config( + """ + tasks.koverMergedXmlReport { + excludes = listOf("org.jetbrains.*Exa?ple*") + }""".trimIndent(), + """ + tasks.koverMergedXmlReport { + excludes = ['org.jetbrains.*Exa?ple*'] + }""".trimIndent() + ) + .build() + .run("build") { + xml(defaultXmlReport()) { + assertCounterAbsent(classCounter("org.jetbrains.ExampleClass")) + assertCounterCovered(classCounter("org.jetbrains.SecondClass")) + } + } + } + + @Test + fun testExcludeInclude() { + builder("Test inclusion and exclusion of classes in XML report") + .languages(GradleScriptLanguage.KOTLIN, GradleScriptLanguage.GROOVY) + .sources("simple") + .config( + """ + tasks.koverMergedXmlReport { + includes = listOf("org.jetbrains.*Cla?s") + excludes = listOf("org.jetbrains.*Exa?ple*") + }""".trimIndent(), + + """ + tasks.koverMergedXmlReport { + includes = ['org.jetbrains.*Cla?s'] + excludes = ['org.jetbrains.*Exa?ple*'] + }""".trimIndent() + ) + .build() + .run("build") { + xml(defaultXmlReport()) { + assertCounterAbsent(classCounter("org.jetbrains.ExampleClass")) + assertCounterAbsent(classCounter("org.jetbrains.Unused")) + assertCounterFullyCovered(classCounter("org.jetbrains.SecondClass")) + } + } + } + +} diff --git a/src/functionalTest/kotlin/kotlinx/kover/test/functional/core/Builder.kt b/src/functionalTest/kotlin/kotlinx/kover/test/functional/core/Builder.kt index 5098e88c..c72f22e2 100644 --- a/src/functionalTest/kotlin/kotlinx/kover/test/functional/core/Builder.kt +++ b/src/functionalTest/kotlin/kotlinx/kover/test/functional/core/Builder.kt @@ -117,7 +117,7 @@ private open class ProjectBuilderImpl>(val projectState: P } override fun config(kotlin: String, groovy: String): B { - projectState.testScripts += GradleScript(kotlin, groovy) + projectState.scripts += GradleScript(kotlin, groovy) return this as B } diff --git a/src/main/kotlin/kotlinx/kover/KoverPlugin.kt b/src/main/kotlin/kotlinx/kover/KoverPlugin.kt index d5a6125d..e2f1895f 100644 --- a/src/main/kotlin/kotlinx/kover/KoverPlugin.kt +++ b/src/main/kotlin/kotlinx/kover/KoverPlugin.kt @@ -33,7 +33,6 @@ import org.gradle.api.provider.* import org.gradle.api.tasks.* import org.gradle.api.tasks.testing.* import org.gradle.process.* -import java.io.* import kotlin.reflect.* class KoverPlugin : Plugin { @@ -86,8 +85,6 @@ class KoverPlugin : Plugin { projectProviders ) { it.onlyIf { t -> (t as KoverVerificationTask).rules.isNotEmpty() } - // kover takes counter values from XML file. Remove after reporter upgrade - it.mustRunAfter(xmlReportTask) it.description = "Verifies code coverage metrics of one project based on specified rules." } @@ -141,8 +138,6 @@ class KoverPlugin : Plugin { providers ) { it.onlyIf { t -> (t as KoverMergedVerificationTask).rules.isNotEmpty() } - // kover takes counter values from XML file. Remove after reporter upgrade - it.mustRunAfter(xmlReportTask) it.description = "Verifies code coverage metrics of all projects based on specified rules." } diff --git a/src/main/kotlin/kotlinx/kover/api/KoverTaskExtension.kt b/src/main/kotlin/kotlinx/kover/api/KoverTaskExtension.kt index d8954772..cf3caa4b 100644 --- a/src/main/kotlin/kotlinx/kover/api/KoverTaskExtension.kt +++ b/src/main/kotlin/kotlinx/kover/api/KoverTaskExtension.kt @@ -29,7 +29,9 @@ open class KoverTaskExtension(objects: ObjectFactory) { public val binaryReportFile: Property = objects.property(File::class.java) /** - * Specifies class inclusion rules coverage engine. Exclusion rules have priority over inclusion ones. + * Specifies class instrumentation inclusion rules. + * Only the specified classes may be instrumented, for the remaining classes there will be zero coverage. + * Exclusion rules have priority over inclusion ones. * * Inclusion rules are represented as a set of fully-qualified names of the classes being instrumented. * It's possible to use `*` and `?` wildcards. @@ -38,7 +40,9 @@ open class KoverTaskExtension(objects: ObjectFactory) { public var includes: List = emptyList() /** - * Specifies class exclusion rules for coverage engine. Exclusion rules have priority over inclusion ones. + * Specifies class instrumentation exclusion rules. + * The specified classes will not be instrumented and there will be zero coverage for them. + * Exclusion rules have priority over inclusion ones. * * Exclusion rules are represented as a set of fully-qualified names of the classes being instrumented. * It's possible to use `*` and `?` wildcards. diff --git a/src/main/kotlin/kotlinx/kover/engines/commons/Reports.kt b/src/main/kotlin/kotlinx/kover/engines/commons/Reports.kt index bd5cc91d..ac9933bb 100644 --- a/src/main/kotlin/kotlinx/kover/engines/commons/Reports.kt +++ b/src/main/kotlin/kotlinx/kover/engines/commons/Reports.kt @@ -4,3 +4,24 @@ import java.io.* internal class Report(val files: List, val projects: List) internal class ProjectInfo(val sources: Iterable, val outputs: Iterable) + +private val regexMetacharactersSet = "<([{\\^-=$!|]})+.>".toSet() + +/** + * Replaces characters `*` or `.` to `.*` and `.` regexp characters. + */ +internal fun String.wildcardsToRegex(): String { + // in most cases, the characters `*` or `.` will be present therefore, we increase the capacity in advance + val builder = StringBuilder(length * 2) + + forEach { char -> + when (char) { + in regexMetacharactersSet -> builder.append('\\').append(char) + '*' -> builder.append('.').append("*") + '?' -> builder.append('.') + else -> builder.append(char) + } + } + + return builder.toString() +} diff --git a/src/main/kotlin/kotlinx/kover/engines/intellij/IntellijAgent.kt b/src/main/kotlin/kotlinx/kover/engines/intellij/IntellijAgent.kt index 7923bf46..0ec50149 100644 --- a/src/main/kotlin/kotlinx/kover/engines/intellij/IntellijAgent.kt +++ b/src/main/kotlin/kotlinx/kover/engines/intellij/IntellijAgent.kt @@ -5,6 +5,7 @@ package kotlinx.kover.engines.intellij import kotlinx.kover.api.* +import kotlinx.kover.engines.commons.* import kotlinx.kover.engines.commons.CoverageAgent import org.gradle.api.* import org.gradle.api.artifacts.* @@ -51,7 +52,7 @@ private class IntellijAgent(private val config: Configuration): CoverageAgent { pw.appendLine(appendToDataFile.toString()) pw.appendLine(samplingMode.toString()) extension.includes.forEach { i -> - pw.appendLine(i.replaceWildcards()) + pw.appendLine(i.wildcardsToRegex()) } if (extension.excludes.isNotEmpty()) { @@ -59,30 +60,12 @@ private class IntellijAgent(private val config: Configuration): CoverageAgent { } extension.excludes.forEach { e -> - pw.appendLine(e.replaceWildcards()) + pw.appendLine(e.wildcardsToRegex()) } } } - - private fun String.replaceWildcards(): String { - // in most cases, the characters `*` or `.` will be present therefore, we increase the capacity in advance - val builder = StringBuilder(length * 2) - - forEach { char -> - when (char) { - in regexMetacharactersSet -> builder.append('\\').append(char) - '*' -> builder.append('.').append("*") - '?' -> builder.append('.') - else -> builder.append(char) - } - } - - return builder.toString() - } } -private val regexMetacharactersSet = "<([{\\^-=$!|]})+.>".toSet() - private fun Project.createIntellijConfig(koverExtension: KoverExtension): Configuration { val config = project.configurations.create("IntellijKoverConfig") config.isVisible = false diff --git a/src/main/kotlin/kotlinx/kover/engines/intellij/IntellijReports.kt b/src/main/kotlin/kotlinx/kover/engines/intellij/IntellijReports.kt index ad961ea3..63a34a89 100644 --- a/src/main/kotlin/kotlinx/kover/engines/intellij/IntellijReports.kt +++ b/src/main/kotlin/kotlinx/kover/engines/intellij/IntellijReports.kt @@ -16,6 +16,8 @@ internal fun Task.intellijReport( report: Report, xmlFile: File?, htmlDir: File?, + includes: List, + excludes: List, classpath: FileCollection ) { xmlFile?.let { @@ -28,7 +30,7 @@ internal fun Task.intellijReport( val argsFile = File(temporaryDir, "intellijreport.json") argsFile.printWriter().use { pw -> - pw.writeReportsJson(report, xmlFile, htmlDir) + pw.writeReportsJson(report, xmlFile, htmlDir, includes, excludes) } project.javaexec { e -> @@ -95,22 +97,37 @@ JSON example: private fun Writer.writeReportsJson( report: Report, xmlFile: File?, - htmlDir: File? + htmlDir: File?, + includes: List, + excludes: List, ) { appendLine("{") appendLine(""" "reports": [ """) appendLine(report.files.joinToString(",\n ", " ") { f -> - """{"ic": "${f.safePath()}"}""" + """{"ic": ${f.jsonString}}""" }) appendLine(""" ], """) xmlFile?.also { - appendLine(""" "xml": "${it.safePath()}",""") + appendLine(""" "xml": ${it.jsonString},""") } htmlDir?.also { - appendLine(""" "html": "${it.safePath()}",""") + appendLine(""" "html": ${it.jsonString},""") + } + + if (includes.isNotEmpty()) { + appendLine(""" "include": {""") + appendLine(includes.joinToString(", ", """ "classes": [""", "]") { i -> i.wildcardsToRegex().jsonString }) + appendLine(""" },""") + } + + if (excludes.isNotEmpty()) { + appendLine(""" "exclude": {""") + appendLine(excludes.joinToString(", ", """ "classes": [""", "]") { e -> e.wildcardsToRegex().jsonString }) + appendLine(""" },""") } + appendLine(""" "modules": [""") report.projects.forEachIndexed { index, aProject -> writeProjectReportJson(aProject, index == (report.projects.size - 1)) @@ -123,19 +140,25 @@ private fun Writer.writeProjectReportJson(projectInfo: ProjectInfo, isLast: Bool appendLine(""" {""") appendLine(""" "output": [""") appendLine( - projectInfo.outputs.joinToString(",\n ", " ") { f -> '"' + f.safePath() + '"' }) + projectInfo.outputs.joinToString(",\n ", " ") { f -> f.jsonString }) appendLine(""" ],""") appendLine(""" "sources": [""") appendLine( - projectInfo.sources.joinToString(",\n ", " ") { f -> '"' + f.safePath() + '"' }) + projectInfo.sources.joinToString(",\n ", " ") { f -> f.jsonString }) appendLine(""" ]""") appendLine(""" }${if (isLast) "" else ","}""") } -private fun File.safePath(): String { - return canonicalPath.replace("\\", "\\\\").replace("\"", "\\\"") -} +private val File.jsonString: String + get() { + return canonicalPath.jsonString + } + +private val String.jsonString: String + get() { + return '"' + replace("\\", "\\\\").replace("\"", "\\\"") + '"' + } internal fun Task.intellijVerification( xmlFile: File, diff --git a/src/main/kotlin/kotlinx/kover/tasks/KoverHtmlReport.kt b/src/main/kotlin/kotlinx/kover/tasks/KoverHtmlReport.kt index 929d29ad..c1ad4afa 100644 --- a/src/main/kotlin/kotlinx/kover/tasks/KoverHtmlReport.kt +++ b/src/main/kotlin/kotlinx/kover/tasks/KoverHtmlReport.kt @@ -27,6 +27,8 @@ open class KoverMergedHtmlReportTask : KoverMergedTask() { report(), null, htmlDirFile, + includes, + excludes, classpath.get() ) } else { @@ -58,6 +60,8 @@ open class KoverHtmlReportTask : KoverProjectTask() { report(), null, htmlDirFile, + includes, + excludes, classpath.get() ) } else { diff --git a/src/main/kotlin/kotlinx/kover/tasks/KoverMergedTask.kt b/src/main/kotlin/kotlinx/kover/tasks/KoverMergedTask.kt index 16fa13f9..8d347722 100644 --- a/src/main/kotlin/kotlinx/kover/tasks/KoverMergedTask.kt +++ b/src/main/kotlin/kotlinx/kover/tasks/KoverMergedTask.kt @@ -34,6 +34,31 @@ open class KoverMergedTask : DefaultTask() { @get:Classpath internal val classpath: Property = project.objects.property(FileCollection::class.java) + /** + * Specifies class inclusion rules into report. + * Only the specified classes may be present in the report. + * Exclusion rules have priority over inclusion ones. + * + * Inclusion rules are represented as a set of fully-qualified names of the classes being instrumented. + * It's possible to use `*` and `?` wildcards. + * + * **Works only with IntelliJ Coverage Engine.** + */ + @get:Input + public var includes: List = emptyList() + + /** + * Specifies class exclusion rules into report. + * The specified classes will definitely be missing from report. + * Exclusion rules have priority over inclusion ones. + * + * Exclusion rules are represented as a set of fully-qualified names of the classes being instrumented. + * It's possible to use `*` and `?` wildcards. + * + * **Works only with IntelliJ Coverage Engine.** + */ + @get:Input + public var excludes: List = emptyList() internal fun report(): Report { val binariesMap = binaryReportFiles.get() diff --git a/src/main/kotlin/kotlinx/kover/tasks/KoverProjectTask.kt b/src/main/kotlin/kotlinx/kover/tasks/KoverProjectTask.kt index 634a5f3f..669a03c9 100644 --- a/src/main/kotlin/kotlinx/kover/tasks/KoverProjectTask.kt +++ b/src/main/kotlin/kotlinx/kover/tasks/KoverProjectTask.kt @@ -30,6 +30,32 @@ abstract class KoverProjectTask : DefaultTask() { @get:Classpath internal val classpath: Property = project.objects.property(FileCollection::class.java) + /** + * Specifies class inclusion rules into report. + * Only the specified classes may be present in the report. + * Exclusion rules have priority over inclusion ones. + * + * Inclusion rules are represented as a set of fully-qualified names of the classes being instrumented. + * It's possible to use `*` and `?` wildcards. + * + * **Works only with IntelliJ Coverage Engine.** + */ + @get:Input + public var includes: List = emptyList() + + /** + * Specifies class exclusion rules into report. + * The specified classes will definitely be missing from report. + * Exclusion rules have priority over inclusion ones. + * + * Exclusion rules are represented as a set of fully-qualified names of the classes being instrumented. + * It's possible to use `*` and `?` wildcards. + * + * **Works only with IntelliJ Coverage Engine.** + */ + @get:Input + public var excludes: List = emptyList() + internal fun report(): Report { return Report(binaryReportFiles.get().toList(), listOf(ProjectInfo(srcDirs.get(), outputDirs.get()))) } diff --git a/src/main/kotlin/kotlinx/kover/tasks/KoverVerification.kt b/src/main/kotlin/kotlinx/kover/tasks/KoverVerification.kt index be5788a6..ade373cd 100644 --- a/src/main/kotlin/kotlinx/kover/tasks/KoverVerification.kt +++ b/src/main/kotlin/kotlinx/kover/tasks/KoverVerification.kt @@ -39,24 +39,7 @@ open class KoverMergedVerificationTask : KoverMergedTask() { @TaskAction fun verify() { - verify(report(), coverageEngine.get(), rulesInternal, classpath.get()) { - val xmlReport = - this.project.tasks.withType(KoverMergedXmlReportTask::class.java) - .findByName(MERGED_XML_REPORT_TASK_NAME) - ?: throw GradleException("Kover: task '$MERGED_XML_REPORT_TASK_NAME' not exists but it is required for verification") - - var xmlFile = xmlReport.xmlReportFile.get().asFile - if (!xmlFile.exists()) { - xmlFile = File(temporaryDir, "counters.xml") - intellijReport( - it, - xmlFile, - null, - xmlReport.classpath.get() - ) - } - xmlFile - } + verify(report(), coverageEngine.get(), rulesInternal, includes, excludes, classpath.get()) } } @@ -81,24 +64,7 @@ open class KoverVerificationTask : KoverProjectTask() { @TaskAction fun verify() { - verify(report(), coverageEngine.get(), rulesInternal, classpath.get()) { - val xmlReport = - this.project.tasks.withType(KoverXmlReportTask::class.java) - .findByName(XML_REPORT_TASK_NAME) - ?: throw GradleException("Kover: task '$XML_REPORT_TASK_NAME' does not exist but it is required for verification") - - var xmlFile = xmlReport.xmlReportFile.get().asFile - if (!xmlFile.exists()) { - xmlFile = File(temporaryDir, "counters.xml") - intellijReport( - it, - xmlFile, - null, - xmlReport.classpath.get() - ) - } - xmlFile - } + verify(report(), coverageEngine.get(), rulesInternal, includes, excludes, classpath.get()) } } @@ -107,12 +73,20 @@ private fun Task.verify( report: Report, engine: CoverageEngine, rules: List, - classpath: FileCollection, - // Remove it after verification is implemented in the IntelliJ reporter - xmlFileProducer: (Report) -> File, + includes: List, + excludes: List, + classpath: FileCollection ) { if (engine == CoverageEngine.INTELLIJ) { - val xmlFile = xmlFileProducer(report) + val xmlFile = File(temporaryDir, "counters.xml") + intellijReport( + report, + xmlFile, + null, + includes, + excludes, + classpath + ) this.intellijVerification(xmlFile, rules) } else { jacocoVerification(report, rules, classpath) diff --git a/src/main/kotlin/kotlinx/kover/tasks/KoverXmlReport.kt b/src/main/kotlin/kotlinx/kover/tasks/KoverXmlReport.kt index cd9ec6f7..44e8bab4 100644 --- a/src/main/kotlin/kotlinx/kover/tasks/KoverXmlReport.kt +++ b/src/main/kotlin/kotlinx/kover/tasks/KoverXmlReport.kt @@ -26,6 +26,8 @@ open class KoverMergedXmlReportTask : KoverMergedTask() { report(), xmlReportFile.get().asFile, null, + includes, + excludes, classpath.get() ) } else { @@ -55,6 +57,8 @@ open class KoverXmlReportTask : KoverProjectTask() { report(), xmlReportFile.get().asFile, null, + includes, + excludes, classpath.get() ) } else {