Search in sources :

Example 26 with OptionsParser.newOptionsParser

use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.

the class OptionsParserTest method newDeprecationWarningForExpansionOption.

@Test
public void newDeprecationWarningForExpansionOption() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(NewWarningOptions.class);
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--third"));
    assertEquals(Arrays.asList("Option 'third' is deprecated: use --forth instead"), parser.getWarnings());
    assertTrue(parser.getOptions(NewWarningOptions.class).fourth);
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 27 with OptionsParser.newOptionsParser

use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.

the class OptionsParserTest method canonicalize.

public static List<String> canonicalize(Class<? extends OptionsBase> optionsClass, String... args) throws OptionsParsingException {
    OptionsParser parser = OptionsParser.newOptionsParser(ImmutableList.<Class<? extends OptionsBase>>of(optionsClass));
    parser.setAllowResidue(false);
    parser.parse(Arrays.asList(args));
    return parser.canonicalize();
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser)

Example 28 with OptionsParser.newOptionsParser

use of com.google.devtools.common.options.OptionsParser.newOptionsParser in project bazel by bazelbuild.

the class OptionsParserTest method warningForExplicitOverridingImplicitOption.

@Test
public void warningForExplicitOverridingImplicitOption() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(ImplicitDependencyWarningOptions.class);
    parser.parse("--first=first");
    assertThat(parser.getWarnings()).isEmpty();
    parser.parse("--second=second");
    assertThat(parser.getWarnings()).containsExactly("A new value for option 'second' overrides a" + " previous implicit setting of that option by option 'first'");
}
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