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)
|
||||
add("-script")
|
||||
add(path)
|
||||
if (arguments.isNotEmpty() && arguments.first() != "--") {
|
||||
add("--")
|
||||
}
|
||||
addAll(arguments)
|
||||
}
|
||||
runCompiler(compilerClasspath, compilerArgs)
|
||||
@@ -153,6 +156,9 @@ class ExpressionRunner(private val code: String) : RunnerWithCompiler() {
|
||||
addClasspathArgIfNeeded(classpath)
|
||||
add("-expression")
|
||||
add(code)
|
||||
if (arguments.isNotEmpty() && arguments.first() != "--") {
|
||||
add("--")
|
||||
}
|
||||
addAll(arguments)
|
||||
}
|
||||
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() {
|
||||
runProcess(
|
||||
"kotlinc",
|
||||
|
||||
Reference in New Issue
Block a user