use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method implicitDependencyHasImplicitDependency.
@Test
public void implicitDependencyHasImplicitDependency() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(ImplicitDependencyOptions.class);
parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--first=first"));
assertEquals("first", parser.getOptions(ImplicitDependencyOptions.class).first);
assertEquals("second", parser.getOptions(ImplicitDependencyOptions.class).second);
assertEquals("third", parser.getOptions(ImplicitDependencyOptions.class).third);
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method overrideExpansionWithExplicit.
@Test
public void overrideExpansionWithExplicit() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(ExpansionOptions.class);
parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--first", "--second=second"));
ExpansionOptions options = parser.getOptions(ExpansionOptions.class);
assertEquals("second", options.second);
assertEquals(0, parser.getWarnings().size());
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method asListOfEffectiveOptions.
@Test
public void asListOfEffectiveOptions() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(IntrospectionExample.class);
parser.parse(OptionPriority.COMMAND_LINE, "source", Arrays.asList("--alpha=one", "--gamma=two"));
List<OptionValueDescription> result = parser.asListOfEffectiveOptions();
assertNotNull(result);
assertEquals(5, result.size());
HashMap<String, OptionValueDescription> map = new HashMap<String, OptionValueDescription>();
for (OptionValueDescription description : result) {
map.put(description.getName(), description);
}
assertOptionValue("alpha", "one", OptionPriority.COMMAND_LINE, "source", map.get("alpha"));
assertOptionValue("beta", "beta", OptionPriority.DEFAULT, null, map.get("beta"));
assertOptionValue("gamma", "two", OptionPriority.COMMAND_LINE, "source", map.get("gamma"));
assertOptionValue("delta", "delta", OptionPriority.DEFAULT, null, map.get("delta"));
assertOptionValue("echo", "echo", OptionPriority.DEFAULT, null, map.get("echo"));
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method deprecationWarningForListOption.
@Test
public void deprecationWarningForListOption() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(WarningOptions.class);
parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--second=a"));
assertEquals(Arrays.asList("Option 'second' is deprecated"), parser.getWarnings());
}
use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.
the class OptionsParserTest method getOptionValueDescriptionWithValue.
@Test
public void getOptionValueDescriptionWithValue() throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(NullTestOptions.class);
parser.parse(OptionPriority.COMMAND_LINE, "my description", Arrays.asList("--simple=abc"));
OptionValueDescription result = parser.getOptionValueDescription("simple");
assertNotNull(result);
assertEquals("simple", result.getName());
assertEquals("abc", result.getValue());
assertEquals(OptionPriority.COMMAND_LINE, result.getPriority());
assertEquals("my description", result.getSource());
assertNull(result.getImplicitDependant());
assertFalse(result.isImplicitDependency());
assertNull(result.getExpansionParent());
assertFalse(result.isExpansion());
}
Aggregations