From 188ab3dea99b3ccce429a97325ba59f32a989f8a Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Wed, 22 Jun 2022 11:26:22 +0200 Subject: [PATCH] Move ListAllCoroutineThrowableSubclassesTest to integration-testing and fix assertion --- integration-testing/build.gradle | 9 ++++++++- .../ListAllCoroutineThrowableSubclassesTest.kt | 13 +++---------- 2 files changed, 11 insertions(+), 11 deletions(-) rename {integration/kotlinx-coroutines-guava/test => integration-testing/src/test/kotlin}/ListAllCoroutineThrowableSubclassesTest.kt (77%) diff --git a/integration-testing/build.gradle b/integration-testing/build.gradle index 60b6cdcd07..e87367e180 100644 --- a/integration-testing/build.gradle +++ b/integration-testing/build.gradle @@ -23,6 +23,13 @@ dependencies { } sourceSets { + test { + kotlin + dependencies { + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" + implementation 'com.google.guava:guava:31.1-jre' + } + } mavenTest { kotlin compileClasspath += sourceSets.test.runtimeClasspath @@ -89,5 +96,5 @@ compileTestKotlin { } check { - dependsOn([mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build']) + dependsOn([test, mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build']) } diff --git a/integration/kotlinx-coroutines-guava/test/ListAllCoroutineThrowableSubclassesTest.kt b/integration-testing/src/test/kotlin/ListAllCoroutineThrowableSubclassesTest.kt similarity index 77% rename from integration/kotlinx-coroutines-guava/test/ListAllCoroutineThrowableSubclassesTest.kt rename to integration-testing/src/test/kotlin/ListAllCoroutineThrowableSubclassesTest.kt index 204d5e8302..6ff7103605 100644 --- a/integration/kotlinx-coroutines-guava/test/ListAllCoroutineThrowableSubclassesTest.kt +++ b/integration-testing/src/test/kotlin/ListAllCoroutineThrowableSubclassesTest.kt @@ -2,14 +2,14 @@ * Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ -package kotlinx.coroutines.guava +package kotlinx.coroutines import com.google.common.reflect.* import kotlinx.coroutines.* import org.junit.Test import kotlin.test.* -class ListAllCoroutineThrowableSubclassesTest : TestBase() { +class ListAllCoroutineThrowableSubclassesTest { /* * These are all known throwables in kotlinx.coroutines. @@ -17,8 +17,6 @@ class ListAllCoroutineThrowableSubclassesTest : TestBase() { * you ensure your exception type is java.io.Serializable. * * We do not have means to check it automatically, so checks are delegated to humans. - * Also, this test meant to be in kotlinx-coroutines-core, but properly scanning classpath - * requires guava which is toxic dependency that we'd like to avoid even in tests. * * See #3328 for serialization rationale. */ @@ -33,7 +31,6 @@ class ListAllCoroutineThrowableSubclassesTest : TestBase() { "kotlinx.coroutines.channels.ClosedReceiveChannelException", "kotlinx.coroutines.flow.internal.ChildCancelledException", "kotlinx.coroutines.flow.internal.AbortFlowException", - ) @Test @@ -44,15 +41,11 @@ class ListAllCoroutineThrowableSubclassesTest : TestBase() { classes.forEach { try { if (Throwable::class.java.isAssignableFrom(it.load())) { - // Skip classes from test sources - if (it.load().protectionDomain.codeSource.location.toString().contains("/test/")) { - return@forEach - } ++throwables // println(""""$it",""") assertTrue(knownThrowables.contains(it.toString())) } - } catch (e: Throwable) { + } catch (e: LinkageError) { // Ignore unloadable classes } }