Skip to content

Commit 3f9009d

Browse files
committed
Improve build configuration of integration tests
* publication-validator is renamed to integration-testing; * Each test is now in a separate source set, which allows for more flexibility in their configuration; for example, failing to set `dryRun=true` doesn't prevent tests other than NPM to run, and it is possible to run the tests (and their dependencies) separately.
1 parent 658c5c3 commit 3f9009d

File tree

8 files changed

+81
-61
lines changed

8 files changed

+81
-61
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ apply from: rootProject.file("gradle/experimental.gradle")
88
def rootModule = "kotlinx.coroutines"
99
def coreModule = "kotlinx-coroutines-core"
1010
// Not applicable for Kotlin plugin
11-
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'publication-validator']
12-
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'publication-validator']
11+
def sourceless = ['kotlinx.coroutines', 'site', 'kotlinx-coroutines-bom', 'integration-testing']
12+
def internal = ['kotlinx.coroutines', 'site', 'benchmarks', 'js-stub', 'stdlib-stubs', 'integration-testing']
1313
// Not published
1414
def unpublished = internal + ['example-frontend-js', 'android-unit-tests']
1515

integration-testing/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Integration tests
2+
3+
This is a supplementary subproject of kotlinx.coroutines that provides
4+
integration tests.
5+
6+
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
12+
13+
All the available tests can be run with `integration-testing:test`.

integration-testing/build.gradle

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
apply from: rootProject.file("gradle/compile-jvm.gradle")
6+
7+
repositories {
8+
mavenLocal()
9+
mavenCentral()
10+
}
11+
12+
sourceSets {
13+
npmTest {
14+
kotlin
15+
compileClasspath += sourceSets.test.runtimeClasspath
16+
runtimeClasspath += sourceSets.test.runtimeClasspath
17+
}
18+
mavenTest {
19+
kotlin
20+
compileClasspath += sourceSets.test.runtimeClasspath
21+
runtimeClasspath += sourceSets.test.runtimeClasspath
22+
}
23+
}
24+
25+
task npmTest(type: Test) {
26+
def sourceSet = sourceSets.npmTest
27+
environment "projectRoot", project.rootDir
28+
environment "deployVersion", version
29+
def dryRunNpm = project.properties['dryRun']
30+
def doRun = dryRunNpm == "true" // so that we don't accidentally publish anything, especially before the test
31+
onlyIf { doRun }
32+
if (doRun) { // `onlyIf` only affects execution of the task, not the dependency subtree
33+
dependsOn(project(':').getTasksByName("publishNpm", true))
34+
}
35+
testClassesDirs = sourceSet.output.classesDirs
36+
classpath = sourceSet.runtimeClasspath
37+
}
38+
39+
task mavenTest(type: Test) {
40+
def sourceSet = sourceSets.mavenTest
41+
dependsOn(project(':').getTasksByName("publishToMavenLocal", true))
42+
dependsOn.remove(project(':').getTasksByName("dokka", true))
43+
testClassesDirs = sourceSet.output.classesDirs
44+
classpath = sourceSet.runtimeClasspath
45+
// we can't depend on the subprojects because we need to test the classfiles that are published in the end.
46+
// also, we can't put this in the `dependencies` block because the resolution would happen before publication.
47+
classpath += project.configurations.detachedConfiguration(
48+
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"),
49+
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-android:$version"))
50+
}
51+
52+
dependencies {
53+
testCompile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
54+
testCompile 'junit:junit:4.12'
55+
npmTestCompile 'org.apache.commons:commons-compress:1.18'
56+
npmTestCompile 'com.google.code.gson:gson:2.8.5'
57+
}
58+
59+
compileTestKotlin {
60+
kotlinOptions.jvmTarget = "1.8"
61+
}
62+
63+
test {
64+
dependsOn([npmTest, mavenTest])
65+
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package kotlinx.coroutines.validator
66

77
import org.junit.*
88
import org.junit.Assert.assertTrue
9-
import java.io.*
109
import java.util.jar.*
1110

1211
class MavenPublicationValidator {

publication-validator/README.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

publication-validator/build.gradle

Lines changed: 0 additions & 44 deletions
This file was deleted.

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ if (!build_snapshot_train) {
4545
include('site')
4646
}
4747

48-
module('publication-validator')
48+
module('integration-testing')

0 commit comments

Comments
 (0)