Skip to content

Commit

Permalink
Integration test project (Kotlin#3307)
Browse files Browse the repository at this point in the history
Test for Kotlin#3305 

Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
Co-authored-by: dkhalanskyjb <52952525+dkhalanskyjb@users.noreply.github.com>
  • Loading branch information
3 people authored and pablobaxter committed Sep 14, 2022
1 parent b499918 commit 3a870b8
Show file tree
Hide file tree
Showing 16 changed files with 462 additions and 47 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Projects.kt
Expand Up @@ -12,8 +12,8 @@ val testModule = "kotlinx-coroutines-test"

val multiplatform = setOf(coreModule, testModule)
// Not applicable for Kotlin plugin
val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom", "integration-testing")
val internal = setOf("kotlinx.coroutines", "benchmarks", "integration-testing")
val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom")
val internal = setOf("kotlinx.coroutines", "benchmarks")
// Not published
val unpublished = internal + setOf("example-frontend-js", "android-unit-tests")

Expand Down
1 change: 1 addition & 0 deletions bump-version.sh
Expand Up @@ -21,6 +21,7 @@ update_version "kotlinx-coroutines-debug/README.md"
update_version "kotlinx-coroutines-test/README.md"
update_version "ui/coroutines-guide-ui.md"
update_version "gradle.properties"
update_version "integration-test/gradle.properties"

# Escape dots, e.g. 1.0.0 -> 1\.0\.0
escaped_old_version=$(echo $old_version | sed s/[.]/\\\\./g)
Expand Down
15 changes: 7 additions & 8 deletions integration-testing/README.md
@@ -1,14 +1,13 @@
# Integration tests

This is a supplementary subproject of kotlinx.coroutines that provides
integration tests.
This is a supplementary project that provides integration tests.

The tests are the following:
* `NpmPublicationValidator` tests that version of NPM artifact is correct and that it has neither source nor package dependencies on atomicfu
In order for the test to work, one needs to run gradle with `-PdryRun=true`.
`-PdryRun` affects `npmPublish` so that it only provides a packed publication
and does not in fact attempt to send the build for publication.
* `MavenPublicationValidator` depends on the published artifacts and tests artifacts binary content and absence of atomicfu in the classpath
* `MavenPublicationValidator` depends on the published artifacts and tests artifacts binary content and absence of atomicfu in the classpath.
* `CoreAgentTest` checks that `kotlinx-coroutines-core` can be run as a Java agent.
* `DebugAgentTest` checks that the coroutine debugger can be run as a Java agent.
* `smokeTest` builds the test project that depends on coroutines.

All the available tests can be run with `integration-testing:test`.
The `integration-testing` project is expected to be in a subdirectory of the main `kotlinx.coroutines` project.

To run all the available tests: `cd integration-testing` + `./gradlew check`.
58 changes: 30 additions & 28 deletions integration-testing/build.gradle
Expand Up @@ -5,30 +5,52 @@
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType

plugins {
id("kotlin-jvm-conventions")
id "org.jetbrains.kotlin.jvm"
}

repositories {
mavenLocal()
mavenCentral()
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}

sourceSets {
mavenTest {
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-android:$coroutines_version"
}
}
debugAgentTest {
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"
}
}
coreAgentTest {
kotlin
compileClasspath += sourceSets.test.runtimeClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath

dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
}
}
}

Expand All @@ -39,53 +61,33 @@ compileDebugAgentTestKotlin {
}

task mavenTest(type: Test) {
environment "version", version
environment "version", coroutines_version
def sourceSet = sourceSets.mavenTest
dependsOn(project(':').getTasksByName("publishToMavenLocal", true))
testClassesDirs = sourceSet.output.classesDirs
classpath = sourceSet.runtimeClasspath
// we can't depend on the subprojects because we need to test the classfiles that are published in the end.
// also, we can't put this in the `dependencies` block because the resolution would happen before publication.
def mavenTestClasspathConfiguration = project.configurations.detachedConfiguration(
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"),
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"))

mavenTestClasspathConfiguration.attributes {
attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
}

classpath += mavenTestClasspathConfiguration
}

task debugAgentTest(type: Test) {
def sourceSet = sourceSets.debugAgentTest
dependsOn(project(':kotlinx-coroutines-debug').shadowJar)
jvmArgs ('-javaagent:' + project(':kotlinx-coroutines-debug').shadowJar.outputs.files.getFiles()[0])
def coroutinesDebugJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-debug-${coroutines_version}.jar" }.singleFile
jvmArgs ('-javaagent:' + coroutinesDebugJar)
testClassesDirs = sourceSet.output.classesDirs
classpath = sourceSet.runtimeClasspath
systemProperties project.properties.subMap(["overwrite.probes"])
}

task coreAgentTest(type: Test) {
def sourceSet = sourceSets.coreAgentTest
dependsOn(project(':kotlinx-coroutines-core').jvmJar)
jvmArgs ('-javaagent:' + project(':kotlinx-coroutines-core').jvmJar.outputs.files.getFiles()[0])
def coroutinesCoreJar = sourceSet.runtimeClasspath.filter {it.name == "kotlinx-coroutines-core-jvm-${coroutines_version}.jar" }.singleFile
jvmArgs ('-javaagent:' + coroutinesCoreJar)
testClassesDirs = sourceSet.output.classesDirs
classpath = sourceSet.runtimeClasspath
}

dependencies {
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
testImplementation 'junit:junit:4.12'
debugAgentTestImplementation project(':kotlinx-coroutines-core')
debugAgentTestImplementation project(':kotlinx-coroutines-debug')
coreAgentTestImplementation project(':kotlinx-coroutines-core')
}

compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

check {
dependsOn([mavenTest, debugAgentTest, coreAgentTest])
dependsOn([mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build'])
}
4 changes: 4 additions & 0 deletions integration-testing/gradle.properties
@@ -0,0 +1,4 @@
kotlin_version=1.6.21
coroutines_version=1.6.2-SNAPSHOT

kotlin.code.style=official
Binary file not shown.
5 changes: 5 additions & 0 deletions integration-testing/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 3a870b8

Please sign in to comment.