Skip to content

Commit f101f93

Browse files
mvicsokolovaqwwdfsaddkhalanskyjb
authored
Integration test project (#3307)
Test for #3305 Co-authored-by: Vsevolod Tolstopyatov <[email protected]> Co-authored-by: dkhalanskyjb <[email protected]>
1 parent c4cd1fd commit f101f93

File tree

16 files changed

+462
-47
lines changed

16 files changed

+462
-47
lines changed

buildSrc/src/main/kotlin/Projects.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ val testModule = "kotlinx-coroutines-test"
1212

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

bump-version.sh

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ update_version "kotlinx-coroutines-debug/README.md"
2121
update_version "kotlinx-coroutines-test/README.md"
2222
update_version "ui/coroutines-guide-ui.md"
2323
update_version "gradle.properties"
24+
update_version "integration-test/gradle.properties"
2425

2526
# Escape dots, e.g. 1.0.0 -> 1\.0\.0
2627
escaped_old_version=$(echo $old_version | sed s/[.]/\\\\./g)

integration-testing/README.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Integration tests
22

3-
This is a supplementary subproject of kotlinx.coroutines that provides
4-
integration tests.
3+
This is a supplementary project that provides integration tests.
54

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

14-
All the available tests can be run with `integration-testing:test`.
11+
The `integration-testing` project is expected to be in a subdirectory of the main `kotlinx.coroutines` project.
12+
13+
To run all the available tests: `cd integration-testing` + `./gradlew check`.

integration-testing/build.gradle

+30-28
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,52 @@
55
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
66

77
plugins {
8-
id("kotlin-jvm-conventions")
8+
id "org.jetbrains.kotlin.jvm"
99
}
1010

1111
repositories {
1212
mavenLocal()
1313
mavenCentral()
1414
}
1515

16+
java {
17+
sourceCompatibility = JavaVersion.VERSION_1_8
18+
targetCompatibility = JavaVersion.VERSION_1_8
19+
}
20+
21+
dependencies {
22+
testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
23+
}
24+
1625
sourceSets {
1726
mavenTest {
1827
kotlin
1928
compileClasspath += sourceSets.test.runtimeClasspath
2029
runtimeClasspath += sourceSets.test.runtimeClasspath
30+
31+
dependencies {
32+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
33+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
34+
}
2135
}
2236
debugAgentTest {
2337
kotlin
2438
compileClasspath += sourceSets.test.runtimeClasspath
2539
runtimeClasspath += sourceSets.test.runtimeClasspath
26-
}
2740

41+
dependencies {
42+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
43+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-debug:$coroutines_version"
44+
}
45+
}
2846
coreAgentTest {
2947
kotlin
3048
compileClasspath += sourceSets.test.runtimeClasspath
3149
runtimeClasspath += sourceSets.test.runtimeClasspath
50+
51+
dependencies {
52+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
53+
}
3254
}
3355
}
3456

@@ -39,53 +61,33 @@ compileDebugAgentTestKotlin {
3961
}
4062

4163
task mavenTest(type: Test) {
42-
environment "version", version
64+
environment "version", coroutines_version
4365
def sourceSet = sourceSets.mavenTest
44-
dependsOn(project(':').getTasksByName("publishToMavenLocal", true))
4566
testClassesDirs = sourceSet.output.classesDirs
4667
classpath = sourceSet.runtimeClasspath
47-
// we can't depend on the subprojects because we need to test the classfiles that are published in the end.
48-
// also, we can't put this in the `dependencies` block because the resolution would happen before publication.
49-
def mavenTestClasspathConfiguration = project.configurations.detachedConfiguration(
50-
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"),
51-
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"))
52-
53-
mavenTestClasspathConfiguration.attributes {
54-
attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
55-
}
56-
57-
classpath += mavenTestClasspathConfiguration
5868
}
5969

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

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

77-
dependencies {
78-
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
79-
testImplementation 'junit:junit:4.12'
80-
debugAgentTestImplementation project(':kotlinx-coroutines-core')
81-
debugAgentTestImplementation project(':kotlinx-coroutines-debug')
82-
coreAgentTestImplementation project(':kotlinx-coroutines-core')
83-
}
84-
8587
compileTestKotlin {
8688
kotlinOptions.jvmTarget = "1.8"
8789
}
8890

8991
check {
90-
dependsOn([mavenTest, debugAgentTest, coreAgentTest])
92+
dependsOn([mavenTest, debugAgentTest, coreAgentTest, 'smokeTest:build'])
9193
}

integration-testing/gradle.properties

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
kotlin_version=1.6.21
2+
coroutines_version=1.6.2-SNAPSHOT
3+
4+
kotlin.code.style=official
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)