Search in sources :

Example 1 with CommandExecutor

use of com.google.copybara.util.CommandRunner.CommandExecutor in project copybara by google.

the class CommandRunnerTest method testCommandWithCustomRunner.

@Test
public void testCommandWithCustomRunner() throws Exception {
    Command command = bashCommand("");
    CommandException e = assertThrows(CommandException.class, () -> runCommand(new CommandRunner(command).withCommandExecutor(new CommandExecutor() {

        @Override
        public TerminationStatus getCommandOutputWithStatus(Command cmd, byte[] input, KillableObserver cmdMonitor, OutputStream stdoutStream, OutputStream stderrStream) throws CommandException {
            throw new CommandException(cmd, "OH NOES!");
        }
    })));
    assertThat(e).hasMessageThat().contains("OH NOES!");
}
Also used : Command(com.google.copybara.shell.Command) KillableObserver(com.google.copybara.shell.KillableObserver) TerminationStatus(com.google.copybara.shell.TerminationStatus) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) CommandExecutor(com.google.copybara.util.CommandRunner.CommandExecutor) CommandException(com.google.copybara.shell.CommandException) CommandRunner(com.google.copybara.util.CommandRunner) Test(org.junit.Test)

Aggregations

Command (com.google.copybara.shell.Command)1 CommandException (com.google.copybara.shell.CommandException)1 KillableObserver (com.google.copybara.shell.KillableObserver)1 TerminationStatus (com.google.copybara.shell.TerminationStatus)1 CommandRunner (com.google.copybara.util.CommandRunner)1 CommandExecutor (com.google.copybara.util.CommandRunner.CommandExecutor)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 Test (org.junit.Test)1