diff options
author | Vsevolod Tolstopyatov <qwwdfsad@gmail.com> | 2022-07-11 10:48:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 11:48:44 +0300 |
commit | 562902b0dc2ce1af58e37ff203ed0f06675562dc (patch) | |
tree | 1be94ee411fed4df820b23e8cd6922265b0b0103 /integration-testing | |
parent | 8b6473df0336128ca4bac79811d858db330bd251 (diff) | |
download | kotlinx.coroutines-562902b0dc2ce1af58e37ff203ed0f06675562dc.tar.gz |
Fix debug module publication with shadow plugin (#3357)
Fixes #3345
Fixes #3334
Diffstat (limited to 'integration-testing')
-rw-r--r-- | integration-testing/build.gradle | 25 | ||||
-rw-r--r-- | integration-testing/src/debugDynamicAgentTest/kotlin/DynamicAttachDebugTest.kt | 29 |
2 files changed, 53 insertions, 1 deletions
diff --git a/integration-testing/build.gradle b/integration-testing/build.gradle index c23d35fb..985a40ed 100644 --- a/integration-testing/build.gradle +++ b/integration-testing/build.gradle @@ -23,6 +23,7 @@ dependencies { } sourceSets { + // Test that relies on Guava to reflectively check all Throwable subclasses in coroutines withGuavaTest { kotlin compileClasspath += sourceSets.test.runtimeClasspath @@ -33,6 +34,7 @@ sourceSets { implementation 'com.google.guava:guava:31.1-jre' } } + // Checks correctness of Maven publication (JAR resources) and absence of atomicfu symbols mavenTest { kotlin compileClasspath += sourceSets.test.runtimeClasspath @@ -43,6 +45,7 @@ sourceSets { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" } } + // Checks that kotlinx-coroutines-debug can be used as -javaagent parameter debugAgentTest { kotlin compileClasspath += sourceSets.test.runtimeClasspath @@ -53,6 +56,20 @@ sourceSets { implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version" } } + + // Checks that kotlinx-coroutines-debug agent can self-attach dynamically to JVM as standalone dependency + debugDynamicAgentTest { + kotlin + compileClasspath += sourceSets.test.runtimeClasspath + runtimeClasspath += sourceSets.test.runtimeClasspath + + dependencies { + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version" + } + } + + // Checks that kotlinx-coroutines-core can be used as -javaagent parameter coreAgentTest { kotlin compileClasspath += sourceSets.test.runtimeClasspath @@ -93,6 +110,12 @@ task debugAgentTest(type: Test) { systemProperties project.properties.subMap(["overwrite.probes"]) } +task debugDynamicAgentTest(type: Test) { + def sourceSet = sourceSets.debugDynamicAgentTest + testClassesDirs = sourceSet.output.classesDirs + classpath = sourceSet.runtimeClasspath +} + task coreAgentTest(type: Test) { def sourceSet = sourceSets.coreAgentTest def coroutinesCoreJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-core-jvm-${coroutines_version}.jar" }.singleFile @@ -106,5 +129,5 @@ compileTestKotlin { } check { - dependsOn([withGuavaTest, mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build']) + dependsOn([withGuavaTest, debugDynamicAgentTest, mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build']) } diff --git a/integration-testing/src/debugDynamicAgentTest/kotlin/DynamicAttachDebugTest.kt b/integration-testing/src/debugDynamicAgentTest/kotlin/DynamicAttachDebugTest.kt new file mode 100644 index 00000000..ff9cac84 --- /dev/null +++ b/integration-testing/src/debugDynamicAgentTest/kotlin/DynamicAttachDebugTest.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ +import org.junit.* +import kotlinx.coroutines.* +import kotlinx.coroutines.debug.* +import org.junit.Test +import java.io.* +import java.lang.IllegalStateException + +class DynamicAttachDebugTest { + + @Test + fun testAgentDumpsCoroutines() = + DebugProbes.withDebugProbes { + runBlocking { + val baos = ByteArrayOutputStream() + DebugProbes.dumpCoroutines(PrintStream(baos)) + // if the agent works, then dumps should contain something, + // at least the fact that this test is running. + Assert.assertTrue(baos.toString().contains("testAgentDumpsCoroutines")) + } + } + + @Test(expected = IllegalStateException::class) + fun testAgentIsNotInstalled() { + DebugProbes.dumpCoroutines(PrintStream(ByteArrayOutputStream())) + } +} |