Scripting: fix supplementary test jar compilation
make its version consistent with compilation of the script that uses it
This commit is contained in:
committed by
Space Team
parent
30899e4bbf
commit
9ed23a7f07
+5
-1
@@ -9,6 +9,7 @@ import junit.framework.TestCase
|
|||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||||
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
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.Assert
|
||||||
import org.junit.Ignore
|
import org.junit.Ignore
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@@ -224,12 +225,15 @@ class CachingTest : TestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun makeDependenciesJar(depDir: File, standardJars: List<File>): File {
|
private fun makeDependenciesJar(depDir: File, standardJars: List<File>): File {
|
||||||
|
val isK2 = System.getProperty(SCRIPT_BASE_COMPILER_ARGUMENTS_PROPERTY)?.contains("-language-version 1.9") != true
|
||||||
val outJar = File(depDir, "dependency.jar")
|
val outJar = File(depDir, "dependency.jar")
|
||||||
val inKt = File(depDir, "Dependency.kt").apply { writeText("class Dependency(val v: Int)") }
|
val inKt = File(depDir, "Dependency.kt").apply { writeText("class Dependency(val v: Int)") }
|
||||||
val outStream = ByteArrayOutputStream()
|
val outStream = ByteArrayOutputStream()
|
||||||
val compileExitCode = K2JVMCompiler().exec(
|
val compileExitCode = K2JVMCompiler().exec(
|
||||||
PrintStream(outStream),
|
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(
|
assertTrue(
|
||||||
"Compilation Failed:\n$outStream",
|
"Compilation Failed:\n$outStream",
|
||||||
|
|||||||
Reference in New Issue
Block a user