Skip to content

Commit 0013192

Browse files
authored
Setup running native tests in release mode (#2667)
Proposed here: #2608 To run native tests in release mode, separate tasks are created by KGP for additional test runs, f.e macosArm64ReleaseTest or linuxX64ReleaseTest. By default, they will be run also on build, check and allTests tasks, so they should automatically run on TC. Note: with Kotlin 1.9.22 the original issue (#2608) doesn't reproduce nor via running protobuf tests (which contains tests for inner classes, so I haven't added additional test from original issue), nor via running tests in integration-test module (by adding reproducer test there, not included)
1 parent 08e604a commit 0013192

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

buildSrc/src/main/kotlin/native-targets-conventions.gradle.kts

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.jetbrains.kotlin.gradle.*
2+
import org.jetbrains.kotlin.gradle.plugin.mpp.*
23

34
/*
45
* Copyright 2017-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
@@ -47,6 +48,15 @@ kotlin {
4748
linuxArm32Hfp()
4849
}
4950

51+
// setup tests running in RELEASE mode
52+
targets.withType<KotlinNativeTarget>().configureEach {
53+
binaries.test(listOf(NativeBuildType.RELEASE))
54+
}
55+
targets.withType<KotlinNativeTargetWithTests<*>>().configureEach {
56+
testRuns.create("releaseTest") {
57+
setExecutionSourceFrom(binaries.getTest(NativeBuildType.RELEASE))
58+
}
59+
}
5060
}
5161

5262
fun doesNotDependOnOkio(project: Project): Boolean {

integration-test/build.gradle.kts

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
55
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask
6+
import org.jetbrains.kotlin.gradle.plugin.mpp.*
67

78
val serialization_version = property("mainLibVersion") as String
89

@@ -132,6 +133,16 @@ kotlin {
132133
freeCompilerArgs += "-Xsuppress-version-warnings"
133134
}
134135
}
136+
137+
// setup tests running in RELEASE mode
138+
targets.withType<KotlinNativeTarget>().configureEach {
139+
binaries.test(listOf(NativeBuildType.RELEASE))
140+
}
141+
targets.withType<KotlinNativeTargetWithTests<*>>().configureEach {
142+
testRuns.create("releaseTest") {
143+
setExecutionSourceFrom(binaries.getTest(NativeBuildType.RELEASE))
144+
}
145+
}
135146
}
136147

137148
dependencies {

0 commit comments

Comments
 (0)