|
| 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, |
| 14 | + "kotlinx-coroutines-android" to 50, |
| 15 | + "kotlinx-coroutines-javafx" to 39, // JavaFx is not tested on TC because its graphic subsystem cannot be initialized in headless mode |
| 16 | + |
| 17 | + // TODO figure it out, these probably should be fixed |
| 18 | + "kotlinx-coroutines-debug" to 84, |
| 19 | + "kotlinx-coroutines-reactive" to 65, |
| 20 | + "kotlinx-coroutines-reactor" to 65, |
| 21 | + "kotlinx-coroutines-rx2" to 78, |
| 22 | + "kotlinx-coroutines-slf4j" to 81 |
| 23 | +) |
| 24 | + |
| 25 | +extensions.configure<KoverExtension> { |
| 26 | + disabledProjects = notCovered |
| 27 | + /* |
| 28 | + * Is explicitly enabled on TC in a separate build step. |
| 29 | + * Examples: |
| 30 | + * ./gradlew :p:check -- doesn't verify coverage |
| 31 | + * ./gradlew :p:check -Pkover.enabled=true -- verifies coverage |
| 32 | + * ./gradlew :p:koverReport -Pkover.enabled=true -- generates report |
| 33 | + */ |
| 34 | + isDisabled = !(properties["kover.enabled"]?.toString()?.toBoolean() ?: false) |
| 35 | +} |
| 36 | + |
| 37 | +subprojects { |
| 38 | + val projectName = name |
| 39 | + if (projectName in notCovered) return@subprojects |
| 40 | + tasks.withType<KoverVerificationTask> { |
| 41 | + rule { |
| 42 | + bound { |
| 43 | + /* |
| 44 | + * 85 is our baseline that we aim to raise to 90+. |
| 45 | + * Missing coverage is typically due to bugs in the agent |
| 46 | + * (e.g. signatures deprecated with an error are counted), |
| 47 | + * sometimes it's various diagnostic `toString` or `catch` for OOMs/VerificationErrors, |
| 48 | + * but some places are definitely worth visiting. |
| 49 | + */ |
| 50 | + minValue = expectedCoverage[projectName] ?: 85 // COVERED_LINES_PERCENTAGE |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments