Search in sources :

Example 6 with OptionsBase

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

the class BuildEventStreamerModuleTest method testReturnsBuildEventStreamerOptions.

@Test
public void testReturnsBuildEventStreamerOptions() throws Exception {
    BuildEventStreamerModule module = new BuildEventStreamerModule();
    Iterable<Class<? extends OptionsBase>> commandOptions = module.getCommandOptions(command);
    assertThat(commandOptions).isNotEmpty();
    OptionsParser optionsParser = OptionsParser.newOptionsParser(commandOptions);
    optionsParser.parse("--experimental_build_event_text_file", "/tmp/foo.txt", "--experimental_build_event_binary_file", "/tmp/foo.bin");
    BuildEventStreamOptions options = optionsParser.getOptions(BuildEventStreamOptions.class);
    assertThat(options.getBuildEventTextFile()).isEqualTo("/tmp/foo.txt");
    assertThat(options.getBuildEventBinaryFile()).isEqualTo("/tmp/foo.bin");
}
Also used : OptionsBase(com.google.devtools.common.options.OptionsBase) BuildEventStreamOptions(com.google.devtools.build.lib.buildeventstream.transports.BuildEventStreamOptions) OptionsParser(com.google.devtools.common.options.OptionsParser) Test(org.junit.Test)

Example 7 with OptionsBase

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

the class ConfigurationTestCase method createCollection.

protected BuildConfigurationCollection createCollection(String... args) throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(ImmutableList.<Class<? extends OptionsBase>>builder().addAll(buildOptionClasses).add(TestOptions.class).build());
    parser.parse(args);
    InvocationPolicyEnforcer optionsPolicyEnforcer = analysisMock.getInvocationPolicyEnforcer();
    optionsPolicyEnforcer.enforce(parser);
    ImmutableSortedSet<String> multiCpu = ImmutableSortedSet.copyOf(parser.getOptions(TestOptions.class).multiCpus);
    BuildOptions buildOptions = BuildOptions.applyStaticConfigOverride(BuildOptions.of(buildOptionClasses, parser));
    skyframeExecutor.handleDiffs(reporter);
    BuildConfigurationCollection collection = skyframeExecutor.createConfigurations(reporter, configurationFactory, buildOptions, multiCpu, false);
    return collection;
}
Also used : OptionsBase(com.google.devtools.common.options.OptionsBase) BuildOptions(com.google.devtools.build.lib.analysis.config.BuildOptions) InvocationPolicyEnforcer(com.google.devtools.build.lib.flags.InvocationPolicyEnforcer) OptionsParser(com.google.devtools.common.options.OptionsParser) BuildConfigurationCollection(com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection)

Aggregations

OptionsBase (com.google.devtools.common.options.OptionsBase)7 OptionsParser (com.google.devtools.common.options.OptionsParser)5 BlazeCommand (com.google.devtools.build.lib.runtime.BlazeCommand)3 InvocationPolicyEnforcer (com.google.devtools.build.lib.flags.InvocationPolicyEnforcer)2 RuleClass (com.google.devtools.build.lib.packages.RuleClass)2 BlazeRuntime (com.google.devtools.build.lib.runtime.BlazeRuntime)2 Command (com.google.devtools.build.lib.runtime.Command)2 OptionsParsingException (com.google.devtools.common.options.OptionsParsingException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 ConfiguredRuleClassProvider (com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider)1 BuildConfigurationCollection (com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection)1 BuildOptions (com.google.devtools.build.lib.analysis.config.BuildOptions)1 BuildEventStreamOptions (com.google.devtools.build.lib.buildeventstream.transports.BuildEventStreamOptions)1 BlazeModule (com.google.devtools.build.lib.runtime.BlazeModule)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1