Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sorting out of starlark flags to also identify external repo starlark flags #11510

Closed
wants to merge 7 commits into from

Conversation

juliexxia
Copy link
Contributor

@juliexxia juliexxia commented May 27, 2020

Fixes #11506

@juliexxia juliexxia changed the title Juliexxia/starlark opt regexp Update sorting out of starlark flags to also identify external repo starlark flags May 27, 2020
juliexxia referenced this pull request May 27, 2020
Fixes #11301

PiperOrigin-RevId: 312470710
@juliexxia juliexxia requested a review from katre May 27, 2020 21:39
@@ -314,4 +319,16 @@ public void testOptionsAreParsedWithBuildTestsOnly() throws Exception {

assertThat(result.getStarlarkOptions().get("//test:my_int_setting")).isEqualTo(15);
}

@Test
public void testRemoveStarlarkOptionsWorks() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a test for the --@//external/starlark/option main repo case please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! added

@@ -228,7 +228,7 @@ private Target loadBuildSetting(
ImmutableList.Builder<String> keep = ImmutableList.builder();
ImmutableList.Builder<String> remove = ImmutableList.builder();
for (String name : list) {
((name.startsWith("--//") || name.startsWith("--no//")) ? remove : keep).add(name);
(name.matches("--(no)?(@.*)?//.*") ? remove : keep).add(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regex-based parsing is going to fall into difficulties. Can this just strip off the -- and the no (if present), and call LabelValidator.validateAbsoluteLabel, and check for exceptions being thrown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much better. Done.

@@ -228,7 +230,21 @@ private Target loadBuildSetting(
ImmutableList.Builder<String> keep = ImmutableList.builder();
ImmutableList.Builder<String> remove = ImmutableList.builder();
for (String name : list) {
((name.startsWith("--//") || name.startsWith("--no//")) ? remove : keep).add(name);
if (!name.startsWith("--")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is great, but needs comments. More comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! added a description to the javadoc as well

@bazel-io bazel-io closed this in 69d4ace May 29, 2020
@philwo philwo deleted the juliexxia/starlark-opt-regexp branch June 30, 2020 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clean command errors if Starlark-defined flags are provided
4 participants