Browse Source

Split integration and unit Gradle plugin tests

Previously some tests (e.g. FileHashTest) were executed
multiple times in each test task.
This change splits tests in the following way:
* `testGradle-<VERSION>` task only runs `org.jetbrains.compose.gradle.*` tests
with the corresponding Gradle version;
* `test` runs all other tests once;
* `check` runs all tests and checks;
pull/534/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
4e673239a7
  1. 30
      gradle-plugins/compose/build.gradle.kts
  2. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/DesktopApplicationTest.kt
  3. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt

30
gradle-plugins/compose/build.gradle.kts

@ -59,8 +59,9 @@ val jar = tasks.named<Jar>("jar") {
}
// __SUPPORTED_GRADLE_VERSIONS__
val minGradleVersionForTests = "6.4"
val maxGradleVersionForTests = "6.8.3"
testGradleVersion("6.4")
testGradleVersion("6.8.3")
val javaHomeForTests: String? = when {
// __COMPOSE_NATIVE_DISTRIBUTIONS_MIN_JAVA_VERSION__
JavaVersion.current() >= JavaVersion.VERSION_15 -> System.getProperty("java.home")
@ -69,18 +70,29 @@ val javaHomeForTests: String? = when {
}
val isWindows = getCurrentOperatingSystem().isWindows
val gradleTestsPattern = "org.jetbrains.compose.gradle.*"
tasks.test {
configureTest(maxGradleVersionForTests)
filter {
excludeTestsMatching(gradleTestsPattern)
}
val testMinGradleVersion by tasks.registering(Test::class) {
}
fun testGradleVersion(gradleVersion: String) {
val taskProvider = tasks.register("testGradle-$gradleVersion", Test::class) {
tasks.test.get().let { defaultTest ->
classpath = defaultTest.classpath
}
configureTest(minGradleVersionForTests)
systemProperty("gradle.version.for.tests", gradleVersion)
filter {
includeTestsMatching(gradleTestsPattern)
}
dependsOn("validateTaskProperties")
}
tasks.named("check") {
dependsOn(taskProvider)
}
}
fun Test.configureTest(gradleVersion: String) {
tasks.withType<Test>().configureEach {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
@ -88,7 +100,6 @@ fun Test.configureTest(gradleVersion: String) {
dependsOn("publishToMavenLocal")
systemProperty("compose.plugin.version", BuildProperties.deployVersion(project))
systemProperty("gradle.version.for.tests", gradleVersion)
if (javaHomeForTests != null) {
val executableFileName = if (isWindows) "java.exe" else "java"
@ -96,10 +107,7 @@ fun Test.configureTest(gradleVersion: String) {
} else {
doFirst { error("Use JDK 15+ to run tests or set up JDK_15/JDK_FOR_GRADLE_TESTS env. var") }
}
}
tasks.named("check") {
dependsOn(testMinGradleVersion)
}
task("printAllAndroidxReplacements") {

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/DesktopApplicationTest.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/DesktopApplicationTest.kt

@ -1,4 +1,4 @@
package org.jetbrains.compose
package org.jetbrains.compose.gradle
import org.gradle.internal.impldep.org.testng.Assert
import org.gradle.testkit.runner.TaskOutcome

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/GradlePluginTest.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt

@ -1,4 +1,4 @@
package org.jetbrains.compose
package org.jetbrains.compose.gradle
import org.gradle.testkit.runner.TaskOutcome
import org.jetbrains.compose.test.GradlePluginTestBase
Loading…
Cancel
Save