From 9ed23a7f073379af4f15733a58b785e7af8c78c5 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Mon, 11 Sep 2023 15:51:14 +0200 Subject: [PATCH] Scripting: fix supplementary test jar compilation make its version consistent with compilation of the script that uses it --- .../kotlin/script/experimental/jvmhost/test/CachingTest.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/CachingTest.kt b/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/CachingTest.kt index 56554e5dafe..24d6d025aec 100644 --- a/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/CachingTest.kt +++ b/libraries/scripting/jvm-host-test/test/kotlin/script/experimental/jvmhost/test/CachingTest.kt @@ -9,6 +9,7 @@ import junit.framework.TestCase import kotlinx.coroutines.runBlocking import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler +import org.jetbrains.kotlin.scripting.compiler.plugin.impl.SCRIPT_BASE_COMPILER_ARGUMENTS_PROPERTY import org.junit.Assert import org.junit.Ignore import org.junit.Test @@ -224,12 +225,15 @@ class CachingTest : TestCase() { } private fun makeDependenciesJar(depDir: File, standardJars: List): File { + val isK2 = System.getProperty(SCRIPT_BASE_COMPILER_ARGUMENTS_PROPERTY)?.contains("-language-version 1.9") != true val outJar = File(depDir, "dependency.jar") val inKt = File(depDir, "Dependency.kt").apply { writeText("class Dependency(val v: Int)") } val outStream = ByteArrayOutputStream() val compileExitCode = K2JVMCompiler().exec( PrintStream(outStream), - "-d", outJar.path, "-no-stdlib", "-cp", standardJars.joinToString(File.pathSeparator), inKt.path + "-d", outJar.path, "-no-stdlib", "-cp", standardJars.joinToString(File.pathSeparator), + "-language-version", if (isK2) "2.0" else "1.9", + inKt.path ) assertTrue( "Compilation Failed:\n$outStream",