use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class CachedGoConfigIntegrationTest method setupExternalConfigRepo.
private Modification setupExternalConfigRepo(File configRepo, String configRepoTestResource) throws IOException {
ClassPathResource resource = new ClassPathResource(configRepoTestResource);
FileUtils.copyDirectory(resource.getFile(), configRepo);
CommandLine.createCommandLine("git").withEncoding("utf-8").withArg("init").withArg(configRepo.getAbsolutePath()).runOrBomb(null);
CommandLine.createCommandLine("git").withEncoding("utf-8").withArgs("config", "commit.gpgSign", "false").withWorkingDir(configRepo.getAbsoluteFile()).runOrBomb(null);
gitAddDotAndCommit(configRepo);
ConsoleResult consoleResult = CommandLine.createCommandLine("git").withEncoding("utf-8").withArg("log").withArg("-1").withArg("--pretty=format:%h").withWorkingDir(configRepo).runOrBomb(null);
Modification modification = new Modification();
modification.setRevision(consoleResult.outputAsString());
return modification;
}
use of com.thoughtworks.go.util.command.ConsoleResult 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.ConsoleResult 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.ConsoleResult 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.ConsoleResult in project gocd by gocd.
the class GoRepoConfigDataSourceIntegrationTest method setupExternalConfigRepo.
private String setupExternalConfigRepo(File configRepo, String configRepoTestResource) throws IOException {
ClassPathResource resource = new ClassPathResource(configRepoTestResource);
FileUtils.copyDirectory(resource.getFile(), configRepo);
CommandLine.createCommandLine("git").withEncoding("utf-8").withArg("init").withArg(configRepo.getAbsolutePath()).runOrBomb("");
CommandLine.createCommandLine("git").withEncoding("utf-8").withArgs("config", "commit.gpgSign", "false").withWorkingDir(configRepo.getAbsoluteFile()).runOrBomb("");
gitAddDotAndCommit(configRepo);
ConsoleResult consoleResult = CommandLine.createCommandLine("git").withEncoding("utf-8").withArg("log").withArg("-1").withArg("--pretty=format:%h").withWorkingDir(configRepo).runOrBomb("");
return consoleResult.outputAsString();
}
Aggregations