Search in sources :

Example 1 with ConsoleResult

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));
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 2 with ConsoleResult

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"));
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine) ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) Test(org.junit.Test)

Example 3 with ConsoleResult

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<>());
}
Also used : ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult) InMemoryStreamConsumer(com.thoughtworks.go.util.command.InMemoryStreamConsumer) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext)

Example 4 with ConsoleResult

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);
}
Also used : ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult)

Example 5 with ConsoleResult

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;
}
Also used : ConsoleResult(com.thoughtworks.go.util.command.ConsoleResult)

Aggregations

ConsoleResult (com.thoughtworks.go.util.command.ConsoleResult)24 Test (org.junit.jupiter.api.Test)12 Modification (com.thoughtworks.go.domain.materials.Modification)11 ArrayList (java.util.ArrayList)10 CommandLine (com.thoughtworks.go.util.command.CommandLine)5 Test (org.junit.Test)5 ClassPathResource (org.springframework.core.io.ClassPathResource)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)1 LogFixture (com.thoughtworks.go.util.LogFixture)1 CommandLineException (com.thoughtworks.go.util.command.CommandLineException)1 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)1 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)1 StringWriter (java.io.StringWriter)1 DateTime (org.joda.time.DateTime)1