Search in sources :

Example 21 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method newDeprecationWarningForListOption.

@Test
public void newDeprecationWarningForListOption() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(NewWarningOptions.class);
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--second=a"));
    assertEquals(Arrays.asList("Option 'second' is deprecated: sorry, no replacement"), parser.getWarnings());
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 22 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method getOptionValueDescriptionWithoutValue.

@Test
public void getOptionValueDescriptionWithoutValue() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(NullTestOptions.class);
    assertNull(parser.getOptionValueDescription("simple"));
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 23 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method deprecationWarning.

@Test
public void deprecationWarning() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(WarningOptions.class);
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--first"));
    assertEquals(Arrays.asList("Option 'first' is deprecated"), parser.getWarnings());
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 24 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method getOptionValueDescriptionWithNonExistingOption.

@Test
public void getOptionValueDescriptionWithNonExistingOption() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(NullTestOptions.class);
    try {
        parser.getOptionValueDescription("notexisting");
        fail();
    } catch (IllegalArgumentException e) {
    /* Expected exception. */
    }
}
Also used : OptionsParser.newOptionsParser(com.google.devtools.common.options.OptionsParser.newOptionsParser) Test(org.junit.Test)

Example 25 with OptionsParser.newOptionsParser

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

the class OptionsParserTest method badExpansionOptions.

@Test
public void badExpansionOptions() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(BadExpansionOptions.class);
    try {
        parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--first"));
    } catch (AssertionError e) {
        /* Expected error. */
        return;
    }
    fail();
}
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