Search in sources :

Example 11 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method warningForExplicitOverridingImplicitOptionInSameCall.

@Test
public void warningForExplicitOverridingImplicitOptionInSameCall() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(ImplicitDependencyWarningOptions.class);
    parser.parse("--first=first", "--second=second");
    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 12 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method deprecationWarningForAbbreviatedExpansionOption.

@Test
public void deprecationWarningForAbbreviatedExpansionOption() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(WarningOptions.class);
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("-t"));
    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)

Example 13 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method badImplicitDependency.

@Test
public void badImplicitDependency() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(BadImplicitDependencyOptions.class);
    try {
        parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--first=first"));
    } catch (AssertionError e) {
        /* Expected error. */
        return;
    }
    fail();
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 14 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method warningForImplicitOverridingImplicitOption.

@Test
public void warningForImplicitOverridingImplicitOption() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(ImplicitDependencyWarningOptions.class);
    parser.parse("--first=first");
    assertThat(parser.getWarnings()).isEmpty();
    parser.parse("--third=third");
    assertThat(parser.getWarnings()).containsExactly("Option 'second' is implicitly defined by both " + "option 'first' and option 'third'");
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 15 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method newDeprecationWarning.

@Test
public void newDeprecationWarning() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(NewWarningOptions.class);
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--first"));
    assertEquals(Arrays.asList("Option 'first' is deprecated: it's gone"), parser.getWarnings());
}
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