Skip to content

Update Kover to 0.5.0 #3183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,9 @@ dependencies {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
}
implementation("ru.vyarus:gradle-animalsniffer-plugin:1.5.3") // Android API check
implementation("org.jetbrains.kotlinx:kover:${version("kover")}")
implementation("org.jetbrains.kotlinx:kover:${version("kover")}") {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
}
}
33 changes: 32 additions & 1 deletion buildSrc/src/main/kotlin/UnpackAar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,49 @@
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

import org.gradle.api.*
import org.gradle.api.artifacts.transform.InputArtifact
import org.gradle.api.artifacts.transform.TransformAction
import org.gradle.api.artifacts.transform.TransformOutputs
import org.gradle.api.artifacts.transform.TransformParameters
import org.gradle.api.attributes.*
import org.gradle.api.file.FileSystemLocation
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.*
import java.io.File
import java.nio.file.Files
import java.util.zip.ZipEntry
import java.util.zip.ZipFile

// TODO move back to kotlinx-coroutines-play-services when it's migrated to the kts
// Attributes used by aar dependencies
val artifactType = Attribute.of("artifactType", String::class.java)
val unpackedAar = Attribute.of("unpackedAar", Boolean::class.javaObjectType)

fun Project.configureAar() = configurations.configureEach {
afterEvaluate {
if (isCanBeResolved && !isCanBeConsumed) {
attributes.attribute(unpackedAar, true) // request all AARs to be unpacked
}
}
}

fun DependencyHandlerScope.configureAarUnpacking() {
attributesSchema {
attribute(unpackedAar)
}

artifactTypes {
create("aar") {
attributes.attribute(unpackedAar, false)
}
}

registerTransform(UnpackAar::class.java) {
from.attribute(unpackedAar, false).attribute(artifactType, "aar")
to.attribute(unpackedAar, true).attribute(artifactType, "jar")
}
}

@Suppress("UnstableApiUsage")
abstract class UnpackAar : TransformAction<TransformParameters.None> {
@get:InputArtifact
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/kover-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ val expectedCoverage = mutableMapOf(
"kotlinx-coroutines-swing" to 70, // awaitFrame is not tested
"kotlinx-coroutines-javafx" to 39, // JavaFx is not tested on TC because its graphic subsystem cannot be initialized in headless mode

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

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

subprojects {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ rxjava3_version=3.0.2
javafx_version=11.0.2
javafx_plugin_version=0.0.8
binary_compatibility_validator_version=0.8.0
kover_version=0.5.0-RC2
kover_version=0.5.0
blockhound_version=1.0.2.RELEASE
jna_version=5.9.0

# Android versions
android_version=4.1.1.4
androidx_annotation_version=1.1.0
robolectric_version=4.0.2
robolectric_version=4.4
baksmali_version=2.2.7

# JS
Expand Down
31 changes: 6 additions & 25 deletions integration/kotlinx-coroutines-play-services/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,17 @@

val tasksVersion = "16.0.1"

val artifactType = Attribute.of("artifactType", String::class.java)
val unpackedAar = Attribute.of("unpackedAar", Boolean::class.javaObjectType)

configurations.configureEach {
afterEvaluate {
if (isCanBeResolved) {
attributes.attribute(unpackedAar, true) // request all AARs to be unpacked
}
}
}
project.configureAar()

dependencies {
attributesSchema {
attribute(unpackedAar)
}

artifactTypes {
create("aar") {
attributes.attribute(unpackedAar, false)
}
}

registerTransform(UnpackAar::class.java) {
from.attribute(unpackedAar, false).attribute(artifactType, "aar")
to.attribute(unpackedAar, true).attribute(artifactType, "jar")
}

configureAarUnpacking()
api("com.google.android.gms:play-services-tasks:$tasksVersion") {
exclude(group="com.android.support")
}

// Required by robolectric
testImplementation("androidx.test:core:1.2.0")
testImplementation("androidx.test:monitor:1.2.0")
}

externalDocumentationLink(
Expand Down
3 changes: 2 additions & 1 deletion reactive/kotlinx-coroutines-reactor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ externalDocumentationLink(
)

val commonKoverExcludes = listOf(
"kotlinx.coroutines.reactor.FlowKt" // Deprecated
"kotlinx.coroutines.reactor.FlowKt", // Deprecated
"kotlinx.coroutines.reactor.ConvertKt\$asFlux$1" // Deprecated
)

tasks.koverHtmlReport {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

project.configureAar()

dependencies {
kotlinCompilerPluginClasspathMain(project(":kotlinx-coroutines-core"))
configureAarUnpacking()

testImplementation("com.google.android:android:${version("android")}")
testImplementation("org.robolectric:robolectric:${version("robolectric")}")
// Required by robolectric
testImplementation("androidx.test:core:1.2.0")
testImplementation("androidx.test:monitor:1.2.0")

testImplementation(project(":kotlinx-coroutines-test"))
testImplementation(project(":kotlinx-coroutines-android"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class InitMainDispatcherBeforeRobolectricTestRunner(testClass: Class<*>) : Robol

@Config(manifest = Config.NONE, sdk = [28])
@RunWith(InitMainDispatcherBeforeRobolectricTestRunner::class)
@LooperMode(LooperMode.Mode.LEGACY)
class CustomizedRobolectricTest : TestBase() {
@Test
fun testComponent() {
Expand All @@ -52,4 +53,4 @@ class CustomizedRobolectricTest : TestBase() {
mainLooper.unPause()
assertTrue(component.launchCompleted)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlin.test.*

@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE, sdk = [28])
@LooperMode(LooperMode.Mode.LEGACY)
open class FirstRobolectricTest {
@Test
fun testComponent() {
Expand Down
12 changes: 10 additions & 2 deletions ui/kotlinx-coroutines-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ configurations {

repositories {
mavenCentral()
jcenter() // https://youtrack.jetbrains.com/issue/IDEA-261387
}

project.configureAar()

dependencies {
configureAarUnpacking()

compileOnly("com.google.android:android:${version("android")}")
compileOnly("androidx.annotation:annotation:${version("androidx_annotation")}")

testImplementation("com.google.android:android:${version("android")}")
testImplementation("org.robolectric:robolectric:${version("robolectric")}")
testImplementation("org.smali:baksmali:${version("baksmali")}")
// Required by robolectric
testImplementation("androidx.test:core:1.2.0")
testImplementation("androidx.test:monitor:1.2.0")


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlin.test.*

@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE, sdk = [27])
@LooperMode(LooperMode.Mode.LEGACY)
class AndroidExceptionPreHandlerTest : TestBase() {
@Test
fun testUnhandledException() = runTest {
Expand Down
1 change: 1 addition & 0 deletions ui/kotlinx-coroutines-android/test/DisabledHandlerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.robolectric.annotation.*

@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE, sdk = [28])
@LooperMode(LooperMode.Mode.LEGACY)
class DisabledHandlerTest : TestBase() {

private var delegateToSuper = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import kotlin.test.*

@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE, sdk = [28])
@LooperMode(LooperMode.Mode.LEGACY)
class HandlerDispatcherAsyncTest : TestBase() {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import kotlin.test.*

@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE, sdk = [28])
@LooperMode(LooperMode.Mode.LEGACY)
class HandlerDispatcherTest : TestBase() {
@Test
fun testImmediateDispatcherYield() = runBlocking(Dispatchers.Main) {
Expand Down Expand Up @@ -121,7 +122,6 @@ class HandlerDispatcherTest : TestBase() {
}

private fun CoroutineScope.doTestAwaitWithDetectedChoreographer() {
ShadowChoreographer.reset()
ShadowChoreographer.setPostFrameCallbackDelay(100)
val mainLooper = Shadows.shadowOf(Looper.getMainLooper())
launch(Dispatchers.Main, start = CoroutineStart.UNDISPATCHED) {
Expand Down