[Build, BTA] Add the build tools api tests module
The module is configured to run a bunch of test suites defined as API pairs. Currently those are `CURRENT API` – `CURRENT IMPL`, `CURRENT API` – `1.9.20 IMPL`, `1.9.20 API` – `CURRENT IMPL` ^KT-61860 In Progress
This commit is contained in:
committed by
Space Team
parent
0196928af7
commit
4afb393ff1
@@ -0,0 +1,143 @@
|
||||
import org.gradle.configurationcache.extensions.capitalized
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
`jvm-test-suite`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(kotlinStdlib())
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
optIn.add("org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi")
|
||||
}
|
||||
}
|
||||
|
||||
class BuildToolsApiTestSuit(
|
||||
val testName: String,
|
||||
val apiVersion: BuildToolsVersion,
|
||||
val implVersion: BuildToolsVersion,
|
||||
/**
|
||||
* Tells whether only tests marked with the `CompatibilityTest` JUnit tag must be run
|
||||
*/
|
||||
val onlyCompatibilityTests: Boolean = true,
|
||||
)
|
||||
|
||||
val testMatrix = listOf(
|
||||
BuildToolsApiTestSuit(
|
||||
"testDefaultToDefault",
|
||||
BuildToolsVersion(KotlinToolingVersion(project.version.toString()), isCurrent = true),
|
||||
BuildToolsVersion(KotlinToolingVersion(project.version.toString()), isCurrent = true),
|
||||
onlyCompatibilityTests = false,
|
||||
),
|
||||
BuildToolsApiTestSuit(
|
||||
"test1.9.20ToDefault",
|
||||
BuildToolsVersion(KotlinToolingVersion(1, 9, 20, null)),
|
||||
BuildToolsVersion(KotlinToolingVersion(project.version.toString()), isCurrent = true),
|
||||
),
|
||||
BuildToolsApiTestSuit(
|
||||
"testDefaultTo1.9.20",
|
||||
BuildToolsVersion(KotlinToolingVersion(project.version.toString()), isCurrent = true),
|
||||
BuildToolsVersion(KotlinToolingVersion(1, 9, 20, null)),
|
||||
),
|
||||
)
|
||||
|
||||
val SourceSet.kotlinCompileTask
|
||||
get() = tasks.named<KotlinCompile>("compile${name.capitalized()}Kotlin")
|
||||
|
||||
class BuildToolsVersion(val version: KotlinToolingVersion, val isCurrent: Boolean = false) {
|
||||
override fun toString() = version.toString()
|
||||
}
|
||||
|
||||
fun KotlinCompile.ensureCompiledAgainstExpectedBuildToolsApiVersion(version: BuildToolsVersion) {
|
||||
if (version.isCurrent) return
|
||||
// the check is required for the case when Gradle substitutes external dependencies with project ones
|
||||
doFirst {
|
||||
check(libraries.any { "kotlin-build-tools-api-${version}" in it.name }) {
|
||||
"compilation classpath must contain kotlin-build-tools-api:$version"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Test.ensureExecutedAgainstExpectedBuildToolsImplVersion(version: BuildToolsVersion) {
|
||||
if (version.isCurrent) return
|
||||
// the check is required for the case when Gradle substitutes external dependencies with project ones
|
||||
doFirst {
|
||||
check(classpath.any { "kotlin-build-tools-impl-${version}" in it.name }) {
|
||||
"runtime classpath must contain kotlin-build-tools-impl:$version"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun SourceSet.configureApiVersionSourceDirectories() {
|
||||
java.setSrcDirs(
|
||||
listOf(
|
||||
layout.projectDirectory.dir("src/testCommon/java"),
|
||||
)
|
||||
)
|
||||
kotlin.setSrcDirs(
|
||||
listOf(
|
||||
layout.projectDirectory.dir("src/testCommon/java"),
|
||||
layout.projectDirectory.dir("src/testCommon/kotlin"),
|
||||
)
|
||||
)
|
||||
resources.setSrcDirs(
|
||||
listOf(
|
||||
layout.projectDirectory.dir("src/testCommon/resources"),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
testing {
|
||||
suites {
|
||||
for (suitConfig in testMatrix) {
|
||||
register<JvmTestSuite>(suitConfig.testName) {
|
||||
sources.configureApiVersionSourceDirectories()
|
||||
dependencies {
|
||||
useJUnitJupiter(libs.versions.junit5.get())
|
||||
|
||||
compileOnly(project()) // propagate stdlib from the main dependencies for compilation,
|
||||
// the runtime dependency provides the actual required version
|
||||
implementation(project(":kotlin-tooling-core")) // to reuse `KotlinToolingVersion`
|
||||
|
||||
if (suitConfig.apiVersion.isCurrent) {
|
||||
compileOnly(project(":compiler:build-tools:kotlin-build-tools-api"))
|
||||
} else {
|
||||
compileOnly("org.jetbrains.kotlin:kotlin-build-tools-api:${suitConfig.apiVersion}")
|
||||
}
|
||||
sources.kotlinCompileTask.configure {
|
||||
ensureCompiledAgainstExpectedBuildToolsApiVersion(suitConfig.apiVersion)
|
||||
}
|
||||
|
||||
if (suitConfig.implVersion.isCurrent) {
|
||||
runtimeOnly(project(":compiler:build-tools:kotlin-build-tools-impl"))
|
||||
} else {
|
||||
runtimeOnly("org.jetbrains.kotlin:kotlin-build-tools-impl:${suitConfig.implVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
targets.all {
|
||||
projectTest(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5) {
|
||||
ensureExecutedAgainstExpectedBuildToolsImplVersion(suitConfig.implVersion)
|
||||
useJUnitPlatform {
|
||||
if (suitConfig.onlyCompatibilityTests) {
|
||||
includeTags("CompatibilityTest")
|
||||
}
|
||||
}
|
||||
systemProperty("kotlin.build-tools-api.log.level", "DEBUG")
|
||||
systemProperty("kotlin.build-tools-api.impl-version", suitConfig.implVersion.toString()) // TODO: remove after KT-63862
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("check") {
|
||||
dependsOn(testing.suites)
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.buildtools.api.tests
|
||||
|
||||
import org.junit.jupiter.api.Tag
|
||||
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FUNCTION)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@Tag("CompatibilityTest")
|
||||
annotation class CompatibilityTest
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.buildtools.api.tests
|
||||
|
||||
import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion
|
||||
|
||||
// TODO: remove after KT-63862
|
||||
const val IMPL_VERSION_SYSTEM_PROPERTY = "kotlin.build-tools-api.impl-version"
|
||||
val buildToolsVersion = System.getProperty(IMPL_VERSION_SYSTEM_PROPERTY)
|
||||
?.let { KotlinToolingVersion(it) }
|
||||
?: error("The build tools implementation version must be passed via the `$IMPL_VERSION_SYSTEM_PROPERTY` system property to the tests")
|
||||
@@ -3748,12 +3748,54 @@
|
||||
<sha256 value="2324882ccb36833847b47fc397b50ad46bf96a8959b98ec68f6dc08b47dd7e57" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-build-common" version="1.9.20">
|
||||
<artifact name="kotlin-build-common-1.9.20.jar">
|
||||
<md5 value="e275ef9d49e72fc34a51b376f77de5fb" origin="Generated by Gradle"/>
|
||||
<sha256 value="17319416d0fa12cd77a9f365f8b8cb9c616953883368a5c7f529cf082da9e98d" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-build-gradle-plugin" version="0.0.40">
|
||||
<artifact name="kotlin-build-gradle-plugin-0.0.40.jar">
|
||||
<md5 value="051a39904e8285e78cbcd1dc8e2b221a" origin="Generated by Gradle"/>
|
||||
<sha256 value="ea3644137bdf9006eecd1fa1e6771548de3c9b335ffac6387bff01400ab63bd9" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-api" version="1.9.20">
|
||||
<artifact name="kotlin-build-tools-api-1.9.20.jar">
|
||||
<md5 value="d198342d234320740d50caa6b650df0c" origin="Generated by Gradle"/>
|
||||
<sha256 value="c722948c568352cdc19dc8a8b245d14aae507d4dcffde6a7b26c535c472c1b17" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-build-tools-impl" version="1.9.20">
|
||||
<artifact name="kotlin-build-tools-impl-1.9.20.jar">
|
||||
<md5 value="a6f2282c211d133a4c602b28c30a83ef" origin="Generated by Gradle"/>
|
||||
<sha256 value="b7377a08d67dcddcbe4f7930d8cb0f7d0055789fbb30efdbe97008405d1f026d" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-compiler-embeddable" version="1.9.20">
|
||||
<artifact name="kotlin-compiler-embeddable-1.9.20.jar">
|
||||
<md5 value="788dce78ad5a3c096ccbb957fd3364ea" origin="Generated by Gradle"/>
|
||||
<sha256 value="a25024fe5da8440de01af045c4fcb954a22f078738ec02616085f0cfc57b2702" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-compiler-runner" version="1.9.20">
|
||||
<artifact name="kotlin-compiler-runner-1.9.20.jar">
|
||||
<md5 value="c82ae3a34c76a7e5097402604671a725" origin="Generated by Gradle"/>
|
||||
<sha256 value="49769c046f8d392654a4ab52af795455bd41e88d8392aeab9028f0edd5e8d50b" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-daemon-client" version="1.9.20">
|
||||
<artifact name="kotlin-daemon-client-1.9.20.jar">
|
||||
<md5 value="4f46aeada4e73361b4bb2be71784b434" origin="Generated by Gradle"/>
|
||||
<sha256 value="582230cbcfd65d36b94bc9d127f90024b8cf17dfa4a67ef6a929f14c6c27661c" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-daemon-embeddable" version="1.9.20">
|
||||
<artifact name="kotlin-daemon-embeddable-1.9.20.jar">
|
||||
<md5 value="5c1d5ace55a2f200c383d0d5c195ca0f" origin="Generated by Gradle"/>
|
||||
<sha256 value="a939cb5d6ee2a758c9285bd9f3286824beabe12d9a4b5f49f784d0bca329dea5" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-gradle-plugin-annotations" version="1.8.20-dev-4242">
|
||||
<artifact name="kotlin-gradle-plugin-annotations-1.8.20-dev-4242.jar">
|
||||
<md5 value="eab72c484635dc4d819cdb1c2222e238" origin="Generated by Gradle"/>
|
||||
@@ -3812,6 +3854,12 @@
|
||||
<sha256 value="655825fa6511220fed0cae5aad4dfea2abf98fd10f0ae77eb8daf6abfcd0f027" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-script-runtime" version="1.9.20">
|
||||
<artifact name="kotlin-script-runtime-1.9.20.jar">
|
||||
<md5 value="448f3cef7b52d1552ad3c3d61b08ce04" origin="Generated by Gradle"/>
|
||||
<sha256 value="a26a6256a76f766ab8bacdb409b3f8c940d999712a8e88864252b678d66bab9e" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.jetbrains.kotlin" name="kotlin-reflect" version="1.9.10">
|
||||
<artifact name="kotlin-reflect-1.9.10.jar">
|
||||
<md5 value="dd9c5b1139dd521f3a58bfa05791ccf3" origin="Generated by Gradle"/>
|
||||
@@ -4404,6 +4452,12 @@
|
||||
<sha256 value="e20a5e78b1372f2a4e620832db4442d5077e5cbde280b24c666a3770844999bc" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.junit.jupiter" name="junit-jupiter" version="5.10.0">
|
||||
<artifact name="junit-jupiter-5.10.0.jar">
|
||||
<md5 value="ba19f309e63d0c128c381a8d68432c34" origin="Generated by Gradle"/>
|
||||
<sha256 value="8e4bde23ee28fc443975654a7b28c410a3b78d6be96b78c99ab73695ec344f7c" origin="Generated by Gradle"/>
|
||||
</artifact>
|
||||
</component>
|
||||
<component group="org.junit.jupiter" name="junit-jupiter-api" version="5.0.0">
|
||||
<artifact name="junit-jupiter-api-5.0.0.jar">
|
||||
<md5 value="59468e20e8d8c03c17bd089659d26654" origin="Generated by Gradle"/>
|
||||
|
||||
+2
-1
@@ -422,7 +422,8 @@ if (!buildProperties.inJpsBuildIdeaSync) {
|
||||
}
|
||||
|
||||
include ":compiler:build-tools:kotlin-build-tools-api",
|
||||
":compiler:build-tools:kotlin-build-tools-impl"
|
||||
":compiler:build-tools:kotlin-build-tools-impl",
|
||||
":compiler:build-tools:kotlin-build-tools-api-tests"
|
||||
|
||||
// Experimental modules, should be placed into plugins/compose-compiler-plugin folder
|
||||
include ":plugins:compose-compiler-plugin:compiler",
|
||||
|
||||
Reference in New Issue
Block a user