-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Closed
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d382ed5
update starlark options parser finding to use a regexp
juliexxia f0005d6
fix
juliexxia f77926f
fix
juliexxia 8adefd7
add BUILD'
juliexxia 66f9c48
use proper methods in test
juliexxia 4610fd7
use label validator
juliexxia 88d8cb4
add comments
juliexxia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,19 @@ | |
import static com.google.common.truth.Truth.assertThat; | ||
import static org.junit.Assert.assertThrows; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.devtools.build.lib.skylark.util.StarlarkOptionsTestCase; | ||
import com.google.devtools.build.lib.runtime.StarlarkOptionsParser; | ||
import com.google.devtools.build.lib.util.Pair; | ||
import com.google.devtools.common.options.OptionsParsingException; | ||
import com.google.devtools.common.options.OptionsParsingResult; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
/** Unit test for the {@code StarlarkOptionsParser}. */ | ||
/** | ||
* Unit test for the {@code StarlarkOptionsParser}. | ||
*/ | ||
@RunWith(JUnit4.class) | ||
public class StarlarkOptionsParsingTest extends StarlarkOptionsTestCase { | ||
|
||
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add a test for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep! added |
||
Pair<ImmutableList<String>, ImmutableList<String>> residueAndStarlarkOptions = StarlarkOptionsParser | ||
.removeStarlarkOptions(ImmutableList | ||
.of("--//local/starlark/option", "--@some_repo//external/starlark/option", | ||
"some-random-residue", "--mangled//external/starlark/option")); | ||
assertThat(residueAndStarlarkOptions.getFirst()) | ||
.containsExactly("--//local/starlark/option", "--@some_repo//external/starlark/option"); | ||
assertThat(residueAndStarlarkOptions.getSecond()) | ||
.containsExactly("some-random-residue", "--mangled//external/starlark/option"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much better. Done.