use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class AppleSimulatorController method launchInstalledBundleInSimulator.
/**
* Launches a previously-installed bundle in a started simulator.
*
* @return the process ID of the newly-launched process if successful,
* an absent value otherwise.
*/
public Optional<Long> launchInstalledBundleInSimulator(String simulatorUdid, String bundleID, LaunchBehavior launchBehavior, List<String> args) throws IOException, InterruptedException {
ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
commandBuilder.add(simctlPath.toString(), "launch");
if (launchBehavior == LaunchBehavior.WAIT_FOR_DEBUGGER) {
commandBuilder.add("-w");
}
commandBuilder.add(simulatorUdid, bundleID);
commandBuilder.addAll(args);
ImmutableList<String> command = commandBuilder.build();
ProcessExecutorParams processExecutorParams = ProcessExecutorParams.builder().setCommand(command).build();
Set<ProcessExecutor.Option> options = EnumSet.of(ProcessExecutor.Option.EXPECTING_STD_OUT);
String message = String.format("Launching bundle ID %s in simulator %s via command %s", bundleID, simulatorUdid, command);
LOG.debug(message);
ProcessExecutor.Result result = processExecutor.launchAndExecute(processExecutorParams, options, /* stdin */
Optional.empty(), /* timeOutMs */
Optional.empty(), /* timeOutHandler */
Optional.empty());
if (result.getExitCode() != 0) {
LOG.error(result.getMessageForResult(message));
return Optional.empty();
}
Preconditions.checkState(result.getStdout().isPresent());
String trimmedStdout = result.getStdout().get().trim();
Matcher stdoutMatcher = SIMCTL_LAUNCH_OUTPUT_PATTERN.matcher(trimmedStdout);
if (!stdoutMatcher.find()) {
LOG.error("Could not parse output from %s: %s", command, trimmedStdout);
return Optional.empty();
}
return Optional.of(Long.parseLong(stdoutMatcher.group(1), 10));
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class CxxInferAnalyze method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
buildableContext.recordArtifact(specsDir);
buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
return ImmutableList.<Step>builder().add(new MkdirStep(getProjectFilesystem(), specsDir)).add(new SymCopyStep(getProjectFilesystem(), captureAndAnalyzeRules.captureRules.stream().map(CxxInferCapture::getSourcePathToOutput).map(context.getSourcePathResolver()::getRelativePath).collect(MoreCollectors.toImmutableList()), resultsDir)).add(new AbstractExecutionStep("write_specs_path_list") {
@Override
public StepExecutionResult execute(ExecutionContext executionContext) throws IOException {
try {
ImmutableList<String> specsDirsWithAbsolutePath = getSpecsOfAllDeps().stream().map(input -> context.getSourcePathResolver().getAbsolutePath(input).toString()).collect(MoreCollectors.toImmutableList());
getProjectFilesystem().writeLinesToPath(specsDirsWithAbsolutePath, specsPathList);
} catch (IOException e) {
executionContext.logError(e, "Error while writing specs path list file for the analyzer");
return StepExecutionResult.ERROR;
}
return StepExecutionResult.SUCCESS;
}
}).add(new DefaultShellStep(getProjectFilesystem().getRootPath(), getAnalyzeCommand(), ImmutableMap.of())).build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class AbstractPrebuiltCxxLibraryGroupDescription method getSharedLinkArgs.
/**
* @return the link args formed from the user-provided shared link line after resolving library
* macro references.
*/
private Iterable<Arg> getSharedLinkArgs(BuildTarget target, ImmutableMap<String, SourcePath> libs, ImmutableList<String> args) {
ImmutableList.Builder<Arg> builder = ImmutableList.builder();
for (String arg : args) {
Optional<Pair<String, String>> libRef = getLibRef(ImmutableSet.of(LIB_MACRO, REL_LIB_MACRO), arg);
if (libRef.isPresent()) {
SourcePath lib = libs.get(libRef.get().getSecond());
if (lib == null) {
throw new HumanReadableException("%s: library \"%s\" (in \"%s\") must refer to keys in the `sharedLibs` parameter", target, libRef.get().getSecond(), arg);
}
Arg libArg;
if (libRef.get().getFirst().equals(LIB_MACRO)) {
libArg = SourcePathArg.of(lib);
} else if (libRef.get().getFirst().equals(REL_LIB_MACRO)) {
if (!(lib instanceof PathSourcePath)) {
throw new HumanReadableException("%s: can only link prebuilt DSOs without sonames", target);
}
libArg = new RelativeLinkArg((PathSourcePath) lib);
} else {
throw new IllegalStateException();
}
builder.add(libArg);
} else {
builder.add(StringArg.of(arg));
}
}
return builder.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class Archive method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
// Cache the archive we built.
buildableContext.recordArtifact(output);
SourcePathResolver resolver = context.getSourcePathResolver();
// paths.
for (SourcePath input : inputs) {
Preconditions.checkState(resolver.getFilesystem(input).getRootPath().equals(getProjectFilesystem().getRootPath()));
}
ImmutableList.Builder<Step> builder = ImmutableList.builder();
builder.add(new MkdirStep(getProjectFilesystem(), output.getParent()), new RmStep(getProjectFilesystem(), output), new ArchiveStep(getProjectFilesystem(), archiver.getEnvironment(resolver), archiver.getCommandPrefix(resolver), archiverFlags, archiver.getArchiveOptions(contents == Contents.THIN), output, inputs.stream().map(resolver::getRelativePath).collect(MoreCollectors.toImmutableList()), archiver));
if (archiver.isRanLibStepRequired()) {
builder.add(new RanlibStep(getProjectFilesystem(), ranlib.getEnvironment(resolver), ranlib.getCommandPrefix(resolver), ranlibFlags, output));
}
if (!archiver.getScrubbers().isEmpty()) {
builder.add(new FileScrubberStep(getProjectFilesystem(), output, archiver.getScrubbers()));
}
return builder.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.
the class CxxBoostTest method parseResults.
@Override
protected ImmutableList<TestResultSummary> parseResults(Path exitCode, Path output, Path results) throws Exception {
ImmutableList.Builder<TestResultSummary> summariesBuilder = ImmutableList.builder();
// Process the test run output to grab the individual test stdout/stderr and
// test run times.
Map<String, String> messages = Maps.newHashMap();
Map<String, List<String>> stdout = Maps.newHashMap();
Map<String, Long> times = Maps.newHashMap();
try (BufferedReader reader = Files.newBufferedReader(output, Charsets.US_ASCII)) {
Stack<String> testSuite = new Stack<>();
Optional<String> currentTest = Optional.empty();
String line;
while ((line = reader.readLine()) != null) {
Matcher matcher;
if ((matcher = SUITE_START.matcher(line)).matches()) {
String suite = matcher.group(1);
testSuite.push(suite);
} else if ((matcher = SUITE_END.matcher(line)).matches()) {
String suite = matcher.group(1);
Preconditions.checkState(testSuite.peek().equals(suite));
testSuite.pop();
} else if ((matcher = CASE_START.matcher(line)).matches()) {
String test = Joiner.on(".").join(testSuite) + "." + matcher.group(1);
currentTest = Optional.of(test);
stdout.put(test, Lists.newArrayList());
} else if ((matcher = CASE_END.matcher(line)).matches()) {
String test = Joiner.on(".").join(testSuite) + "." + matcher.group(1);
Preconditions.checkState(currentTest.isPresent() && currentTest.get().equals(test));
String time = matcher.group(2);
times.put(test, time == null ? 0 : Long.valueOf(time));
currentTest = Optional.empty();
} else if (currentTest.isPresent()) {
if (ERROR.matcher(line).matches()) {
messages.put(currentTest.get(), line);
} else {
Preconditions.checkNotNull(stdout.get(currentTest.get())).add(line);
}
}
}
}
// Parse the XML result file for the actual test result summaries.
Document doc = XmlDomParser.parse(results);
Node testResult = doc.getElementsByTagName("TestResult").item(0);
Node testSuite = testResult.getFirstChild();
visitTestSuite(summariesBuilder, messages, stdout, times, "", testSuite);
return summariesBuilder.build();
}
Aggregations