Skip to content

Commit 56fdb63

Browse files
demiurg906Space Team
authored andcommitted
[Test] Pass classpath arguments to Jsr223 tests with file
Previously they were passed as plain `-D...` CLI arguments for gradle task invocation, which caused problems on Windows, which has limits on the length of the CLI command.
1 parent 7e1fd66 commit 56fdb63

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

libraries/scripting/jsr223-test/build.gradle.kts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ projectTests {
5656
workingDir = rootDir
5757
val testRuntimeProvider = project.provider { testJsr223Runtime.asPath }
5858
val testCompilationClasspathProvider = project.provider { testCompilationClasspath.asPath }
59-
doFirst {
60-
systemProperty("testJsr223RuntimeClasspath", testRuntimeProvider.get())
61-
systemProperty("testCompilationClasspath", testCompilationClasspathProvider.get())
62-
systemProperty("kotlin.script.base.compiler.arguments", "-language-version 1.9")
63-
}
59+
configureProperties(testRuntimeProvider, testCompilationClasspathProvider)
6460
}
6561

6662
testTask("embeddableTest", jUnitMode = JUnitMode.JUnit5, parallel = true, skipInLocalBuild = false) {
@@ -69,10 +65,18 @@ projectTests {
6965
classpath = embeddableTestRuntime
7066
val testRuntimeProvider = project.provider { embeddableTestRuntime.asPath }
7167
val testCompilationClasspathProvider = project.provider { testCompilationClasspath.asPath }
72-
doFirst {
73-
systemProperty("testJsr223RuntimeClasspath", testRuntimeProvider.get())
74-
systemProperty("testCompilationClasspath", testCompilationClasspathProvider.get())
75-
systemProperty("kotlin.script.base.compiler.arguments", "-language-version 1.9")
76-
}
68+
configureProperties(testRuntimeProvider, testCompilationClasspathProvider)
69+
}
70+
}
71+
72+
fun Test.configureProperties(testRuntimeProvider: Provider<String>, testCompilationClasspathProvider: Provider<String>) {
73+
doFirst {
74+
val jsr223RuntimeClasspathFile = temporaryDir.resolve("testJsr223RuntimeClasspath.txt")
75+
.apply { writeText(testRuntimeProvider.get()) }
76+
systemProperty("testJsr223RuntimeClasspath", jsr223RuntimeClasspathFile)
77+
val compilationClasspathFile = temporaryDir.resolve("testCompilationClasspath.txt")
78+
.apply { writeText(testCompilationClasspathProvider.get()) }
79+
systemProperty("testCompilationClasspath", compilationClasspathFile)
80+
systemProperty("kotlin.script.base.compiler.arguments", "-language-version 1.9")
7781
}
7882
}

libraries/scripting/jsr223-test/test/kotlin/script/experimental/jsr223/test/KotlinJsr223ScriptEngineIT.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ obj
453453
val tempDir = createTempDirectory(KotlinJsr223ScriptEngineIT::class.simpleName!!)
454454
try {
455455
val outJar = createTempFile(tempDir, "inlining17", ".jar").toFile()
456-
val compileCp = System.getProperty("testCompilationClasspath")!!.split(File.pathSeparator).map(::File)
456+
val compileCp = File(System.getProperty("testCompilationClasspath")!!).readText().split(File.pathSeparator).map(::File)
457457
assertTrue(
458458
compileCp.any { it.name.startsWith("kotlin-stdlib") },
459459
"Expecting \"testCompilationClasspath\" property to contain stdlib jar:\n$compileCp"
@@ -473,7 +473,7 @@ obj
473473
additionalEnvVars = listOf("JAVA_HOME" to jdk17.absolutePath)
474474
)
475475

476-
val runtimeCp = System.getProperty("testJsr223RuntimeClasspath")!!.split(File.pathSeparator).map(::File) + outJar
476+
val runtimeCp = File(System.getProperty("testJsr223RuntimeClasspath")!!).readText().split(File.pathSeparator).map(::File) + outJar
477477
assertTrue(
478478
runtimeCp.any { it.name.startsWith("kotlin-scripting-jsr223") },
479479
"Expecting \"testJsr223RuntimeClasspath\" property to contain JSR223 jar:\n$runtimeCp"

0 commit comments

Comments
 (0)