Automatically add -- after script/expression in kotlin runner
#KT-37987 fixed
This commit is contained in:
@@ -141,6 +141,9 @@ class ScriptRunner(private val path: String) : RunnerWithCompiler() {
|
|||||||
addClasspathArgIfNeeded(classpath)
|
addClasspathArgIfNeeded(classpath)
|
||||||
add("-script")
|
add("-script")
|
||||||
add(path)
|
add(path)
|
||||||
|
if (arguments.isNotEmpty() && arguments.first() != "--") {
|
||||||
|
add("--")
|
||||||
|
}
|
||||||
addAll(arguments)
|
addAll(arguments)
|
||||||
}
|
}
|
||||||
runCompiler(compilerClasspath, compilerArgs)
|
runCompiler(compilerClasspath, compilerArgs)
|
||||||
@@ -153,6 +156,9 @@ class ExpressionRunner(private val code: String) : RunnerWithCompiler() {
|
|||||||
addClasspathArgIfNeeded(classpath)
|
addClasspathArgIfNeeded(classpath)
|
||||||
add("-expression")
|
add("-expression")
|
||||||
add(code)
|
add(code)
|
||||||
|
if (arguments.isNotEmpty() && arguments.first() != "--") {
|
||||||
|
add("--")
|
||||||
|
}
|
||||||
addAll(arguments)
|
addAll(arguments)
|
||||||
}
|
}
|
||||||
runCompiler(compilerClasspath, compilerArgs)
|
runCompiler(compilerClasspath, compilerArgs)
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
println(args.joinToString())
|
||||||
@@ -176,6 +176,41 @@ class LauncherScriptTest : TestCaseWithTmpdir() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testCommandlineProcessing() {
|
||||||
|
runProcess(
|
||||||
|
"kotlin",
|
||||||
|
"-e",
|
||||||
|
"println(args.joinToString())",
|
||||||
|
"-a",
|
||||||
|
"b",
|
||||||
|
expectedStdout = "-a, b\n"
|
||||||
|
)
|
||||||
|
runProcess(
|
||||||
|
"kotlin",
|
||||||
|
"-e",
|
||||||
|
"println(args.joinToString())",
|
||||||
|
"--",
|
||||||
|
"-a",
|
||||||
|
"b",
|
||||||
|
expectedStdout = "-a, b\n"
|
||||||
|
)
|
||||||
|
runProcess(
|
||||||
|
"kotlin",
|
||||||
|
"$testDataDirectory/printargs.kts",
|
||||||
|
"-a",
|
||||||
|
"b",
|
||||||
|
expectedStdout = "-a, b\n"
|
||||||
|
)
|
||||||
|
runProcess(
|
||||||
|
"kotlin",
|
||||||
|
"$testDataDirectory/printargs.kts",
|
||||||
|
"--",
|
||||||
|
"-a",
|
||||||
|
"b",
|
||||||
|
expectedStdout = "-a, b\n"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun testLegacyAssert() {
|
fun testLegacyAssert() {
|
||||||
runProcess(
|
runProcess(
|
||||||
"kotlinc",
|
"kotlinc",
|
||||||
|
|||||||
Reference in New Issue
Block a user