use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class ProcessWrapperTest method shouldCollectOutput.
@Test
public void shouldCollectOutput() throws Exception {
String output = "SYSOUT: Hello World!";
String error = "SYSERR: Some error happened!";
CommandLine line = CommandLine.createCommandLine("ruby").withArgs(script("echo"), output, error);
ConsoleResult result = run(line);
assertThat("Errors: " + result.errorAsString(), result.returnValue(), is(0));
assertThat(result.output(), contains(output));
assertThat(result.error(), contains(error));
}
use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class ProcessWrapperTest method shouldReportReturnValueIfProcessFails.
@Test
public void shouldReportReturnValueIfProcessFails() {
CommandLine line = CommandLine.createCommandLine("ruby").withArgs(script("nonexistent-script"));
ConsoleResult result = run(line);
assertThat(result.returnValue(), is(1));
}
use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class ProcessWrapperTest method shouldAcceptInputString.
@Test
public void shouldAcceptInputString() throws Exception {
String input = "SYSIN: Hello World!";
CommandLine line = CommandLine.createCommandLine("ruby").withArgs(script("echo-input"));
ConsoleResult result = run(line, input);
assertThat(result.output(), contains(input));
assertThat(result.error().size(), is(0));
}
use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class ProcessWrapperTest method shouldTryCommandWithTimeout.
@Test
public void shouldTryCommandWithTimeout() throws IOException {
CommandLine line = CommandLine.createCommandLine("doesnotexist");
try {
line.waitForSuccess(100);
fail("Expected Exception");
} catch (Exception e) {
assertThat(e.getMessage(), containsString("Timeout after 0.1 seconds waiting for command 'doesnotexist'"));
}
}
use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class GarageService method gc.
public void gc(HttpLocalizedOperationResult result) {
CommandLine gitCheck = getGit().withArg("--version");
InMemoryStreamConsumer consumer = new InMemoryStreamConsumer();
if (execute(gitCheck, consumer, result)) {
File configRepoDir = systemEnvironment.getConfigRepoDir();
CommandLine gc = getGit().withArg("gc").withWorkingDir(configRepoDir);
execute(gc, consumer, result);
}
}
Aggregations