Implement new 'mix' test mode
This mode must be used when one configuration will run several tests for different JUnit versions.
This commit is contained in:
@@ -35,7 +35,7 @@ tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
}
|
||||
}
|
||||
|
||||
projectTest(jUnit5Enabled = true) {
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform()
|
||||
|
||||
@@ -59,7 +59,7 @@ sourceSets {
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
projectTest(jUnit5Enabled = true) {
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform()
|
||||
|
||||
@@ -60,7 +60,7 @@ sourceSets {
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
projectTest(jUnit5Enabled = true) {
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform()
|
||||
|
||||
@@ -88,6 +88,10 @@ fun Task.dependsOnKotlinGradlePluginPublish() {
|
||||
}
|
||||
}
|
||||
|
||||
enum class JUnitMode {
|
||||
JUnit4, JUnit5, Mix
|
||||
}
|
||||
|
||||
/**
|
||||
* @param parallel is redundant if @param jUnit5Enabled is true, because
|
||||
* JUnit5 supports parallel test execution by itself, without gradle help
|
||||
@@ -96,7 +100,7 @@ fun Project.projectTest(
|
||||
taskName: String = "test",
|
||||
parallel: Boolean = false,
|
||||
shortenTempRootName: Boolean = false,
|
||||
jUnit5Enabled: Boolean = false,
|
||||
jUnitMode: JUnitMode = JUnitMode.JUnit4,
|
||||
body: Test.() -> Unit = {}
|
||||
): TaskProvider<Test> {
|
||||
val shouldInstrument = project.providers.gradleProperty("kotlin.test.instrumentation.disable")
|
||||
@@ -136,7 +140,7 @@ fun Project.projectTest(
|
||||
}
|
||||
}
|
||||
|
||||
val parentNames = if (jUnit5Enabled) {
|
||||
val parentNames = if (jUnitMode != JUnitMode.JUnit4) {
|
||||
/*
|
||||
* If we run test from inner test class with junit 5 we need
|
||||
* to include all containing classes of our class
|
||||
@@ -154,10 +158,12 @@ fun Project.projectTest(
|
||||
if (treeElement.isDirectory) {
|
||||
classFileNameWithoutExtension.startsWith(path)
|
||||
} else {
|
||||
if (jUnit5Enabled) {
|
||||
path == classFileName || (path.endsWith(".class") && parentNames.any { path.startsWith(it) })
|
||||
} else {
|
||||
path == classFileName || (path.endsWith(".class") && path.startsWith("$classFileNameWithoutExtension$"))
|
||||
if (path == classFileName) return@include true
|
||||
if (!path.endsWith(".class")) return@include false
|
||||
when(jUnitMode) {
|
||||
JUnitMode.JUnit5 -> parentNames.any { path.startsWith(it) }
|
||||
JUnitMode.JUnit4 -> path.startsWith("$classFileNameWithoutExtension$")
|
||||
JUnitMode.Mix -> parentNames.any { path.startsWith(it) } || path.startsWith("$classFileNameWithoutExtension$")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +231,7 @@ fun Project.projectTest(
|
||||
}
|
||||
}
|
||||
|
||||
if (parallel && !jUnit5Enabled) {
|
||||
if (parallel && jUnitMode != JUnitMode.JUnit5) {
|
||||
maxParallelForks =
|
||||
project.providers.gradleProperty("kotlin.test.maxParallelForks").forUseAtConfigurationTime().orNull?.toInt()
|
||||
?: (Runtime.getRuntime().availableProcessors() / if (project.kotlinBuildProperties.isTeamcityBuild) 2 else 4).coerceAtLeast(1)
|
||||
|
||||
@@ -56,7 +56,7 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
}
|
||||
}
|
||||
|
||||
projectTest(jUnit5Enabled = true) {
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
jvmArgs!!.removeIf { it.contains("-Xmx") }
|
||||
|
||||
@@ -73,7 +73,7 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
}
|
||||
}
|
||||
|
||||
projectTest(jUnit5Enabled = true) {
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform()
|
||||
|
||||
@@ -62,7 +62,7 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
}
|
||||
}
|
||||
|
||||
projectTest(jUnit5Enabled = true) {
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
jvmArgs!!.removeIf { it.contains("-Xmx") }
|
||||
|
||||
@@ -33,7 +33,7 @@ fun Project.codegenTest(
|
||||
body: Test.() -> Unit = {}
|
||||
): TaskProvider<Test> = projectTest(
|
||||
taskName = "codegenTarget${targetInTestClass}Jvm${jvm}Test",
|
||||
jUnit5Enabled = true
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
|
||||
@@ -40,7 +40,7 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
}
|
||||
}
|
||||
|
||||
projectTest(parallel = true, jUnit5Enabled = true) {
|
||||
projectTest(parallel = true, jUnitMode = JUnitMode.JUnit5) {
|
||||
workingDir = rootDir
|
||||
|
||||
useJUnitPlatform()
|
||||
|
||||
@@ -243,7 +243,7 @@ fun Test.setUpBoxTests() {
|
||||
|
||||
val testDataDir = project(":js:js.translator").projectDir.resolve("testData")
|
||||
|
||||
projectTest(parallel = true) {
|
||||
projectTest(parallel = true, jUnitMode = JUnitMode.Mix) {
|
||||
setUpJsBoxTests(jsEnabled = true, jsIrEnabled = true)
|
||||
systemProperty("kotlin.js.ir.pir", "false")
|
||||
maxHeapSize = "3g"
|
||||
@@ -263,7 +263,7 @@ projectTest(parallel = true) {
|
||||
configureTestDistribution()
|
||||
}
|
||||
|
||||
projectTest("jsTest", parallel = true, jUnit5Enabled = true) {
|
||||
projectTest("jsTest", parallel = true, jUnitMode = JUnitMode.Mix) {
|
||||
// PIR temporary disabled
|
||||
systemProperty("kotlin.js.ir.pir", "false")
|
||||
setUpJsBoxTests(jsEnabled = true, jsIrEnabled = false)
|
||||
@@ -303,7 +303,7 @@ projectTest("jsPirTest", true) {
|
||||
setUpJsBoxTests(jsEnabled = false, jsIrEnabled = true)
|
||||
}
|
||||
|
||||
projectTest("quickTest", parallel = true, jUnit5Enabled = true) {
|
||||
projectTest("quickTest", parallel = true, jUnitMode = JUnitMode.Mix) {
|
||||
setUpJsBoxTests(jsEnabled = true, jsIrEnabled = false)
|
||||
maxHeapSize = "3g"
|
||||
systemProperty("kotlin.js.skipMinificationTest", "true")
|
||||
|
||||
@@ -101,7 +101,7 @@ fun Test.advanceGradleVersion() {
|
||||
projectTest(
|
||||
"test",
|
||||
shortenTempRootName = shortenTempRootName,
|
||||
jUnit5Enabled = true
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
includeMppAndAndroid(false)
|
||||
includeNative(false)
|
||||
@@ -111,7 +111,7 @@ projectTest(
|
||||
projectTest(
|
||||
"testAdvanceGradleVersion",
|
||||
shortenTempRootName = shortenTempRootName,
|
||||
jUnit5Enabled = true
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
advanceGradleVersion()
|
||||
includeMppAndAndroid(false)
|
||||
@@ -124,7 +124,7 @@ if (isTeamcityBuild) {
|
||||
projectTest(
|
||||
"testNative",
|
||||
shortenTempRootName = shortenTempRootName,
|
||||
jUnit5Enabled = true
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
includeNative(true)
|
||||
finalizedBy(cleanTestKitCacheTask)
|
||||
@@ -133,7 +133,7 @@ if (isTeamcityBuild) {
|
||||
projectTest(
|
||||
"testAdvanceGradleVersionNative",
|
||||
shortenTempRootName = shortenTempRootName,
|
||||
jUnit5Enabled = true
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
advanceGradleVersion()
|
||||
includeNative(true)
|
||||
@@ -143,7 +143,7 @@ if (isTeamcityBuild) {
|
||||
projectTest(
|
||||
"testMppAndAndroid",
|
||||
shortenTempRootName = shortenTempRootName,
|
||||
jUnit5Enabled = true
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
includeMppAndAndroid(true)
|
||||
finalizedBy(cleanTestKitCacheTask)
|
||||
@@ -152,7 +152,7 @@ if (isTeamcityBuild) {
|
||||
projectTest(
|
||||
"testAdvanceGradleVersionMppAndAndroid",
|
||||
shortenTempRootName = shortenTempRootName,
|
||||
jUnit5Enabled = true
|
||||
jUnitMode = JUnitMode.JUnit5
|
||||
) {
|
||||
advanceGradleVersion()
|
||||
includeMppAndAndroid(true)
|
||||
|
||||
@@ -60,7 +60,7 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
}
|
||||
}
|
||||
|
||||
projectTest(parallel = true, jUnit5Enabled = true) {
|
||||
projectTest(parallel = true, jUnitMode = JUnitMode.JUnit5) {
|
||||
workingDir = rootDir
|
||||
jvmArgs!!.removeIf { it.contains("-Xmx") }
|
||||
maxHeapSize = "3g"
|
||||
|
||||
@@ -51,7 +51,7 @@ sourcesJar()
|
||||
javadocJar()
|
||||
testsJar()
|
||||
|
||||
projectTest(parallel = true, jUnit5Enabled = true) {
|
||||
projectTest(parallel = true, jUnitMode = JUnitMode.JUnit5) {
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ sourcesJar()
|
||||
|
||||
testsJar()
|
||||
|
||||
projectTest(jUnit5Enabled = true) {
|
||||
projectTest(jUnitMode = JUnitMode.JUnit5) {
|
||||
useJUnitPlatform()
|
||||
dependsOn(parcelizeRuntimeForTests)
|
||||
dependsOn(":dist")
|
||||
|
||||
Reference in New Issue
Block a user