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");
}
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();
}
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));
}
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));
}
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));
}
Aggregations