use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class ProcessWrapperTest method shouldBeAbleToCompleteInput.
@Test
public void shouldBeAbleToCompleteInput() throws Exception {
String input1 = "SYSIN: Line 1!";
String input2 = "SYSIN: Line 2!";
CommandLine line = CommandLine.createCommandLine("ruby").withArgs(script("echo-all-input"));
ConsoleResult result = run(line, input1, input2);
assertThat(result.returnValue(), is(0));
assertThat(result.output(), contains("You said: " + input1));
assertThat(result.output(), contains("You said: " + input2));
assertThat(result.error().size(), is(0));
}
use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class ProcessWrapperTest method shouldSetGoServerVariablesIfTheyExist.
@Test
public void shouldSetGoServerVariablesIfTheyExist() {
System.setProperty("GO_DEPENDENCY_LABEL_PIPELINE_NAME", "999");
CommandLine line = CommandLine.createCommandLine("ruby").withArgs(script("dump-environment"));
ConsoleResult result = run(line);
assertThat("Errors: " + result.errorAsString(), result.returnValue(), is(0));
assertThat(result.output(), contains("GO_DEPENDENCY_LABEL_PIPELINE_NAME=999"));
}
use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class ProcessWrapperTest method run.
private ConsoleResult run(CommandLine line, String... inputs) {
InMemoryStreamConsumer outputStreamConsumer = inMemoryConsumer();
EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
environmentVariableContext.setProperty("GO_DEPENDENCY_LABEL_PIPELINE_NAME", "999", false);
line.addInput(inputs);
ProcessWrapper processWrapper = line.execute(outputStreamConsumer, environmentVariableContext, null);
return new ConsoleResult(processWrapper.waitForExit(), outputStreamConsumer.getStdLines(), outputStreamConsumer.getErrLines(), line.getArguments(), new ArrayList<>());
}
use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class P4Client method latestChange.
public List<Modification> latestChange() {
ConsoleResult result = execute(p4("changes", "-m", "1", clientView()));
P4OutputParser parser = new P4OutputParser(this);
return parser.modifications(result);
}
use of com.thoughtworks.go.util.command.ConsoleResult in project gocd by gocd.
the class P4Client method execute.
private ConsoleResult execute(CommandLine p4, String input) {
login();
String[] input1 = new String[] { input };
ConsoleResult result = runOrBomb(p4, input1);
if (result.error().size() > 0)
throw new RuntimeException(result.describe());
return result;
}
Aggregations