Skip to content

Commit ddb4930

Browse files
demiurg906Space Team
authored andcommitted
[Build] Move nativeTests utilities to the project-tests-convention
1 parent d969dd6 commit ddb4930

File tree

28 files changed

+292
-248
lines changed

28 files changed

+292
-248
lines changed

analysis/analysis-api-standalone/analysis-api-standalone-native/build.gradle.kts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ sourceSets {
2727

2828

2929
projectTests {
30-
testTask(jUnitMode = JUnitMode.JUnit5) {
31-
dependsOn(":dist")
32-
workingDir = rootDir
30+
nativeTestTask("test", tag = null) {
31+
systemProperty("kotlin.native.home", kotlinNativeDist.absolutePath)
3332
}
3433
}
3534

36-
val test by nativeTest("test", null) {
37-
systemProperty("kotlin.native.home", kotlinNativeDist.absolutePath)
38-
}
39-
4035
testsJar()

analysis/low-level-api-fir/low-level-api-fir-native/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ projectTests {
2828
dependsOn(":dist")
2929
workingDir = rootDir
3030
}
31-
}
3231

33-
nativeTest("llFirNativeTests", "llFirNative", requirePlatformLibs = true)
32+
nativeTestTask("llFirNativeTests", "llFirNative", requirePlatformLibs = true)
33+
}
3434

3535
testsJar()

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

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

1010
dependencies {
@@ -97,7 +97,7 @@ testing {
9797
}
9898
}
9999
targets.all {
100-
compilerTests {
100+
projectTests {
101101
testTask(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5, skipInLocalBuild = false) {
102102
ensureExecutedAgainstExpectedBuildToolsImplVersion(implVersion)
103103
systemProperty("kotlin.build-tools-api.log.level", "DEBUG")
@@ -126,7 +126,7 @@ testing {
126126

127127
targets.all {
128128
if (!testTask.name.startsWith("testCompatibility")) {
129-
compilerTests {
129+
projectTests {
130130
testTask(taskName = testTask.name, jUnitMode = JUnitMode.JUnit5, skipInLocalBuild = false) {
131131
systemProperty("kotlin.build-tools-api.log.level", "DEBUG")
132132
}

native/native.tests/build.gradle.kts

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
kotlin("jvm")
33
id("jps-compatible")
44
id("java-test-fixtures")
5+
id("project-tests-convention")
56
}
67

78
dependencies {
@@ -46,50 +47,52 @@ sourceSets {
4647

4748
testsJar {}
4849

49-
// Tasks that run different sorts of tests. Most frequent use case: running specific tests at TeamCity.
50-
val infrastructureTest = nativeTest("infrastructureTest", "infrastructure")
51-
val stdlibTest = nativeTest("stdlibTest", "stdlib")
52-
val kotlinTestLibraryTest = nativeTest("kotlinTestLibraryTest", "kotlin-test")
53-
val partialLinkageTest = nativeTest("partialLinkageTest", "partial-linkage")
54-
val cinteropTest = nativeTest("cinteropTest", "cinterop")
55-
val debuggerTest = nativeTest("debuggerTest", "debugger")
56-
val cachesTest = nativeTest("cachesTest", "caches")
57-
val klibTest = nativeTest("klibTest", "klib")
58-
val standaloneTest = nativeTest("standaloneTest", "standalone")
59-
val gcTest = nativeTest("gcTest", "gc")
50+
projectTests {
51+
// Tasks that run different sorts of tests. Most frequent use case: running specific tests at TeamCity.
52+
nativeTestTask("infrastructureTest", "infrastructure")
53+
nativeTestTask("stdlibTest", "stdlib")
54+
nativeTestTask("kotlinTestLibraryTest", "kotlin-test")
55+
nativeTestTask("partialLinkageTest", "partial-linkage")
56+
nativeTestTask("cinteropTest", "cinterop")
57+
nativeTestTask("debuggerTest", "debugger")
58+
nativeTestTask("cachesTest", "caches")
59+
nativeTestTask("klibTest", "klib")
60+
nativeTestTask("standaloneTest", "standalone")
61+
nativeTestTask("gcTest", "gc")
6062

61-
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
62-
// Note: arbitrary JUnit tag expressions can be used in this property.
63-
// See https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions
64-
val test by nativeTest(
65-
"test",
66-
testTags,
67-
requirePlatformLibs = true,
68-
defineJDKEnvVariables = listOf(
69-
JdkMajorVersion.JDK_1_8, // required in CompilerOutputTest via AbstractCliTest.getNormalizedCompilerOutput
70-
JdkMajorVersion.JDK_11_0, // required in CompilerOutputTest via AbstractCliTest.getNormalizedCompilerOutput
71-
JdkMajorVersion.JDK_17_0, // required in CompilerOutputTest via AbstractCliTest.getNormalizedCompilerOutput
72-
JdkMajorVersion.JDK_21_0,
73-
)
74-
) {
75-
options {
76-
// See [org.jetbrains.kotlin.konan.test.KlibCrossCompilationIdentityTest.FULL_CROSS_DIST_ENABLED_PROPERTY]
77-
// See also kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/nativeFullCrossDist.kt
78-
systemProperty(
79-
"kotlin.native.internal.fullCrossDistEnabled",
80-
kotlinBuildProperties.getOrNull("kotlin.native.pathToDarwinDist") != null
63+
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
64+
// Note: arbitrary JUnit tag expressions can be used in this property.
65+
// See https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions
66+
nativeTestTask(
67+
"test",
68+
testTags,
69+
requirePlatformLibs = true,
70+
defineJDKEnvVariables = listOf(
71+
JdkMajorVersion.JDK_1_8, // required in CompilerOutputTest via AbstractCliTest.getNormalizedCompilerOutput
72+
JdkMajorVersion.JDK_11_0, // required in CompilerOutputTest via AbstractCliTest.getNormalizedCompilerOutput
73+
JdkMajorVersion.JDK_17_0, // required in CompilerOutputTest via AbstractCliTest.getNormalizedCompilerOutput
74+
JdkMajorVersion.JDK_21_0,
8175
)
82-
}
76+
) {
77+
options {
78+
// See [org.jetbrains.kotlin.konan.test.KlibCrossCompilationIdentityTest.FULL_CROSS_DIST_ENABLED_PROPERTY]
79+
// See also kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/nativeFullCrossDist.kt
80+
systemProperty(
81+
"kotlin.native.internal.fullCrossDistEnabled",
82+
kotlinBuildProperties.getOrNull("kotlin.native.pathToDarwinDist") != null
83+
)
84+
}
8385

84-
// To workaround KTI-2421, we make these tests run on JDK 11 instead of the project-default JDK 8.
85-
// Kotlin test infra uses reflection to access JDK internals.
86-
// With JDK 11, some JVM args are required to silence the warnings caused by that:
87-
jvmArgs("--add-opens=java.base/java.io=ALL-UNNAMED")
88-
}
86+
// To workaround KTI-2421, we make these tests run on JDK 11 instead of the project-default JDK 8.
87+
// Kotlin test infra uses reflection to access JDK internals.
88+
// With JDK 11, some JVM args are required to silence the warnings caused by that:
89+
jvmArgs("--add-opens=java.base/java.io=ALL-UNNAMED")
90+
}
8991

90-
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt") {
91-
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11_0))
92-
dependsOn(":compiler:generateTestData")
92+
testGenerator("org.jetbrains.kotlin.generators.tests.GenerateNativeTestsKt") {
93+
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11_0))
94+
dependsOn(":compiler:generateTestData")
95+
}
9396
}
9497

9598
optInToK1Deprecation()
Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
kotlin("jvm")
33
id("java-test-fixtures")
4+
id("project-tests-convention")
45
}
56

67
dependencies {
@@ -21,25 +22,27 @@ sourceSets {
2122

2223
testsJar {}
2324

24-
nativeTest(
25-
"test",
26-
null,
27-
defineJDKEnvVariables = listOf(
28-
JdkMajorVersion.JDK_1_8,
29-
JdkMajorVersion.JDK_11_0,
30-
JdkMajorVersion.JDK_17_0,
31-
JdkMajorVersion.JDK_21_0
32-
)
33-
) {
34-
// Kotlin test infra and IntelliJ platform Disposer debug mode use reflection to access JDK internals.
35-
// With JDK 11, some JVM args are required to silence the warnings caused by that:
36-
jvmArgs(
37-
"--add-opens=java.base/java.io=ALL-UNNAMED",
38-
"--add-opens=java.base/java.lang=ALL-UNNAMED",
39-
"--add-opens=java.desktop/javax.swing=ALL-UNNAMED",
40-
)
41-
}
25+
projectTests {
26+
nativeTestTask(
27+
"test",
28+
tag = null,
29+
defineJDKEnvVariables = listOf(
30+
JdkMajorVersion.JDK_1_8,
31+
JdkMajorVersion.JDK_11_0,
32+
JdkMajorVersion.JDK_17_0,
33+
JdkMajorVersion.JDK_21_0
34+
)
35+
) {
36+
// Kotlin test infra and IntelliJ platform Disposer debug mode use reflection to access JDK internals.
37+
// With JDK 11, some JVM args are required to silence the warnings caused by that:
38+
jvmArgs(
39+
"--add-opens=java.base/java.io=ALL-UNNAMED",
40+
"--add-opens=java.base/java.lang=ALL-UNNAMED",
41+
"--add-opens=java.desktop/javax.swing=ALL-UNNAMED",
42+
)
43+
}
4244

43-
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateCliTestsKt") {
44-
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11_0))
45+
testGenerator("org.jetbrains.kotlin.generators.tests.GenerateCliTestsKt") {
46+
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11_0))
47+
}
4548
}

native/native.tests/codegen-box/build.gradle.kts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ sourceSets {
2525

2626
projectTests {
2727
testData(project(":compiler").isolated, "testData/codegen")
28-
}
2928

30-
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
31-
// Note: arbitrary JUnit tag expressions can be used in this property.
32-
// See https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions
33-
val test by nativeTest("test", testTags) {
34-
extensions.configure<TestInputsCheckExtension> {
35-
isNative.set(true)
36-
useXcode.set(OperatingSystem.current().isMacOsX)
29+
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
30+
// Note: arbitrary JUnit tag expressions can be used in this property.
31+
// See https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions
32+
nativeTestTask("test", testTags) {
33+
extensions.configure<TestInputsCheckExtension> {
34+
isNative.set(true)
35+
useXcode.set(OperatingSystem.current().isMacOsX)
36+
}
37+
// nativeTest sets workingDir to rootDir so here we need to override it
38+
workingDir = projectDir
3739
}
38-
// nativeTest sets workingDir to rootDir so here we need to override it
39-
workingDir = projectDir
4040
}

native/native.tests/driver/build.gradle.kts

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

56
dependencies {
@@ -20,9 +21,11 @@ sourceSets {
2021

2122
testsJar {}
2223

23-
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
24-
nativeTest(
25-
"test",
26-
testTags,
27-
allowParallelExecution = false, // Driver tests run Native compiler from CLI. This is resource-intensive and should be done isolated.
28-
)
24+
projectTests {
25+
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
26+
nativeTestTask(
27+
"test",
28+
testTags,
29+
allowParallelExecution = false, // Driver tests run Native compiler from CLI. This is resource-intensive and should be done isolated.
30+
)
31+
}

native/native.tests/gc-fuzzing-tests/build.gradle.kts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ sourceSets {
2121

2222
projectTests {
2323
testData(project.isolated, "testData")
24-
}
25-
26-
nativeTest(
27-
"test",
28-
null,
29-
allowParallelExecution = false, // some of the tests may spawn quite a lot of threads
30-
) {
31-
// nativeTest sets workingDir to rootDir so here we need to override it
32-
workingDir = projectDir
24+
nativeTestTask(
25+
"test",
26+
tag = null,
27+
allowParallelExecution = false, // some of the tests may spawn quite a lot of threads
28+
) {
29+
// nativeTest sets workingDir to rootDir so here we need to override it
30+
workingDir = projectDir
31+
}
3332
}

native/native.tests/klib-compatibility/build.gradle.kts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import java.io.File
33

44
plugins {
55
kotlin("jvm")
6+
id("project-tests-convention")
67
}
78

89
dependencies {
@@ -47,15 +48,17 @@ val downloadCustomCompilerDist: TaskProvider<Sync> by tasks.registering(Sync::cl
4748
into(layout.buildDirectory.dir("customCompiler$customCompilerVersion"))
4849
}
4950

50-
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
51-
nativeTest(
52-
"test",
53-
testTags,
54-
customCompilerDist = downloadCustomCompilerDist,
55-
maxMetaspaceSizeMb = 1024 // to handle two compilers in classloader
56-
) {
57-
// To workaround KTI-2421, we make these tests run on JDK 11 instead of the project-default JDK 8.
58-
// Kotlin test infra uses reflection to access JDK internals.
59-
// With JDK 11, some JVM args are required to silence the warnings caused by that:
60-
jvmArgs("--add-opens=java.base/java.io=ALL-UNNAMED")
51+
projectTests {
52+
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
53+
nativeTestTask(
54+
"test",
55+
testTags,
56+
customCompilerDist = downloadCustomCompilerDist,
57+
maxMetaspaceSizeMb = 1024 // to handle two compilers in classloader
58+
) {
59+
// To workaround KTI-2421, we make these tests run on JDK 11 instead of the project-default JDK 8.
60+
// Kotlin test infra uses reflection to access JDK internals.
61+
// With JDK 11, some JVM args are required to silence the warnings caused by that:
62+
jvmArgs("--add-opens=java.base/java.io=ALL-UNNAMED")
63+
}
6164
}

native/native.tests/klib-ir-inliner/build.gradle.kts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,31 @@ projectTests {
3737
testData(project(":compiler").isolated, "testData/diagnostics")
3838
testData(project(":native:native.tests").isolated, "testData/klib")
3939
testData(project(":native:native.tests").isolated, "testData/irProvidersMismatch")
40-
}
4140

42-
testsJar {}
41+
nativeTestTask(
42+
"test",
43+
null,
44+
allowParallelExecution = true,
45+
requirePlatformLibs = true,
46+
) {
47+
// To workaround KTI-2421, we make these tests run on JDK 11 instead of the project-default JDK 8.
48+
// Kotlin test infra uses reflection to access JDK internals.
49+
// With JDK 11, some JVM args are required to silence the warnings caused by that:
50+
jvmArgs("--add-opens=java.base/java.io=ALL-UNNAMED")
4351

44-
nativeTest(
45-
"test",
46-
null,
47-
allowParallelExecution = true,
48-
requirePlatformLibs = true,
49-
) {
50-
// To workaround KTI-2421, we make these tests run on JDK 11 instead of the project-default JDK 8.
51-
// Kotlin test infra uses reflection to access JDK internals.
52-
// With JDK 11, some JVM args are required to silence the warnings caused by that:
53-
jvmArgs("--add-opens=java.base/java.io=ALL-UNNAMED")
52+
extensions.configure<TestInputsCheckExtension> {
53+
isNative.set(true)
54+
useXcode.set(OperatingSystem.current().isMacOsX)
55+
}
56+
// nativeTest sets workingDir to rootDir so here we need to override it
57+
workingDir = projectDir
58+
systemProperty("user.dir", layout.buildDirectory.asFile.get().absolutePath)
59+
}
5460

55-
extensions.configure<TestInputsCheckExtension> {
56-
isNative.set(true)
57-
useXcode.set(OperatingSystem.current().isMacOsX)
61+
testGenerator("org.jetbrains.kotlin.generators.tests.GenerateKlibNativeTestsKt") {
62+
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11_0))
63+
dependsOn(":compiler:generateTestData")
5864
}
59-
// nativeTest sets workingDir to rootDir so here we need to override it
60-
workingDir = projectDir
61-
systemProperty("user.dir", layout.buildDirectory.asFile.get().absolutePath)
6265
}
6366

64-
val generateTests by generator("org.jetbrains.kotlin.generators.tests.GenerateKlibNativeTestsKt") {
65-
javaLauncher.set(project.getToolchainLauncherFor(JdkMajorVersion.JDK_11_0))
66-
dependsOn(":compiler:generateTestData")
67-
}
67+
testsJar {}

0 commit comments

Comments
 (0)