Search in sources :

Example 1 with Option

use of com.facebook.buck.util.ProcessExecutor.Option in project buck by facebook.

the class ShellStep method launchAndInteractWithProcess.

@VisibleForTesting
int launchAndInteractWithProcess(ExecutionContext context, ProcessExecutorParams params) throws InterruptedException, IOException {
    ImmutableSet.Builder<Option> options = ImmutableSet.builder();
    addOptions(context, options);
    ProcessExecutor executor = context.getProcessExecutor();
    ProcessExecutor.Result result = executor.launchAndExecute(params, options.build(), getStdin(context), getTimeout(), getTimeoutHandler(context));
    stdout = result.getStdout();
    stderr = result.getStderr();
    Verbosity verbosity = context.getVerbosity();
    if (stdout.isPresent() && !stdout.get().isEmpty() && (result.getExitCode() != 0 || shouldPrintStdout(verbosity))) {
        context.postEvent(ConsoleEvent.info("%s", stdout.get()));
    }
    if (stderr.isPresent() && !stderr.get().isEmpty() && (result.getExitCode() != 0 || shouldPrintStderr(verbosity))) {
        context.postEvent(ConsoleEvent.warning("%s", stderr.get()));
    }
    return getExitCodeFromResult(context, result);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Option(com.facebook.buck.util.ProcessExecutor.Option) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) Verbosity(com.facebook.buck.util.Verbosity) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

ProcessExecutor (com.facebook.buck.util.ProcessExecutor)1 Option (com.facebook.buck.util.ProcessExecutor.Option)1 Verbosity (com.facebook.buck.util.Verbosity)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableSet (com.google.common.collect.ImmutableSet)1