Automatically add -- after script/expression in kotlin runner

#KT-37987 fixed
This commit is contained in:
Ilya Chernikov
2020-10-01 22:31:02 +02:00
parent 153217ae2e
commit d7e0649d93
3 changed files with 42 additions and 0 deletions
@@ -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
View File
@@ -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",