use of com.google.copybara.util.CommandTimeoutException in project copybara by google.
the class CommandRunnerTest method testTimeoutCustomExitCode.
@Test
public void testTimeoutCustomExitCode() throws Exception {
Command command = bashCommand("" + "trap 'exit 42' SIGTERM SIGINT\n" + "echo stdout msg\n" + ">&2 echo stderr msg\n" + "sleep 10\n");
CommandTimeoutException e = assertThrows(CommandTimeoutException.class, () -> runCommand(new CommandRunner(command, Duration.ofSeconds(1))));
assertThat(e.getTimeout()).isEquivalentAccordingToCompareTo(Duration.ofSeconds(1));
assertThat(e.getOutput().getStderr()).contains("stderr msg");
assertThat(e.getMessage()).containsMatch("Command '.*' killed by Copybara after timeout \\(1s\\)");
assertThat(e.getOutput().getStdout()).contains("stdout msg");
}
use of com.google.copybara.util.CommandTimeoutException in project copybara by google.
the class CommandRunnerTest method testTimeout.
@Test
public void testTimeout() throws Exception {
Command command = bashCommand("" + "echo stdout msg\n" + ">&2 echo stderr msg\n" + "sleep 10\n");
CommandTimeoutException e = assertThrows(CommandTimeoutException.class, () -> runCommand(new CommandRunner(command, Duration.ofSeconds(1))));
assertThat(e.getOutput().getStdout()).contains("stdout msg");
assertThat(e.getOutput().getStderr()).contains("stderr msg");
assertThat(e.getMessage()).containsMatch("Command '.*' killed by Copybara after timeout \\(1s\\)");
assertThat(e.getTimeout()).isEquivalentAccordingToCompareTo(Duration.ofSeconds(1));
}
Aggregations