From 298fdafefe0c2e6f218caca86294649b13902ccf Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Wed, 2 Oct 2024 11:14:56 +0300 Subject: [PATCH] Forward the kotlin.native.version parameter to test projects --- buildSrc/src/main/kotlin/KotlinCommunity.kt | 13 +++++++++++++ integration/build.gradle.kts | 3 +++ .../kotlin/kotlinx/benchmark/integration/Runner.kt | 7 ++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/KotlinCommunity.kt b/buildSrc/src/main/kotlin/KotlinCommunity.kt index d1ec0853..72d419cc 100644 --- a/buildSrc/src/main/kotlin/KotlinCommunity.kt +++ b/buildSrc/src/main/kotlin/KotlinCommunity.kt @@ -63,3 +63,16 @@ fun getOverriddenKotlinLanguageVersion(project: Project): String? { } return languageVersion } + +/** + * Should be used for running against non-released Kotlin compiler on a system test level. + * + * @return a Kotlin API version parametrized from command line or gradle.properties, null otherwise + */ +fun getOverriddenKotlinNativeVersion(project: Project): String? { + val nativeVersion = project.providers.gradleProperty("kotlin.native.version").orNull + if (!nativeVersion.isNullOrBlank()) { + project.logger.info("""Configured Kotlin Native distribution version: '$nativeVersion' for project ${project.name}""") + } + return nativeVersion +} \ No newline at end of file diff --git a/integration/build.gradle.kts b/integration/build.gradle.kts index 8371fcce..44c9acfd 100644 --- a/integration/build.gradle.kts +++ b/integration/build.gradle.kts @@ -33,6 +33,9 @@ tasks.test { getOverriddenKotlinApiVersion(project)?.let { systemProperty("kotlin_api_version", it) } + getOverriddenKotlinNativeVersion(project)?.let { + systemProperty("kotlin.native.version", it) + } systemProperty("minSupportedGradleVersion", libs.versions.minSupportedGradle.get()) systemProperty("minSupportedKotlinVersion", libs.versions.minSupportedKotlin.get()) } diff --git a/integration/src/main/kotlin/kotlinx/benchmark/integration/Runner.kt b/integration/src/main/kotlin/kotlinx/benchmark/integration/Runner.kt index 00b3c08b..f7d7f3ff 100644 --- a/integration/src/main/kotlin/kotlinx/benchmark/integration/Runner.kt +++ b/integration/src/main/kotlin/kotlinx/benchmark/integration/Runner.kt @@ -16,7 +16,7 @@ class Runner( private fun gradle(vararg tasks: String): GradleRunner = GradleRunner.create() .withProjectDir(projectDir) - .withArguments(*(defaultArguments() + tasks)) + .withArguments(*(defaultArguments() + kotlinNativeVersion + tasks)) .withGradleVersion(gradleVersion.versionString) .forwardStdError(System.err.bufferedWriter()) .run { @@ -44,6 +44,11 @@ class Runner( private fun defaultArguments(): Array = arrayOf("--stacktrace") + // Forward the Kotlin Native distribution version to test projects + private val kotlinNativeVersion = "kotlin.native.version".let { property -> + System.getProperty(property)?.let { arrayOf("-P$property=$it") } ?: emptyArray() + } + fun updateAnnotations(filePath: String, annotationsSpecifier: AnnotationsSpecifier.() -> Unit) { val annotations = AnnotationsSpecifier().also(annotationsSpecifier) val file = projectDir.resolve(filePath)