use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class ShellStepTest method testStdErrPrintedOnErrorIfNotSilentEvenIfNotShouldPrintStdErr.
@Test
public void testStdErrPrintedOnErrorIfNotSilentEvenIfNotShouldPrintStdErr() throws Exception {
ShellStep command = createCommand(/*shouldPrintStdErr*/
false, /*shouldPrintStdOut*/
false);
ProcessExecutorParams params = createParams();
FakeProcess process = new FakeProcess(EXIT_FAILURE, OUTPUT_MSG, ERROR_MSG);
TestConsole console = new TestConsole(Verbosity.STANDARD_INFORMATION);
ExecutionContext context = createContext(ImmutableMap.of(params, process), console);
command.launchAndInteractWithProcess(context, params);
assertEquals(ERROR_MSG, console.getTextWrittenToStdErr());
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class ShellStepTest method testStdErrPrintedOnSuccessIfShouldPrintStdErrEvenIfSilent.
@Test
public void testStdErrPrintedOnSuccessIfShouldPrintStdErrEvenIfSilent() throws Exception {
ShellStep command = createCommand(/*shouldPrintStdErr*/
true, /*shouldPrintStdOut*/
false);
ProcessExecutorParams params = createParams();
FakeProcess process = new FakeProcess(EXIT_SUCCESS, OUTPUT_MSG, ERROR_MSG);
TestConsole console = new TestConsole(Verbosity.SILENT);
ExecutionContext context = createContext(ImmutableMap.of(params, process), console);
command.launchAndInteractWithProcess(context, params);
assertEquals(ERROR_MSG, console.getTextWrittenToStdErr());
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class ShellStepTest method testStdinDoesNotGetToProcessWhenAbsent.
@Test
public void testStdinDoesNotGetToProcessWhenAbsent() throws Exception {
final Optional<String> stdin = Optional.empty();
ShellStep command = createCommand(ImmutableMap.of(), ImmutableList.of("cat", "-"), null, /*shouldPrintStdErr*/
true, /*shouldPrintStdOut*/
true, stdin);
ProcessExecutorParams params = createParams();
FakeProcess process = new FakeProcess(EXIT_SUCCESS, OUTPUT_MSG, ERROR_MSG);
TestConsole console = new TestConsole(Verbosity.ALL);
ExecutionContext context = createContext(ImmutableMap.of(params, process), console);
command.launchAndInteractWithProcess(context, params);
assertEquals("", process.getOutput());
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class WorkerProcessProtocolZeroTest method setUp.
@Before
public void setUp() throws IOException {
ProcessExecutorParams fakeParams = ProcessExecutorParams.ofCommand("");
fakeProcess = new FakeProcess(0);
fakeProcessExecutor = new FakeProcessExecutor(ImmutableMap.of(fakeParams, fakeProcess));
fakeLaunchedProcess = fakeProcessExecutor.launchProcess(fakeParams);
dummyJsonWriter = new JsonWriter(new StringWriter());
dummyJsonReader = new JsonReader(new StringReader(""));
}
use of com.facebook.buck.util.FakeProcess in project buck by facebook.
the class ShellStepTest method testStdOutNotPrintedIfNotShouldRecordStdoutEvenIfVerbose.
@Test
public void testStdOutNotPrintedIfNotShouldRecordStdoutEvenIfVerbose() throws Exception {
ShellStep command = createCommand(/*shouldPrintStdErr*/
false, /*shouldPrintStdOut*/
false);
ProcessExecutorParams params = createParams();
FakeProcess process = new FakeProcess(EXIT_SUCCESS, OUTPUT_MSG, ERROR_MSG);
TestConsole console = new TestConsole(Verbosity.ALL);
ExecutionContext context = createContext(ImmutableMap.of(params, process), console);
command.launchAndInteractWithProcess(context, params);
assertEquals("", console.getTextWrittenToStdErr());
}
Aggregations