Skip to content

Commit d8d739d

Browse files
SvyatoslavScherbinaSpace Team
authored and
Space Team
committed
[K/N][tests] Move codegen/box tests to a separate module
Currently, the codegen/box tests runners for Kotlin/Native are placed in the `:native:native.tests` project, among with other tests. This leads to poor DX: * The project has many test tasks, so running tests in IDE is confusing: running a test through a "gutter" asks the user to select a test task. * The "main" test task, "test", requires "platform libraries", so running a test with this task takes a lot of time, and platform libraries are rebuilt after any change in the compiler. To overcome the latter, one could select the `codegenBoxK2Test` task when asked. But that's obscure. This commit improves this by moving the codegen/box test runners for K/N to a separate module, `:native:native.tests:codegen-box`. So now running a K/N codegen/box test in the IDE through a gutter doesn't ask to select a test task and doesn't build platform libraries. ^KT-72597 Fixed
1 parent f4e6fd9 commit d8d739d

File tree

12 files changed

+33
-9
lines changed

12 files changed

+33
-9
lines changed

build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ tasks {
855855
dependsOn(":native:analysis-api-klib-reader:check")
856856
dependsOn(":native:native.tests:test")
857857
dependsOn(":native:native.tests:cli-tests:check")
858+
dependsOn(":native:native.tests:codegen-box:check")
858859
dependsOn(":native:native.tests:driver:check")
859860
dependsOn(":native:native.tests:stress:check")
860861
dependsOn(":native:native.tests:klib-compatibility:check")

kotlin-native/HACKING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ The same tests are also used in other Kotlin backends (JVM, JS) for the same pur
6969

7070
To run blackbox compiler tests use:
7171

72-
./gradlew :native:native.tests:codegenBoxTest
72+
./gradlew :native:native.tests:codegen-box:test
7373

7474
* **--tests** allows one to choose test suite(s) or test case(s) to run.
7575

76-
./gradlew :native:native.tests:codegenBoxTest --tests "org.jetbrains.kotlin.konan.test.blackbox.NativeCodegenBoxTestGenerated\$Box\$*"
76+
./gradlew :native:native.tests:codegen-box:test --tests "org.jetbrains.kotlin.konan.test.blackbox.FirNativeCodegenBoxTestGenerated\$Box\$*"
7777

7878
* There are also Gradle project properties that can be used to control various aspects of blackbox tests. Example:
7979

80-
./gradlew :native:native.tests:codegenBoxTest \
80+
./gradlew :native:native.tests:codegen-box:test \
8181
-Pkotlin.internal.native.test.<property1Name>=<property1Value> \
8282
-Pkotlin.internal.native.test.<property2Name>=<property2Value>
8383

kotlin-native/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ Note: on MacOS aarch64, [JDK aarch64 is required](./README.md#building-from-sour
102102

103103
### Running tests
104104

105-
For tests, use `./gradlew :native:native.tests:codegenBoxTest` and `./gradlew :kotlin-native:backend.native:tests:run`.
105+
For tests, use `./gradlew :nativeCompilerTest :nativeCompilerUnitTest --continue`.
106106

107-
Note: on MacOS aarch64, for target-specific tests, [JDK aarch64 is required](./README.md#building-from-source)
107+
Note: on MacOS aarch64, [JDK aarch64 is required](./README.md#building-from-source)
108108

109109
For more details see [Testing](HACKING.md#Testing).
110110

native/native.tests/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
## Running tests
22

33
* To run all tests, use `./gradlew :native:native.tests:test`. Please note, this Gradle task is available only in development environment and it not available at CI server.
4-
* To execute certain tests only, use the appropriate Gradle tasks. Example: `./gradlew :native:native.tests:codegenBoxTest`
54
* To execute InteropIndexer tests for all targets, use:
65
```bash
76
for TARGET in android_x64 android_x86 android_arm32 android_arm64 \

native/native.tests/build.gradle.kts

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ testsJar {}
4545

4646
// Tasks that run different sorts of tests. Most frequent use case: running specific tests at TeamCity.
4747
val infrastructureTest = nativeTest("infrastructureTest", "infrastructure")
48-
val codegenBoxTest = nativeTest("codegenBoxTest", "codegen & frontend-classic")
49-
val codegenBoxK2Test = nativeTest("codegenBoxK2Test", "codegen & !frontend-classic")
5048
val stdlibTest = nativeTest("stdlibTest", "stdlib")
5149
val kotlinTestLibraryTest = nativeTest("kotlinTestLibraryTest", "kotlin-test")
5250
val partialLinkageTest = nativeTest("partialLinkageTest", "partial-linkage")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
plugins {
2+
kotlin("jvm")
3+
id("jps-compatible")
4+
}
5+
6+
dependencies {
7+
testImplementation(platform(libs.junit.bom))
8+
testImplementation(libs.junit.jupiter.api)
9+
testRuntimeOnly(libs.junit.jupiter.engine)
10+
11+
testImplementation(projectTests(":native:native.tests"))
12+
}
13+
14+
sourceSets {
15+
"main" { none() }
16+
"test" {
17+
projectDefault()
18+
generatedTestDir()
19+
}
20+
}
21+
22+
val testTags = findProperty("kotlin.native.tests.tags")?.toString()
23+
// Note: arbitrary JUnit tag expressions can be used in this property.
24+
// See https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions
25+
val test by nativeTest("test", testTags)

native/native.tests/tests/org/jetbrains/kotlin/generators/tests/GenerateNativeTests.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fun main() {
5050
}
5151

5252
// Codegen box tests.
53-
testGroup("native/native.tests/tests-gen", "compiler/testData/codegen") {
53+
testGroup("native/native.tests/codegen-box/tests-gen", "compiler/testData/codegen") {
5454
testClass<AbstractNativeCodegenBoxTest>(
5555
suiteTestClassName = "NativeCodegenBoxTestGenerated",
5656
annotations = listOf(

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ if (!buildProperties.inJpsBuildIdeaSync) {
734734
":kotlin-test",
735735
":kotlin-test:kotlin-test-js-it",
736736
":native:native.tests",
737+
':native:native.tests:codegen-box',
737738
":native:native.tests:driver",
738739
":native:native.tests:stress",
739740
":native:native.tests:klib-ir-inliner",

0 commit comments

Comments
 (0)