Skip to content

Commit 1c5c1d2

Browse files
qwwdfsadpablobaxter
authored andcommitted
Update Kover to 0.5.0 (Kotlin#3183)
* Update Kover to 0.5.0 * Update robolectric to workaround robolectric/robolectric#5456 and then workaround all the update consequences
1 parent d75d306 commit 1c5c1d2

File tree

14 files changed

+76
-39
lines changed

14 files changed

+76
-39
lines changed

buildSrc/build.gradle.kts

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,9 @@ dependencies {
5959
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
6060
}
6161
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.5.3") // Android API check
62-
implementation("org.jetbrains.kotlinx:kover:${version("kover")}")
62+
implementation("org.jetbrains.kotlinx:kover:${version("kover")}") {
63+
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
64+
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
65+
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
66+
}
6367
}

buildSrc/src/main/kotlin/UnpackAar.kt

+32-1
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,49 @@
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
import org.gradle.api.*
56
import org.gradle.api.artifacts.transform.InputArtifact
67
import org.gradle.api.artifacts.transform.TransformAction
78
import org.gradle.api.artifacts.transform.TransformOutputs
89
import org.gradle.api.artifacts.transform.TransformParameters
10+
import org.gradle.api.attributes.*
911
import org.gradle.api.file.FileSystemLocation
1012
import org.gradle.api.provider.Provider
13+
import org.gradle.kotlin.dsl.*
1114
import java.io.File
1215
import java.nio.file.Files
1316
import java.util.zip.ZipEntry
1417
import java.util.zip.ZipFile
1518

16-
// TODO move back to kotlinx-coroutines-play-services when it's migrated to the kts
19+
// Attributes used by aar dependencies
20+
val artifactType = Attribute.of("artifactType", String::class.java)
21+
val unpackedAar = Attribute.of("unpackedAar", Boolean::class.javaObjectType)
22+
23+
fun Project.configureAar() = configurations.configureEach {
24+
afterEvaluate {
25+
if (isCanBeResolved && !isCanBeConsumed) {
26+
attributes.attribute(unpackedAar, true) // request all AARs to be unpacked
27+
}
28+
}
29+
}
30+
31+
fun DependencyHandlerScope.configureAarUnpacking() {
32+
attributesSchema {
33+
attribute(unpackedAar)
34+
}
35+
36+
artifactTypes {
37+
create("aar") {
38+
attributes.attribute(unpackedAar, false)
39+
}
40+
}
41+
42+
registerTransform(UnpackAar::class.java) {
43+
from.attribute(unpackedAar, false).attribute(artifactType, "aar")
44+
to.attribute(unpackedAar, true).attribute(artifactType, "jar")
45+
}
46+
}
47+
1748
@Suppress("UnstableApiUsage")
1849
abstract class UnpackAar : TransformAction<TransformParameters.None> {
1950
@get:InputArtifact

buildSrc/src/main/kotlin/kover-conventions.gradle.kts

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ val expectedCoverage = mutableMapOf(
1313
"kotlinx-coroutines-swing" to 70, // awaitFrame is not tested
1414
"kotlinx-coroutines-javafx" to 39, // JavaFx is not tested on TC because its graphic subsystem cannot be initialized in headless mode
1515

16-
// Re-evaluate this along with Kover update where deprecated with error+ functions are not considered as uncovered: IDEA-287459
17-
"kotlinx-coroutines-reactor" to 65,
18-
"kotlinx-coroutines-rx2" to 78
19-
)
16+
// Reactor has lower coverage in general due to various fatal error handling features
17+
"kotlinx-coroutines-reactor" to 75)
2018

2119
extensions.configure<KoverExtension> {
2220
disabledProjects = notCovered
@@ -28,6 +26,8 @@ extensions.configure<KoverExtension> {
2826
* ./gradlew :p:koverReport -Pkover.enabled=true -- generates report
2927
*/
3028
isDisabled = !(properties["kover.enabled"]?.toString()?.toBoolean() ?: false)
29+
// TODO remove when updating Kover to version 0.5.x
30+
intellijEngineVersion.set("1.0.657")
3131
}
3232

3333
subprojects {

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ rxjava3_version=3.0.2
2323
javafx_version=11.0.2
2424
javafx_plugin_version=0.0.8
2525
binary_compatibility_validator_version=0.8.0
26-
kover_version=0.5.0-RC2
26+
kover_version=0.5.0
2727
blockhound_version=1.0.2.RELEASE
2828
jna_version=5.9.0
2929

3030
# Android versions
3131
android_version=4.1.1.4
3232
androidx_annotation_version=1.1.0
33-
robolectric_version=4.0.2
33+
robolectric_version=4.4
3434
baksmali_version=2.2.7
3535

3636
# JS

integration/kotlinx-coroutines-play-services/build.gradle.kts

+6-25
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,17 @@
44

55
val tasksVersion = "16.0.1"
66

7-
val artifactType = Attribute.of("artifactType", String::class.java)
8-
val unpackedAar = Attribute.of("unpackedAar", Boolean::class.javaObjectType)
9-
10-
configurations.configureEach {
11-
afterEvaluate {
12-
if (isCanBeResolved) {
13-
attributes.attribute(unpackedAar, true) // request all AARs to be unpacked
14-
}
15-
}
16-
}
7+
project.configureAar()
178

189
dependencies {
19-
attributesSchema {
20-
attribute(unpackedAar)
21-
}
22-
23-
artifactTypes {
24-
create("aar") {
25-
attributes.attribute(unpackedAar, false)
26-
}
27-
}
28-
29-
registerTransform(UnpackAar::class.java) {
30-
from.attribute(unpackedAar, false).attribute(artifactType, "aar")
31-
to.attribute(unpackedAar, true).attribute(artifactType, "jar")
32-
}
33-
10+
configureAarUnpacking()
3411
api("com.google.android.gms:play-services-tasks:$tasksVersion") {
3512
exclude(group="com.android.support")
3613
}
14+
15+
// Required by robolectric
16+
testImplementation("androidx.test:core:1.2.0")
17+
testImplementation("androidx.test:monitor:1.2.0")
3718
}
3819

3920
externalDocumentationLink(

reactive/kotlinx-coroutines-reactor/build.gradle.kts

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ externalDocumentationLink(
2929
)
3030

3131
val commonKoverExcludes = listOf(
32-
"kotlinx.coroutines.reactor.FlowKt" // Deprecated
32+
"kotlinx.coroutines.reactor.FlowKt", // Deprecated
33+
"kotlinx.coroutines.reactor.ConvertKt\$asFlux$1" // Deprecated
3334
)
3435

3536
tasks.koverHtmlReport {

ui/kotlinx-coroutines-android/android-unit-tests/build.gradle.kts

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

5+
project.configureAar()
6+
57
dependencies {
6-
kotlinCompilerPluginClasspathMain(project(":kotlinx-coroutines-core"))
8+
configureAarUnpacking()
9+
710
testImplementation("com.google.android:android:${version("android")}")
811
testImplementation("org.robolectric:robolectric:${version("robolectric")}")
12+
// Required by robolectric
13+
testImplementation("androidx.test:core:1.2.0")
14+
testImplementation("androidx.test:monitor:1.2.0")
15+
916
testImplementation(project(":kotlinx-coroutines-test"))
1017
testImplementation(project(":kotlinx-coroutines-android"))
1118
}

ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/CustomizedRobolectricTest.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class InitMainDispatcherBeforeRobolectricTestRunner(testClass: Class<*>) : Robol
2626

2727
@Config(manifest = Config.NONE, sdk = [28])
2828
@RunWith(InitMainDispatcherBeforeRobolectricTestRunner::class)
29+
@LooperMode(LooperMode.Mode.LEGACY)
2930
class CustomizedRobolectricTest : TestBase() {
3031
@Test
3132
fun testComponent() {
@@ -52,4 +53,4 @@ class CustomizedRobolectricTest : TestBase() {
5253
mainLooper.unPause()
5354
assertTrue(component.launchCompleted)
5455
}
55-
}
56+
}

ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/FirstRobolectricTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import kotlin.test.*
1515

1616
@RunWith(RobolectricTestRunner::class)
1717
@Config(manifest = Config.NONE, sdk = [28])
18+
@LooperMode(LooperMode.Mode.LEGACY)
1819
open class FirstRobolectricTest {
1920
@Test
2021
fun testComponent() {

ui/kotlinx-coroutines-android/build.gradle.kts

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@ configurations {
1010

1111
repositories {
1212
mavenCentral()
13-
jcenter() // https://youtrack.jetbrains.com/issue/IDEA-261387
1413
}
14+
15+
project.configureAar()
16+
1517
dependencies {
18+
configureAarUnpacking()
19+
1620
compileOnly("com.google.android:android:${version("android")}")
1721
compileOnly("androidx.annotation:annotation:${version("androidx_annotation")}")
1822

1923
testImplementation("com.google.android:android:${version("android")}")
2024
testImplementation("org.robolectric:robolectric:${version("robolectric")}")
21-
testImplementation("org.smali:baksmali:${version("baksmali")}")
25+
// Required by robolectric
26+
testImplementation("androidx.test:core:1.2.0")
27+
testImplementation("androidx.test:monitor:1.2.0")
28+
2229

30+
testImplementation("org.smali:baksmali:${version("baksmali")}")
2331
"r8"("com.android.tools.build:builder:7.1.0-alpha01")
2432
}
2533

ui/kotlinx-coroutines-android/test/AndroidExceptionPreHandlerTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kotlin.test.*
1313

1414
@RunWith(RobolectricTestRunner::class)
1515
@Config(manifest = Config.NONE, sdk = [27])
16+
@LooperMode(LooperMode.Mode.LEGACY)
1617
class AndroidExceptionPreHandlerTest : TestBase() {
1718
@Test
1819
fun testUnhandledException() = runTest {

ui/kotlinx-coroutines-android/test/DisabledHandlerTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.robolectric.annotation.*
1313

1414
@RunWith(RobolectricTestRunner::class)
1515
@Config(manifest = Config.NONE, sdk = [28])
16+
@LooperMode(LooperMode.Mode.LEGACY)
1617
class DisabledHandlerTest : TestBase() {
1718

1819
private var delegateToSuper = false

ui/kotlinx-coroutines-android/test/HandlerDispatcherAsyncTest.kt

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import kotlin.test.*
1818

1919
@RunWith(RobolectricTestRunner::class)
2020
@Config(manifest = Config.NONE, sdk = [28])
21+
@LooperMode(LooperMode.Mode.LEGACY)
2122
class HandlerDispatcherAsyncTest : TestBase() {
2223

2324
/**

ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import kotlin.test.*
1616

1717
@RunWith(RobolectricTestRunner::class)
1818
@Config(manifest = Config.NONE, sdk = [28])
19+
@LooperMode(LooperMode.Mode.LEGACY)
1920
class HandlerDispatcherTest : TestBase() {
2021
@Test
2122
fun testImmediateDispatcherYield() = runBlocking(Dispatchers.Main) {
@@ -121,7 +122,6 @@ class HandlerDispatcherTest : TestBase() {
121122
}
122123

123124
private fun CoroutineScope.doTestAwaitWithDetectedChoreographer() {
124-
ShadowChoreographer.reset()
125125
ShadowChoreographer.setPostFrameCallbackDelay(100)
126126
val mainLooper = Shadows.shadowOf(Looper.getMainLooper())
127127
launch(Dispatchers.Main, start = CoroutineStart.UNDISPATCHED) {

0 commit comments

Comments
 (0)