[Gradle] Add integration test for associated 'functionalTest' style sources
Experiments with the DefaultKotlinCompilationAssociator where made during KT-60937. One experiment broke running functionalTests in kotlin.git in bootstrap mode. This case was not yet covered by CI. ^KT-60937 Verification Pending
This commit is contained in:
committed by
Space Team
parent
6c6200a9c5
commit
d2bd749861
+29
@@ -94,6 +94,35 @@ class TestFixturesIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("Test associated 'functionalTest' compilation can compile and run with test and testFixtures in JVM project")
|
||||||
|
@MppGradlePluginTests
|
||||||
|
@GradleTest
|
||||||
|
fun testTestFixturesAndFunctionalTestsInJvmProject(gradleVersion: GradleVersion) {
|
||||||
|
project("jvm-test-fixtures-functionalTest", gradleVersion) {
|
||||||
|
build("functionalTest") {
|
||||||
|
assertOutputContains("src/main OK!")
|
||||||
|
assertOutputContains("src/test OK!")
|
||||||
|
assertOutputContains("src/testFixtures OK!")
|
||||||
|
assertOutputContains("src/functionalTest OK!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@DisplayName("Test associated 'functionalTest' compilation can compile and run with test and testFixtures in Multiplatform project")
|
||||||
|
@MppGradlePluginTests
|
||||||
|
@GradleTest
|
||||||
|
fun testTestFixturesAndFunctionalTestsInMppProject(gradleVersion: GradleVersion) {
|
||||||
|
project("mpp-test-fixtures-functionalTest", gradleVersion) {
|
||||||
|
build("functionalTest") {
|
||||||
|
assertOutputContains("src/main OK!")
|
||||||
|
assertOutputContains("src/test OK!")
|
||||||
|
assertOutputContains("src/testFixtures OK!")
|
||||||
|
assertOutputContains("src/functionalTest OK!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val JVM_TEST_FIXTURES_PROJECT_NAME = "jvm-test-fixtures"
|
private const val JVM_TEST_FIXTURES_PROJECT_NAME = "jvm-test-fixtures"
|
||||||
private const val MPP_TEST_FIXTURES_PROJECT_NAME = "mpp-test-fixtures"
|
private const val MPP_TEST_FIXTURES_PROJECT_NAME = "mpp-test-fixtures"
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
@file:Suppress("HasPlatformType")
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
`java-test-fixtures`
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create functionalTest (java) source set */
|
||||||
|
val functionalTestSourceSet = sourceSets.create("functionalTest")
|
||||||
|
val functionalTestCompilation = kotlin.target.compilations.getByName("functionalTest")
|
||||||
|
|
||||||
|
/* Associate 'functionalTest' with 'test' */
|
||||||
|
functionalTestCompilation.associateWith(kotlin.target.compilations.getByName("test"))
|
||||||
|
|
||||||
|
/* Create test task */
|
||||||
|
val functionalTest = tasks.register<Test>("functionalTest") {
|
||||||
|
testClassesDirs = functionalTestSourceSet.output.classesDirs
|
||||||
|
classpath = functionalTestSourceSet.runtimeClasspath
|
||||||
|
testLogging {
|
||||||
|
events("passed", "skipped", "failed")
|
||||||
|
showStandardStreams = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation(kotlin("test-junit"))
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
public class FunctionalTestJava {
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
class Executable {
|
||||||
|
@Test
|
||||||
|
fun runTest() {
|
||||||
|
MainJava()
|
||||||
|
MainKotlin()
|
||||||
|
MainKotlinInternal()
|
||||||
|
println("src/main OK!")
|
||||||
|
|
||||||
|
TestJava()
|
||||||
|
TestKotlin()
|
||||||
|
TestKotlinInternal()
|
||||||
|
println("src/test OK!")
|
||||||
|
|
||||||
|
TestFixturesJava()
|
||||||
|
TestFixturesKotlin()
|
||||||
|
TestFixturesKotlinInternal()
|
||||||
|
println("src/testFixtures OK!")
|
||||||
|
|
||||||
|
FunctionalTestKotlin()
|
||||||
|
FunctionalTestJava()
|
||||||
|
println("src/functionalTest OK!")
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
internal class FunctionalTestKotlin {
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
public class MainJava {
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
class MainKotlin
|
||||||
|
internal class MainKotlinInternal
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
public class TestJava {
|
||||||
|
public TestJava() {
|
||||||
|
new MainJava();
|
||||||
|
new MainKotlin();
|
||||||
|
|
||||||
|
new TestFixturesJava();
|
||||||
|
new TestFixturesKotlin();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
class TestKotlin
|
||||||
|
internal class TestKotlinInternal
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
public class TestFixturesJava {
|
||||||
|
public TestFixturesJava() {
|
||||||
|
new MainJava();
|
||||||
|
new MainKotlin();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
class TestFixturesKotlin
|
||||||
|
internal class TestFixturesKotlinInternal
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
java
|
||||||
|
`java-test-fixtures`
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvm { withJava() }
|
||||||
|
val testCompilation = jvm().compilations.getByName("test")
|
||||||
|
testCompilation.associateWith(jvm().compilations.getByName("testFixtures"))
|
||||||
|
|
||||||
|
val functionalTestCompilation = jvm().compilations.create("functionalTest")
|
||||||
|
functionalTestCompilation.associateWith(testCompilation)
|
||||||
|
|
||||||
|
sourceSets.getByName("jvmTest").dependencies {
|
||||||
|
implementation(kotlin("test-junit"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create test task */
|
||||||
|
val functionalTest = tasks.register<Test>("functionalTest") {
|
||||||
|
val compilation = kotlin.jvm().compilations.getByName("functionalTest")
|
||||||
|
testClassesDirs = compilation.output.classesDirs
|
||||||
|
classpath = compilation.output.classesDirs +
|
||||||
|
project.files({ kotlin.jvm().compilations.getByName("functionalTest").runtimeDependencyFiles })
|
||||||
|
|
||||||
|
testLogging {
|
||||||
|
events("passed", "skipped", "failed")
|
||||||
|
showStandardStreams = true
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
public class FunctionalTestJava {
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
class Executable {
|
||||||
|
@Test
|
||||||
|
fun runTest() {
|
||||||
|
MainJava()
|
||||||
|
MainKotlin()
|
||||||
|
MainKotlinInternal()
|
||||||
|
println("src/main OK!")
|
||||||
|
|
||||||
|
TestJava()
|
||||||
|
TestKotlin()
|
||||||
|
TestKotlinInternal()
|
||||||
|
println("src/test OK!")
|
||||||
|
|
||||||
|
TestFixturesJava()
|
||||||
|
TestFixturesKotlin()
|
||||||
|
TestFixturesKotlinInternal()
|
||||||
|
println("src/testFixtures OK!")
|
||||||
|
|
||||||
|
FunctionalTestKotlin()
|
||||||
|
FunctionalTestJava()
|
||||||
|
println("src/functionalTest OK!")
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
internal class FunctionalTestKotlin {
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
public class MainJava {
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
class MainKotlin
|
||||||
|
internal class MainKotlinInternal
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
public class TestJava {
|
||||||
|
public TestJava() {
|
||||||
|
new MainJava();
|
||||||
|
new MainKotlin();
|
||||||
|
|
||||||
|
new TestFixturesJava();
|
||||||
|
new TestFixturesKotlin();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
class TestKotlin
|
||||||
|
internal class TestKotlinInternal
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
public class TestFixturesJava {
|
||||||
|
public TestFixturesJava() {
|
||||||
|
new MainJava();
|
||||||
|
new MainKotlin();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
class TestFixturesKotlin
|
||||||
|
internal class TestFixturesKotlinInternal
|
||||||
Reference in New Issue
Block a user