CLI: support -option=value syntax for non-advanced flags #KT-47640 Fixed

This commit is contained in:
Mikhail Glukhikh
2021-07-07 15:54:08 +03:00
committed by teamcityserver
parent d8417fd622
commit 5871f3d663
8 changed files with 16 additions and 23 deletions
@@ -107,7 +107,7 @@ private fun <A : CommonToolArguments> parsePreprocessedCommandLineArguments(args
return arg.startsWith(argument.value + "=")
}
return argument.value == arg
return argument.value == arg || arg.startsWith(argument.value + "=")
}
val freeArgs = ArrayList<String>()
@@ -160,10 +160,10 @@ private fun <A : CommonToolArguments> parsePreprocessedCommandLineArguments(args
val (property, argument) = argumentField
val value: Any = when {
argumentField.property.returnType.classifier == Boolean::class -> true
argument.isAdvanced && arg.startsWith(argument.value + "=") -> {
arg.startsWith(argument.value + "=") -> {
arg.substring(argument.value.length + 1)
}
argument.isAdvanced && arg.startsWith(argument.deprecatedName + "=") -> {
arg.startsWith(argument.deprecatedName + "=") -> {
arg.substring(argument.deprecatedName.length + 1)
}
i == args.size -> {
+3 -6
View File
@@ -1,11 +1,8 @@
$TESTDATA_DIR$/experimentalDeprecated.kt
-d
$TEMP_DIR$
-opt-in
kotlin.RequiresOptIn
-opt-in=kotlin.RequiresOptIn
-Xexperimental=org.test.Error1
-Xexperimental=org.test.Hidden1
-opt-in
org.test.Error2
-opt-in
org.test.Hidden2
-opt-in=org.test.Error2
-opt-in=org.test.Hidden2
@@ -2,9 +2,7 @@ $TESTDATA_DIR$/experimentalDeprecatedWarning.kt
-d
$TEMP_DIR$
-Xopt-in=kotlin.RequiresOptIn
-opt-in
kotlin.RequiresOptIn
-opt-in
org.test.Warning1
-opt-in=kotlin.RequiresOptIn
-opt-in=org.test.Warning1
-Xexperimental=org.test.Warning2
-Xuse-experimental=org.test.OneMore
+1 -2
View File
@@ -2,5 +2,4 @@ $TESTDATA_DIR$/experimentalIsNotAnnotation.kt
-d
$TEMP_DIR$
-Xexperimental=org.test.NotAnAnnotation1
-opt-in
org.test.NotAnAnnotation2
-opt-in=org.test.NotAnAnnotation2
+1 -2
View File
@@ -2,5 +2,4 @@ $TESTDATA_DIR$/experimentalIsNotMarker.kt
-d
$TEMP_DIR$
-Xexperimental=org.test.NotAMarker1
-opt-in
org.test.NotAMarker2
-opt-in=org.test.NotAMarker2
+1 -2
View File
@@ -1,6 +1,5 @@
$TESTDATA_DIR$/experimentalNested.kt
-d
$TEMP_DIR$
-opt-in
kotlin.RequiresOptIn
-opt-in=kotlin.RequiresOptIn
-Xexperimental=org.test.Outer.Nested
@@ -1,3 +1,4 @@
warning: '-Xopt-in' is deprecated and will be removed in a future release, please use -opt-in instead
compiler/testData/cli/jvm/unrestrictedBuilderInference.kt:3:9: warning: variable 'x' is never used
val x = buildMap {
^
@@ -326,24 +326,24 @@ class ScriptingHostTest : TestCase() {
val script = "println(\"Hi\")"
val compilationConfiguration1 = createJvmCompilationConfigurationFromTemplate<SimpleScriptTemplate> {
compilerOptions("-jvm-target=1.8")
compilerOptions("-jvm-target->1.8")
}
val res1 = BasicJvmScriptingHost().eval(script.toScriptSource(), compilationConfiguration1, null)
assertTrue(res1 is ResultWithDiagnostics.Failure)
assertNotNull(res1.reports.find { it.message == "Invalid argument: -jvm-target=1.8" })
assertNotNull(res1.reports.find { it.message == "Invalid argument: -jvm-target->1.8" })
val compilationConfiguration2 = createJvmCompilationConfigurationFromTemplate<SimpleScriptTemplate> {
refineConfiguration {
beforeCompiling { ctx ->
ScriptCompilationConfiguration(ctx.compilationConfiguration) {
compilerOptions.append("-jvm-target=1.6")
compilerOptions.append("-jvm-target->1.6")
}.asSuccess()
}
}
}
val res2 = BasicJvmScriptingHost().eval(script.toScriptSource(), compilationConfiguration2, null)
assertTrue(res2 is ResultWithDiagnostics.Failure)
assertNotNull(res2.reports.find { it.message == "Invalid argument: -jvm-target=1.6" })
assertNotNull(res2.reports.find { it.message == "Invalid argument: -jvm-target->1.6" })
}
@Test