[Tests] Use custom test tasks instead of gradle test suites for kgp functionalTests
^KT-57380 Verification Pending
This commit is contained in:
committed by
Space Team
parent
40270a9c72
commit
4039ccbb05
@@ -1,12 +1,10 @@
|
|||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
import com.github.jengelman.gradle.plugins.shadow.transformers.DontIncludeResourceTransformer
|
import com.github.jengelman.gradle.plugins.shadow.transformers.DontIncludeResourceTransformer
|
||||||
import org.jetbrains.dokka.gradle.DokkaTask
|
|
||||||
import org.jetbrains.kotlin.pill.PillExtension
|
import org.jetbrains.kotlin.pill.PillExtension
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("gradle-plugin-common-configuration")
|
id("gradle-plugin-common-configuration")
|
||||||
id("jps-compatible")
|
id("jps-compatible")
|
||||||
`jvm-test-suite`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -214,108 +212,76 @@ gradlePlugin {
|
|||||||
// Gradle plugins functional tests
|
// Gradle plugins functional tests
|
||||||
if (!kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
if (!kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||||
|
|
||||||
testing {
|
val functionalTestSourceSet = sourceSets.create("functionalTest") {
|
||||||
suites {
|
compileClasspath += mainSourceSet.output
|
||||||
val functionalTest by registering(JvmTestSuite::class)
|
runtimeClasspath += mainSourceSet.output
|
||||||
|
|
||||||
val functionalRegressionTest by registering(JvmTestSuite::class) {
|
configurations.getByName(implementationConfigurationName) {
|
||||||
sources {
|
extendsFrom(configurations.getByName(mainSourceSet.implementationConfigurationName))
|
||||||
java {
|
extendsFrom(configurations.getByName(testSourceSet.implementationConfigurationName))
|
||||||
setSrcDirs(listOf("src/functionalTest/kotlin"))
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
targets.all {
|
configurations.getByName(runtimeOnlyConfigurationName) {
|
||||||
testTask.configure {
|
extendsFrom(configurations.getByName(mainSourceSet.runtimeOnlyConfigurationName))
|
||||||
include("**/org/jetbrains/kotlin/gradle/regressionTests/**")
|
extendsFrom(configurations.getByName(testSourceSet.runtimeOnlyConfigurationName))
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val functionalDependencyResolutionTest by registering(JvmTestSuite::class) {
|
|
||||||
sources {
|
|
||||||
java {
|
|
||||||
setSrcDirs(listOf("src/functionalTest/kotlin"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
targets.all {
|
|
||||||
testTask.configure {
|
|
||||||
include("**/org/jetbrains/kotlin/gradle/dependencyResolutionTests/**")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val functionalUnitTest by registering(JvmTestSuite::class) {
|
|
||||||
sources {
|
|
||||||
java {
|
|
||||||
setSrcDirs(listOf("src/functionalTest/kotlin"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
targets.all {
|
|
||||||
testTask.configure {
|
|
||||||
include("**/org/jetbrains/kotlin/gradle/unitTests/**")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
withType<JvmTestSuite>().configureEach {
|
|
||||||
if (name == "test") return@configureEach
|
|
||||||
useJUnit()
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project())
|
|
||||||
implementation("com.android.tools.build:gradle:7.2.1")
|
|
||||||
implementation("com.android.tools.build:gradle-api:7.2.1")
|
|
||||||
compileOnly("com.android.tools:common:30.2.1")
|
|
||||||
implementation(gradleKotlinDsl())
|
|
||||||
implementation(project(":kotlin-gradle-plugin-kpm-android"))
|
|
||||||
implementation(project(":kotlin-gradle-plugin-tcs-android"))
|
|
||||||
implementation(project(":kotlin-tooling-metadata"))
|
|
||||||
implementation(project.dependencies.testFixtures(project(":kotlin-gradle-plugin-idea")))
|
|
||||||
implementation("com.github.gundy:semver4j:0.16.4:nodeps") {
|
|
||||||
(this as ExternalModuleDependency).exclude(group = "*")
|
|
||||||
}
|
|
||||||
implementation("org.reflections:reflections:0.10.2")
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations.named(sources.implementationConfigurationName) {
|
|
||||||
extendsFrom(configurations.getByName(mainSourceSet.implementationConfigurationName))
|
|
||||||
extendsFrom(configurations.getByName(testSourceSet.implementationConfigurationName))
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations.named(sources.runtimeOnlyConfigurationName) {
|
|
||||||
extendsFrom(configurations.getByName(mainSourceSet.runtimeOnlyConfigurationName))
|
|
||||||
extendsFrom(configurations.getByName(testSourceSet.runtimeOnlyConfigurationName))
|
|
||||||
}
|
|
||||||
|
|
||||||
targets.all {
|
|
||||||
testTask.configure {
|
|
||||||
dependsOnKotlinGradlePluginInstall()
|
|
||||||
|
|
||||||
testLogging {
|
|
||||||
events("passed", "skipped", "failed")
|
|
||||||
}
|
|
||||||
|
|
||||||
javaLauncher.set(javaToolchains.launcherFor {
|
|
||||||
languageVersion.set(JavaLanguageVersion.of(11))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// open internal visibility to the test code
|
|
||||||
kotlin.target.compilations {
|
|
||||||
named(name) {
|
|
||||||
associateWith(this@compilations.getByName("main"))
|
|
||||||
associateWith(this@compilations.getByName("common"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.named("check") {
|
|
||||||
dependsOn(functionalTest.name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val functionalTestCompilation = kotlin.target.compilations.getByName("functionalTest")
|
||||||
|
functionalTestCompilation.associateWith(kotlin.target.compilations.getByName("main"))
|
||||||
|
functionalTestCompilation.associateWith(kotlin.target.compilations.getByName("common"))
|
||||||
|
|
||||||
|
tasks.register<Test>("functionalTest")
|
||||||
|
|
||||||
|
tasks.register<Test>("functionalUnitTest") {
|
||||||
|
include("**/org/jetbrains/kotlin/gradle/unitTests/**")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<Test>("functionalRegressionTest") {
|
||||||
|
include("**/org/jetbrains/kotlin/gradle/regressionTests/**")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<Test>("functionalDependencyResolutionTest") {
|
||||||
|
include("**/org/jetbrains/kotlin/gradle/dependencyResolutionTests/**")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test>().configureEach {
|
||||||
|
if (!name.startsWith("functional")) return@configureEach
|
||||||
|
|
||||||
|
group = JavaBasePlugin.VERIFICATION_GROUP
|
||||||
|
description = "Runs functional tests"
|
||||||
|
testClassesDirs = functionalTestSourceSet.output.classesDirs
|
||||||
|
classpath = functionalTestSourceSet.runtimeClasspath
|
||||||
|
workingDir = projectDir
|
||||||
|
javaLauncher.set(javaToolchains.launcherFor {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(11))
|
||||||
|
})
|
||||||
|
dependsOnKotlinGradlePluginInstall()
|
||||||
|
|
||||||
|
testLogging {
|
||||||
|
events("passed", "skipped", "failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
val implementation = project.configurations.getByName(functionalTestSourceSet.implementationConfigurationName)
|
||||||
|
val compileOnly = project.configurations.getByName(functionalTestSourceSet.compileOnlyConfigurationName)
|
||||||
|
|
||||||
|
implementation("com.android.tools.build:gradle:7.2.1")
|
||||||
|
implementation("com.android.tools.build:gradle-api:7.2.1")
|
||||||
|
compileOnly("com.android.tools:common:30.2.1")
|
||||||
|
implementation(gradleKotlinDsl())
|
||||||
|
implementation(project(":kotlin-gradle-plugin-kpm-android"))
|
||||||
|
implementation(project(":kotlin-gradle-plugin-tcs-android"))
|
||||||
|
implementation(project(":kotlin-tooling-metadata"))
|
||||||
|
implementation(project.dependencies.testFixtures(project(":kotlin-gradle-plugin-idea")))
|
||||||
|
implementation("com.github.gundy:semver4j:0.16.4:nodeps") {
|
||||||
|
(this as ExternalModuleDependency).exclude(group = "*")
|
||||||
|
}
|
||||||
|
implementation("org.reflections:reflections:0.10.2")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("check") {
|
||||||
|
dependsOn("functionalTest")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user