• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 import kotlinx.kover.api.*
2 import kotlinx.kover.tasks.*
3 
4 /*
5  * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
6  */
7 apply(plugin = "kover")
8 
9 val notCovered = sourceless + internal + unpublished
10 
11 val expectedCoverage = mutableMapOf(
12     // These have lower coverage in general, it can be eventually fixed
13     "kotlinx-coroutines-swing" to 70, // awaitFrame is not tested
14     "kotlinx-coroutines-javafx" to 39, // JavaFx is not tested on TC because its graphic subsystem cannot be initialized in headless mode
15 
16     // Reactor has lower coverage in general due to various fatal error handling features
17     "kotlinx-coroutines-reactor" to 75)
18 
<lambda>null19 extensions.configure<KoverExtension> {
20     disabledProjects = notCovered
21     /*
22      * Is explicitly enabled on TC in a separate build step.
23      * Examples:
24      * ./gradlew :p:check -- doesn't verify coverage
25      * ./gradlew :p:check -Pkover.enabled=true -- verifies coverage
26      * ./gradlew :p:koverReport -Pkover.enabled=true -- generates report
27      */
28     isDisabled = !(properties["kover.enabled"]?.toString()?.toBoolean() ?: false)
29     // TODO remove when updating Kover to version 0.5.x
30     intellijEngineVersion.set("1.0.657")
31 }
32 
<lambda>null33 subprojects {
34     val projectName = name
35     if (projectName in notCovered) return@subprojects
36     tasks.withType<KoverVerificationTask> {
37         rule {
38             bound {
39                 /*
40                  * 85 is our baseline that we aim to raise to 90+.
41                  * Missing coverage is typically due to bugs in the agent
42                  * (e.g. signatures deprecated with an error are counted),
43                  * sometimes it's various diagnostic `toString` or `catch` for OOMs/VerificationErrors,
44                  * but some places are definitely worth visiting.
45                  */
46                 minValue = expectedCoverage[projectName] ?: 85 // COVERED_LINES_PERCENTAGE
47             }
48         }
49     }
50 
51     tasks.withType<KoverHtmlReportTask> {
52         htmlReportDir.set(file(rootProject.buildDir.toString() + "/kover/" + project.name + "/html"))
53     }
54 }
55