Skip to content

Commit d969dd6

Browse files
demiurg906Space Team
authored andcommitted
[Build] Migrate remaining usages of projectTests to project-tests-convention
Only one usage left outside of convention plugins, in the :compiler:build-tools:kotlin-build-tools-api-tests module.
1 parent de9f90d commit d969dd6

File tree

17 files changed

+159
-113
lines changed

17 files changed

+159
-113
lines changed

compiler/build-tools/kotlin-build-tools-api-tests/build.gradle.kts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
kotlin("jvm")
55
`jvm-test-suite`
66
id("test-symlink-transformation")
7+
id("compiler-tests-convention")
78
}
89

910
dependencies {
@@ -96,9 +97,11 @@ testing {
9697
}
9798
}
9899
targets.all {
99-
projectTest(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5) {
100-
ensureExecutedAgainstExpectedBuildToolsImplVersion(implVersion)
101-
systemProperty("kotlin.build-tools-api.log.level", "DEBUG")
100+
compilerTests {
101+
testTask(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5, skipInLocalBuild = false) {
102+
ensureExecutedAgainstExpectedBuildToolsImplVersion(implVersion)
103+
systemProperty("kotlin.build-tools-api.log.level", "DEBUG")
104+
}
102105
}
103106
}
104107
}
@@ -123,8 +126,10 @@ testing {
123126

124127
targets.all {
125128
if (!testTask.name.startsWith("testCompatibility")) {
126-
projectTest(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5) {
127-
systemProperty("kotlin.build-tools-api.log.level", "DEBUG")
129+
compilerTests {
130+
testTask(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5, skipInLocalBuild = false) {
131+
systemProperty("kotlin.build-tools-api.log.level", "DEBUG")
132+
}
128133
}
129134
}
130135
}

compiler/tests-different-jdk/build.gradle.kts

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -42,61 +42,62 @@ projectTests {
4242
withMockJdkAnnotationsJar()
4343
withThirdPartyAnnotations()
4444
withThirdPartyJsr305()
45-
}
4645

47-
fun Project.codegenTest(
48-
target: Int,
49-
jdk: JdkMajorVersion,
50-
jvm: String = jdk.majorVersion.toString(),
51-
targetInTestClass: String = "$target",
52-
body: Test.() -> Unit = {}
53-
): TaskProvider<Test> = projectTest(
54-
taskName = "codegenTarget${targetInTestClass}Jvm${jvm}Test",
55-
jUnitMode = JUnitMode.JUnit5,
56-
maxMetaspaceSizeMb = 1024
57-
) {
58-
useJUnitPlatform()
59-
60-
val testName = "JvmTarget${targetInTestClass}OnJvm${jvm}"
61-
filter.includeTestsMatching("org.jetbrains.kotlin.codegen.jdk.$testName")
62-
63-
javaLauncher.set(project.getToolchainLauncherFor(jdk))
64-
65-
systemProperty("kotlin.test.default.jvm.target", "${if (target <= 8) "1." else ""}$target")
66-
body()
67-
doFirst {
68-
logger.warn("Running tests with $target target and ${javaLauncher.get().metadata.installationPath.asFile}")
46+
fun codegenTestTask(
47+
target: Int,
48+
jdk: JdkMajorVersion,
49+
jvm: String = jdk.majorVersion.toString(),
50+
targetInTestClass: String = "$target",
51+
body: Test.() -> Unit = {},
52+
) {
53+
testTask(
54+
taskName = "codegenTarget${targetInTestClass}Jvm${jvm}Test",
55+
jUnitMode = JUnitMode.JUnit5,
56+
maxMetaspaceSizeMb = 1024,
57+
skipInLocalBuild = false
58+
) {
59+
val testName = "JvmTarget${targetInTestClass}OnJvm${jvm}"
60+
filter.includeTestsMatching("org.jetbrains.kotlin.codegen.jdk.$testName")
61+
62+
javaLauncher.set(project.getToolchainLauncherFor(jdk))
63+
64+
systemProperty("kotlin.test.default.jvm.target", "${if (target <= 8) "1." else ""}$target")
65+
body()
66+
doFirst {
67+
logger.warn("Running tests with $target target and ${javaLauncher.get().metadata.installationPath.asFile}")
68+
}
69+
group = "verification"
70+
}
6971
}
70-
group = "verification"
71-
}
7272

73-
//JDK 8
74-
// This is default one and is executed in default build configuration
75-
codegenTest(target = 8, jdk = JdkMajorVersion.JDK_1_8)
73+
//JDK 8
74+
// This is default one and is executed in default build configuration
75+
codegenTestTask(target = 8, jdk = JdkMajorVersion.JDK_1_8)
7676

77-
//JDK 11
78-
codegenTest(target = 8, jdk = JdkMajorVersion.JDK_11_0)
77+
//JDK 11
78+
codegenTestTask(target = 8, jdk = JdkMajorVersion.JDK_11_0)
7979

80-
codegenTest(target = 11, jdk = JdkMajorVersion.JDK_11_0)
80+
codegenTestTask(target = 11, jdk = JdkMajorVersion.JDK_11_0)
8181

82-
//JDK 17
83-
codegenTest(target = 8, jdk = JdkMajorVersion.JDK_17_0)
82+
//JDK 17
83+
codegenTestTask(target = 8, jdk = JdkMajorVersion.JDK_17_0)
8484

85-
codegenTest(target = 17, jdk = JdkMajorVersion.JDK_17_0) {
86-
systemProperty("kotlin.test.box.d8.disable", true)
87-
}
85+
codegenTestTask(target = 17, jdk = JdkMajorVersion.JDK_17_0) {
86+
systemProperty("kotlin.test.box.d8.disable", true)
87+
}
8888

89-
//..also add this two tasks to build after adding fresh jdks to build agents
90-
val mostRecentJdk = JdkMajorVersion.values().last()
89+
//..also add this two tasks to build after adding fresh jdks to build agents
90+
val mostRecentJdk = JdkMajorVersion.values().last()
9191

92-
//LAST JDK from JdkMajorVersion available on machine
93-
codegenTest(target = 8, jvm = "Last", jdk = mostRecentJdk)
92+
//LAST JDK from JdkMajorVersion available on machine
93+
codegenTestTask(target = 8, jvm = "Last", jdk = mostRecentJdk)
9494

95-
codegenTest(
96-
target = mostRecentJdk.majorVersion,
97-
targetInTestClass = "Last",
98-
jvm = "Last",
99-
jdk = mostRecentJdk
100-
) {
101-
systemProperty("kotlin.test.box.d8.disable", true)
95+
codegenTestTask(
96+
target = mostRecentJdk.majorVersion,
97+
targetInTestClass = "Last",
98+
jvm = "Last",
99+
jdk = mostRecentJdk
100+
) {
101+
systemProperty("kotlin.test.box.d8.disable", true)
102+
}
102103
}

generators/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
kotlin("jvm")
33
id("jps-compatible")
4+
id("project-tests-convention")
45
}
56

67
sourceSets {
@@ -92,8 +93,10 @@ dependencies {
9293
testRuntimeOnly(libs.junit.jupiter.engine)
9394
}
9495

95-
projectTest(parallel = true, jUnitMode = JUnitMode.JUnit4) {
96-
workingDir = rootDir
96+
projectTests {
97+
testTask(parallel = true, jUnitMode = JUnitMode.JUnit4) {
98+
workingDir = rootDir
99+
}
97100
}
98101

99102
val generateCompilerArgumentsCopy by generator("org.jetbrains.kotlin.generators.arguments.GenerateCompilerArgumentsCopyKt")

kotlin-native/common/env/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id("native-interop-plugin")
3+
id("project-tests-convention")
34
}
45

56
dependencies {
@@ -18,4 +19,6 @@ nativeInteropPlugin {
1819
additionalLinkedStaticLibraries.set(emptyList<String>())
1920
}
2021

21-
projectTest(jUnitMode = JUnitMode.JUnit5) // `projectTest()` is not available in kotlin-native/build-tools project
22+
projectTests {
23+
testTask(jUnitMode = JUnitMode.JUnit5)
24+
}

kotlin-native/common/files/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id("native-interop-plugin")
3+
id("project-tests-convention")
34
}
45

56
dependencies {
@@ -18,4 +19,6 @@ nativeInteropPlugin {
1819
additionalLinkedStaticLibraries.set(emptyList<String>())
1920
}
2021

21-
projectTest(jUnitMode = JUnitMode.JUnit5) // `projectTest()` is not available in kotlin-native/build-tools project
22+
projectTests {
23+
testTask(jUnitMode = JUnitMode.JUnit5)
24+
}

kotlin-native/libclangInterop/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import org.jetbrains.kotlin.tools.lib
44

55
plugins {
66
id("native-interop-plugin")
7+
id("project-tests-convention")
78
}
89

910
dependencies {
@@ -76,4 +77,6 @@ nativeInteropPlugin {
7677
})
7778
}
7879

79-
projectTest(jUnitMode = JUnitMode.JUnit5) // `projectTest()` is not available in kotlin-native/build-tools project
80+
projectTests {
81+
testTask(jUnitMode = JUnitMode.JUnit5)
82+
}

kotlin-native/llvmInterop/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.tools.lib
33

44
plugins {
55
id("native-interop-plugin")
6+
id("project-tests-convention")
67
}
78

89
dependencies {
@@ -74,4 +75,6 @@ nativeInteropPlugin {
7475
})
7576
}
7677

77-
projectTest(jUnitMode = JUnitMode.JUnit5) // `projectTest()` is not available in kotlin-native/build-tools project
78+
projectTests {
79+
testTask(jUnitMode = JUnitMode.JUnit5)
80+
}

kotlin-native/prepare/kotlin-native-compiler-embeddable/build.gradle.kts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.jetbrains.kotlin.nativeDistribution.nativeDistributionProperty
55

66
plugins {
77
kotlin("jvm")
8+
id("project-tests-convention")
89
}
910

1011
description = "Embeddable JAR of Kotlin/Native compiler"
@@ -112,16 +113,18 @@ open class ProjectTestArgumentProvider @Inject constructor(
112113
)
113114
}
114115

115-
projectTest(jUnitMode = JUnitMode.JUnit4) {
116-
/**
117-
* It's expected that test should be executed on CI, but currently this project under `kotlin.native.enabled`
118-
*/
119-
jvmArgumentProviders.add(objects.newInstance<ProjectTestArgumentProvider>().apply {
120-
compilerClasspath.from(runtimeJar)
121-
122-
// The tests run the compiler and try to produce an executable on host.
123-
// So, distribution with stdlib and runtime for host is required.
124-
nativeDistribution.set(project.nativeDistribution)
125-
dependsOn(":kotlin-native:distRuntime")
126-
})
116+
projectTests {
117+
testTask(jUnitMode = JUnitMode.JUnit4) {
118+
/**
119+
* It's expected that test should be executed on CI, but currently this project under `kotlin.native.enabled`
120+
*/
121+
jvmArgumentProviders.add(objects.newInstance<ProjectTestArgumentProvider>().apply {
122+
compilerClasspath.from(runtimeJar)
123+
124+
// The tests run the compiler and try to produce an executable on host.
125+
// So, distribution with stdlib and runtime for host is required.
126+
nativeDistribution.set(project.nativeDistribution)
127+
dependsOn(":kotlin-native:distRuntime")
128+
})
129+
}
127130
}

libraries/tools/abi-validation/kgp-integration-tests/build.gradle.kts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
plugins {
22
kotlin("jvm")
3+
id("project-tests-convention")
34
}
45

5-
projectTest(jUnitMode = JUnitMode.JUnit4) {
6-
// Disable KONAN_DATA_DIR env variable for all integration tests
7-
// because we are using `konan.data.dir` gradle property instead
8-
environment.remove("KONAN_DATA_DIR")
6+
projectTests {
7+
testTask(jUnitMode = JUnitMode.JUnit4) {
8+
// Disable KONAN_DATA_DIR env variable for all integration tests
9+
// because we are using `konan.data.dir` gradle property instead
10+
environment.remove("KONAN_DATA_DIR")
911

10-
dependsOnKotlinGradlePluginInstall()
12+
dependsOnKotlinGradlePluginInstall()
1113

12-
if (project.kotlinBuildProperties.isKotlinNativeEnabled) {
13-
// Build full Kotlin Native bundle
14-
dependsOn(":kotlin-native:install")
15-
}
14+
if (project.kotlinBuildProperties.isKotlinNativeEnabled) {
15+
// Build full Kotlin Native bundle
16+
dependsOn(":kotlin-native:install")
17+
}
1618

17-
systemProperty("kotlinVersion", rootProject.extra["kotlinVersion"] as String)
19+
systemProperty("kotlinVersion", rootProject.extra["kotlinVersion"] as String)
20+
}
1821
}
1922

2023
dependencies {

libraries/tools/analysis-api-based-klib-reader/build.gradle.kts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import org.jetbrains.kotlin.konan.target.HostManager
77
plugins {
88
kotlin("jvm")
99
id("jps-compatible")
10+
id("project-tests-convention")
1011
}
1112

1213
sourceSets {
@@ -20,30 +21,31 @@ kotlin {
2021
}
2122
}
2223

23-
projectTest(jUnitMode = JUnitMode.JUnit5) {
24-
workingDir = rootDir
24+
projectTests {
25+
testTask(jUnitMode = JUnitMode.JUnit5) {
26+
workingDir = rootDir
2527

26-
useJUnitPlatform()
27-
val testProjectKlib = configurations.create("testProjectKlib") {
28-
attributes {
29-
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_API))
30-
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
31-
attribute(KotlinPlatformType.attribute, KotlinPlatformType.native)
32-
attribute(KotlinNativeTarget.konanTargetAttribute, HostManager.host.name)
28+
val testProjectKlib = configurations.create("testProjectKlib") {
29+
attributes {
30+
attribute(Usage.USAGE_ATTRIBUTE, objects.named(KotlinUsages.KOTLIN_API))
31+
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
32+
attribute(KotlinPlatformType.attribute, KotlinPlatformType.native)
33+
attribute(KotlinNativeTarget.konanTargetAttribute, HostManager.host.name)
34+
}
3335
}
34-
}
3536

36-
val testProjectKlibFiles = testProjectKlib.incoming.files
37+
val testProjectKlibFiles = testProjectKlib.incoming.files
3738

38-
dependencies {
39-
testProjectKlib(project("testProject"))
40-
}
39+
dependencies {
40+
testProjectKlib(project("testProject"))
41+
}
4142

42-
inputs.files(testProjectKlibFiles)
43-
.withPathSensitivity(PathSensitivity.RELATIVE)
43+
inputs.files(testProjectKlibFiles)
44+
.withPathSensitivity(PathSensitivity.RELATIVE)
4445

45-
doFirst {
46-
systemProperty("testKlibs", testProjectKlibFiles.joinToString(File.pathSeparator))
46+
doFirst {
47+
systemProperty("testKlibs", testProjectKlibFiles.joinToString(File.pathSeparator))
48+
}
4749
}
4850
}
4951

0 commit comments

Comments
 (0)