5
5
6
6
package kotlin.script.experimental.jsr223.test
7
7
8
+ import com.intellij.openapi.util.io.toCanonicalPath
8
9
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
9
10
import org.jetbrains.kotlin.cli.common.arguments.cliArgument
10
11
import org.jetbrains.kotlin.cli.common.environment.setIdeaIoUseFallback
@@ -25,6 +26,7 @@ import java.lang.management.ManagementFactory
25
26
import java.nio.file.Files.createTempDirectory
26
27
import java.nio.file.Files.createTempFile
27
28
import javax.script.*
29
+ import kotlin.io.path.writeLines
28
30
import kotlin.script.experimental.jvmhost.jsr223.KotlinJsr223ScriptEngineImpl
29
31
import kotlin.script.templates.standard.ScriptTemplateWithBindings
30
32
451
453
val runtime = File (jdk17, " bin" + File .separator + javaExe)
452
454
453
455
val tempDir = createTempDirectory(KotlinJsr223ScriptEngineIT ::class .simpleName!! )
456
+
457
+ fun prepareArgFile (vararg args : String ): String {
458
+ val file = tempDir.resolve(" arguments.args" )
459
+ file.writeLines(args.map { it.replace(" \\ " , " \\\\ " ) })
460
+ return " @${file.toCanonicalPath()} "
461
+ }
462
+
454
463
try {
455
464
val outJar = createTempFile(tempDir, " inlining17" , " .jar" ).toFile()
456
465
val compileCp = File (System .getProperty(" testCompilationClasspath" )!! ).readText().split(File .pathSeparator).map(::File )
@@ -462,12 +471,14 @@ obj
462
471
runAndCheckResults(
463
472
listOf (
464
473
runtime.absolutePath,
465
- " -cp" , paths.compilerClasspath.joinToString(File .pathSeparator),
466
- K2JVMCompiler ::class .java.name,
467
- K2JVMCompilerArguments ::noStdlib.cliArgument,
468
- K2JVMCompilerArguments ::classpath.cliArgument, compileCp.joinToString(File .pathSeparator) { it.path },
469
- K2JVMCompilerArguments ::destination.cliArgument, outJar.absolutePath,
470
- K2JVMCompilerArguments ::jvmTarget.cliArgument, " 17" ,
474
+ prepareArgFile(
475
+ " -cp" , paths.compilerClasspath.joinToString(File .pathSeparator),
476
+ K2JVMCompiler ::class .java.name,
477
+ K2JVMCompilerArguments ::noStdlib.cliArgument,
478
+ K2JVMCompilerArguments ::classpath.cliArgument, compileCp.joinToString(File .pathSeparator) { it.path },
479
+ K2JVMCompilerArguments ::destination.cliArgument, outJar.absolutePath,
480
+ K2JVMCompilerArguments ::jvmTarget.cliArgument, " 17" ,
481
+ ),
471
482
" libraries/scripting/jsr223-test/testData/testJsr223Inlining.kt"
472
483
),
473
484
additionalEnvVars = listOf (" JAVA_HOME" to jdk17.absolutePath)
480
491
)
481
492
482
493
runAndCheckResults(
483
- listOf (runtime.absolutePath, " -cp" , runtimeCp.joinToString(File .pathSeparator) { it.path }, " TestJsr223InliningKt" ),
494
+ listOf (
495
+ runtime.absolutePath,
496
+ " -cp" ,
497
+ prepareArgFile(runtimeCp.joinToString(File .pathSeparator) { it.path }),
498
+ " TestJsr223InliningKt"
499
+ ),
484
500
listOf (" OK" )
485
501
)
486
502
} finally {
0 commit comments