diff --git a/src/main/java/com/google/devtools/build/lib/runtime/StarlarkOptionsParser.java b/src/main/java/com/google/devtools/build/lib/runtime/StarlarkOptionsParser.java index 814727016f3ef3..13af8bd59e29ff 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/StarlarkOptionsParser.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/StarlarkOptionsParser.java @@ -322,6 +322,11 @@ public static Pair, ImmutableList> removeStarlarkO if (name.startsWith("no")) { potentialStarlarkFlag = potentialStarlarkFlag.substring(2); } + // Check if the string contains a value, trim off the value if so. + int equalsIdx = potentialStarlarkFlag.indexOf('='); + if (equalsIdx > 0) { + potentialStarlarkFlag = potentialStarlarkFlag.substring(0, equalsIdx); + } // Check if we can properly parse the (potentially trimmed) string as a label. If so, count // as starlark flag, else count as regular residue. try { diff --git a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkOptionsParsingTest.java b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkOptionsParsingTest.java index fa9636ca1ddc76..3bd9fb6ac01f83 100644 --- a/src/test/java/com/google/devtools/build/lib/starlark/StarlarkOptionsParsingTest.java +++ b/src/test/java/com/google/devtools/build/lib/starlark/StarlarkOptionsParsingTest.java @@ -352,17 +352,27 @@ public void testRemoveStarlarkOptionsWorks() throws Exception { StarlarkOptionsParser.removeStarlarkOptions( ImmutableList.of( "--//local/starlark/option", + "--//local/starlark/option=with_value", "--@some_repo//external/starlark/option", + "--@some_repo//external/starlark/option=with_value", "--@//main/repo/option", + "--@//main/repo/option=with_value", "some-random-residue", - "--mangled//external/starlark/option")); + "--mangled//external/starlark/option", + "--mangled//external/starlark/option=with_value")); assertThat(residueAndStarlarkOptions.getFirst()) .containsExactly( "--//local/starlark/option", + "--//local/starlark/option=with_value", "--@some_repo//external/starlark/option", - "--@//main/repo/option"); + "--@some_repo//external/starlark/option=with_value", + "--@//main/repo/option", + "--@//main/repo/option=with_value"); assertThat(residueAndStarlarkOptions.getSecond()) - .containsExactly("some-random-residue", "--mangled//external/starlark/option"); + .containsExactly( + "some-random-residue", + "--mangled//external/starlark/option", + "--mangled//external/starlark/option=with_value"); } /**