use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method commaSeparatedOptionsWithAllowMultiple.
@Test
public void commaSeparatedOptionsWithAllowMultiple() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(CommaSeparatedOptionsExample.class);
parser.parse(OptionPriority.COMMAND_LINE, "a", Arrays.asList("--alpha=one", "--alpha=two,three"));
assertEquals(Arrays.asList("one", "two", "three"), parser.getOptions(CommaSeparatedOptionsExample.class).alpha);
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method overrideWithHigherPriority.
@Test
public void overrideWithHigherPriority() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(NullTestOptions.class);
parser.parse(OptionPriority.RC_FILE, null, Arrays.asList("--simple=a"));
assertEquals("a", parser.getOptions(NullTestOptions.class).simple);
parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--simple=b"));
assertEquals("b", parser.getOptions(NullTestOptions.class).simple);
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method warningForImplicitOverridingExplicitOption.
@Test
public void warningForImplicitOverridingExplicitOption() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(ImplicitDependencyWarningOptions.class);
parser.parse("--second=second", "--first=first");
assertThat(parser.getWarnings()).containsExactly("Option 'second' is implicitly defined by " + "option 'first'; the implicitly set value overrides the previous one");
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method overrideListOptions.
@Test
public void overrideListOptions() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(ListExample.class);
parser.parse(OptionPriority.COMMAND_LINE, "a", Arrays.asList("--alpha=two"));
parser.parse(OptionPriority.RC_FILE, "b", Arrays.asList("--alpha=one"));
assertEquals(Arrays.asList("one", "two"), parser.getOptions(ListExample.class).alpha);
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method deprecationWarningForExpansionOption.
@Test
public void deprecationWarningForExpansionOption() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(WarningOptions.class);
parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--third"));
assertEquals(Arrays.asList("Option 'third' is deprecated"), parser.getWarnings());
assertTrue(parser.getOptions(WarningOptions.class).fourth);
}
Aggregations