Search in sources :

Example 26 with OptionsParser

use of com.google.devtools.common.options.OptionsParser 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 27 with OptionsParser

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

the class StandaloneSpawnStrategyTest method setUp.

@Before
public final void setUp() throws Exception {
    Path testRoot = createTestRoot();
    Path workspaceDir = testRoot.getRelative("workspace-name");
    workspaceDir.createDirectory();
    // setup output base & directories
    Path outputBase = testRoot.getRelative("outputBase");
    outputBase.createDirectory();
    BlazeDirectories directories = new BlazeDirectories(outputBase, outputBase, workspaceDir, "mock-product-name");
    // This call implicitly symlinks the integration bin tools into the exec root.
    IntegrationMock.get().getIntegrationBinTools(directories);
    OptionsParser optionsParser = OptionsParser.newOptionsParser(ExecutionOptions.class);
    optionsParser.parse("--verbose_failures");
    EventBus bus = new EventBus();
    ResourceManager resourceManager = ResourceManager.instanceForTestingOnly();
    resourceManager.setAvailableResources(ResourceSet.create(/*memoryMb=*/
    1, /*cpuUsage=*/
    1, /*ioUsage=*/
    1, /*localTestCount=*/
    1));
    this.executor = new BlazeExecutor(directories.getExecRoot(), reporter, bus, BlazeClock.instance(), optionsParser, ImmutableList.<ActionContext>of(), ImmutableMap.<String, SpawnActionContext>of("", new StandaloneSpawnStrategy(directories.getExecRoot(), false, "mock-product-name", resourceManager)), ImmutableList.<ActionContextProvider>of());
    executor.getExecRoot().createDirectory();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) BlazeExecutor(com.google.devtools.build.lib.exec.BlazeExecutor) EventBus(com.google.common.eventbus.EventBus) ResourceManager(com.google.devtools.build.lib.actions.ResourceManager) OptionsParser(com.google.devtools.common.options.OptionsParser) ActionContext(com.google.devtools.build.lib.actions.Executor.ActionContext) SpawnActionContext(com.google.devtools.build.lib.actions.SpawnActionContext) SpawnActionContext(com.google.devtools.build.lib.actions.SpawnActionContext) ActionContextProvider(com.google.devtools.build.lib.exec.ActionContextProvider) Before(org.junit.Before)

Example 28 with OptionsParser

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

the class OptionsUtilsTest method asStringOfExplicitOptionsMultipleOptionsAreMultipleTimes.

@Test
public void asStringOfExplicitOptionsMultipleOptionsAreMultipleTimes() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(IntrospectionExample.class);
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--alpha=one"));
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--alpha=two"));
    assertEquals("--alpha=one --alpha=two", OptionsUtils.asShellEscapedString(parser));
}
Also used : OptionsParser(com.google.devtools.common.options.OptionsParser) Test(org.junit.Test)

Example 29 with OptionsParser

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

the class OptionsUtilsTest method asStringOfExplicitOptionsWithBooleans.

@Test
public void asStringOfExplicitOptionsWithBooleans() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(BooleanOpts.class);
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--b_one", "--nob_two"));
    assertEquals("--b_one --nob_two", OptionsUtils.asShellEscapedString(parser));
    parser = OptionsParser.newOptionsParser(BooleanOpts.class);
    parser.parse(OptionPriority.COMMAND_LINE, null, Arrays.asList("--b_one=true", "--b_two=0"));
    assertTrue(parser.getOptions(BooleanOpts.class).bOne);
    assertFalse(parser.getOptions(BooleanOpts.class).bTwo);
    assertEquals("--b_one --nob_two", OptionsUtils.asShellEscapedString(parser));
}
Also used : OptionsParser(com.google.devtools.common.options.OptionsParser) Test(org.junit.Test)

Example 30 with OptionsParser

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

the class OptionsUtilsTest method asStringOfExplicitOptions.

@Test
public void asStringOfExplicitOptions() throws Exception {
    OptionsParser parser = OptionsParser.newOptionsParser(IntrospectionExample.class);
    parser.parse("--alpha=no", "--gamma=no", "--echo=no");
    assertEquals("--alpha=no --gamma=no", OptionsUtils.asShellEscapedString(parser));
}
Also used : OptionsParser(com.google.devtools.common.options.OptionsParser) Test(org.junit.Test)

Aggregations

OptionsParser (com.google.devtools.common.options.OptionsParser)50 Path (java.nio.file.Path)11 IOException (java.io.IOException)10 Stopwatch (com.google.common.base.Stopwatch)8 Test (org.junit.Test)7 InvocationPolicyEnforcer (com.google.devtools.build.lib.flags.InvocationPolicyEnforcer)6 OptionsParsingException (com.google.devtools.common.options.OptionsParsingException)6 AaptConfigOptions (com.google.devtools.build.android.AndroidResourceProcessor.AaptConfigOptions)5 OptionsBase (com.google.devtools.common.options.OptionsBase)5 MergingException (com.android.ide.common.res2.MergingException)4 Path (com.google.devtools.build.lib.vfs.Path)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 EventBus (com.google.common.eventbus.EventBus)3 FlagAaptOptions (com.google.devtools.build.android.AndroidResourceProcessor.FlagAaptOptions)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 VariantType (com.android.builder.core.VariantType)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 DexingOptions (com.google.devtools.build.android.dexer.Dexing.DexingOptions)2 SpawnActionContext (com.google.devtools.build.lib.actions.SpawnActionContext)2