Search in sources :

Example 16 with OptionsParser.newOptionsParser

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);
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 17 with OptionsParser.newOptionsParser

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);
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 18 with OptionsParser.newOptionsParser

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");
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 19 with OptionsParser.newOptionsParser

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);
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 20 with OptionsParser.newOptionsParser

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);
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Aggregations

OptionsParser.newOptionsParser (com.google.devtools.common.options.OptionsParser.newOptionsParser)28 Test (org.junit.Test)27 UnparsedOptionValueDescription (com.google.devtools.common.options.OptionsParser.UnparsedOptionValueDescription)4 OptionValueDescription (com.google.devtools.common.options.OptionsParser.OptionValueDescription)2 HashMap (java.util.HashMap)1