Skip to content

Commit

Permalink
Move ListAllCoroutineThrowableSubclassesTest to integration-testing a…
Browse files Browse the repository at this point in the history
…nd fix assertion
  • Loading branch information
qwwdfsad committed Jun 22, 2022
1 parent e32aa78 commit 188ab3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
9 changes: 8 additions & 1 deletion integration-testing/build.gradle
Expand Up @@ -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
Expand Down Expand Up @@ -89,5 +96,5 @@ compileTestKotlin {
}

check {
dependsOn([mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build'])
dependsOn([test, mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build'])
}
Expand Up @@ -2,23 +2,21 @@
* 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.
* If you have added one, this test will fail to make
* 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.
*/
Expand All @@ -33,7 +31,6 @@ class ListAllCoroutineThrowableSubclassesTest : TestBase() {
"kotlinx.coroutines.channels.ClosedReceiveChannelException",
"kotlinx.coroutines.flow.internal.ChildCancelledException",
"kotlinx.coroutines.flow.internal.AbortFlowException",

)

@Test
Expand All @@ -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
}
}
Expand Down

0 comments on commit 188ab3d

Please sign in to comment.