use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method asListOfUnparsedOptions.
@Test
public void asListOfUnparsedOptions() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(IntrospectionExample.class);
parser.parse(OptionPriority.COMMAND_LINE, "source", Arrays.asList("--alpha=one", "--gamma=two", "--echo=three"));
List<UnparsedOptionValueDescription> result = parser.asListOfUnparsedOptions();
assertNotNull(result);
assertEquals(3, result.size());
assertEquals("alpha", result.get(0).getName());
assertEquals(true, result.get(0).isDocumented());
assertEquals(false, result.get(0).isHidden());
assertEquals("one", result.get(0).getUnparsedValue());
assertEquals("source", result.get(0).getSource());
assertEquals(OptionPriority.COMMAND_LINE, result.get(0).getPriority());
assertEquals("gamma", result.get(1).getName());
assertEquals(false, result.get(1).isDocumented());
assertEquals(false, result.get(1).isHidden());
assertEquals("two", result.get(1).getUnparsedValue());
assertEquals("source", result.get(1).getSource());
assertEquals(OptionPriority.COMMAND_LINE, result.get(1).getPriority());
assertEquals("echo", result.get(2).getName());
assertEquals(false, result.get(2).isDocumented());
assertEquals(true, result.get(2).isHidden());
assertEquals("three", result.get(2).getUnparsedValue());
assertEquals("source", result.get(2).getSource());
assertEquals(OptionPriority.COMMAND_LINE, result.get(2).getPriority());
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method overrideExplicitWithExpansion.
@Test
public void overrideExplicitWithExpansion() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(ExpansionOptions.class);
parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--second=second", "--first"));
ExpansionOptions options = parser.getOptions(ExpansionOptions.class);
assertEquals("first", options.second);
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method warningForExpansionOverridingExplicitOption.
@Test
public void warningForExpansionOverridingExplicitOption() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(ExpansionWarningOptions.class);
parser.parse("--second=second", "--first");
assertThat(parser.getWarnings()).containsExactly("The option 'first' was expanded and now overrides a " + "previous explicitly specified option 'second'");
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method overrideWithLowerPriority.
@Test
public void overrideWithLowerPriority() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(NullTestOptions.class);
parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--simple=a"));
assertEquals("a", parser.getOptions(NullTestOptions.class).simple);
parser.parse(OptionPriority.RC_FILE, null, Arrays.asList("--simple=b"));
assertEquals("a", parser.getOptions(NullTestOptions.class).simple);
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method asListOfExplicitOptions.
@Test
public void asListOfExplicitOptions() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(IntrospectionExample.class);
parser.parse(OptionPriority.COMMAND_LINE, "source", Arrays.asList("--alpha=one", "--gamma=two"));
List<UnparsedOptionValueDescription> result = parser.asListOfExplicitOptions();
assertNotNull(result);
assertEquals(2, result.size());
assertEquals("alpha", result.get(0).getName());
assertEquals(true, result.get(0).isDocumented());
assertEquals("one", result.get(0).getUnparsedValue());
assertEquals("source", result.get(0).getSource());
assertEquals(OptionPriority.COMMAND_LINE, result.get(0).getPriority());
assertEquals("gamma", result.get(1).getName());
assertEquals(false, result.get(1).isDocumented());
assertEquals("two", result.get(1).getUnparsedValue());
assertEquals("source", result.get(1).getSource());
assertEquals(OptionPriority.COMMAND_LINE, result.get(1).getPriority());
}
Aggregations