Search in sources :

Example 11 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class CommandBuilderWithArgList method buildCommandLine.

protected CommandLine buildCommandLine() {
    CommandLine command = null;
    if (SystemUtils.IS_OS_WINDOWS) {
        command = CommandLine.createCommandLine("cmd").withWorkingDir(workingDir);
        command.withArg("/c");
        command.withArg(translateToWindowsPath(this.command));
    } else {
        command = CommandLine.createCommandLine(this.command).withWorkingDir(workingDir);
    }
    for (String arg : args) {
        command.withArg(arg);
    }
    return command;
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine)

Example 12 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class GitCommandTest method executeOnDir.

private void executeOnDir(File dir, String command, String... args) {
    CommandLine commandLine = CommandLine.createCommandLine(command);
    commandLine.withArgs(args);
    commandLine.withEncoding("utf-8");
    assertThat(dir.exists(), is(true));
    commandLine.setWorkingDir(dir);
    commandLine.runOrBomb(true, null);
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine)

Example 13 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class HgCommandTest method addremove.

private void addremove(File workingDir) {
    CommandLine hg = hg(workingDir, "addremove");
    String[] input = new String[] {};
    hg.runOrBomb(null, input);
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine)

Example 14 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class CommandBuilderTest method commandWithArgs_shouldAddCmdBeforeAWindowsCommand.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { EnhancedOSChecker.WINDOWS })
public void commandWithArgs_shouldAddCmdBeforeAWindowsCommand() {
    CommandBuilder commandBuilder = new CommandBuilder("echo", "some thing", tempWorkDir, null, null, "some desc");
    CommandLine commandLine = commandBuilder.buildCommandLine();
    assertThat(commandLine.toStringForDisplay(), is("cmd /c echo some thing"));
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test)

Example 15 with CommandLine

use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.

the class HgTestRepo method setUpServerRepoFromHgBundle.

private void setUpServerRepoFromHgBundle(File serverRepo, File hgBundleFile) {
    String[] input1 = new String[] {};
    hgAt(serverRepo, "init").runOrBomb(null, input1);
    CommandLine hg = hgAt(serverRepo, "pull", "-u", hgBundleFile.getAbsolutePath());
    String[] input = new String[] {};
    hg.runOrBomb(null, input);
}
Also used : CommandLine(com.thoughtworks.go.util.command.CommandLine)

Aggregations

CommandLine (com.thoughtworks.go.util.command.CommandLine)31 Test (org.junit.Test)16 InMemoryStreamConsumer (com.thoughtworks.go.util.command.InMemoryStreamConsumer)6 ConsoleResult (com.thoughtworks.go.util.command.ConsoleResult)5 File (java.io.File)5 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 CommandLineException (com.thoughtworks.go.util.command.CommandLineException)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 RunIf (com.googlecode.junit.ext.RunIf)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 ProcessOutputStreamConsumer (com.thoughtworks.go.util.command.ProcessOutputStreamConsumer)2 LinkedList (java.util.LinkedList)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 CheckedCommandLineException (com.thoughtworks.go.util.command.CheckedCommandLineException)1 CompositeConsumer (com.thoughtworks.go.util.command.CompositeConsumer)1 CruiseControlException (com.thoughtworks.go.util.command.CruiseControlException)1 ExecScript (com.thoughtworks.go.util.command.ExecScript)1 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)1 IOException (java.io.IOException)1