use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class P4CommandTestBase method shouldBombForNonZeroReturnCode.
@Test
public void shouldBombForNonZeroReturnCode() throws Exception {
ProcessOutputStreamConsumer outputStreamConsumer = Mockito.mock(ProcessOutputStreamConsumer.class);
CommandLine line = Mockito.mock(CommandLine.class);
when(line.run(outputStreamConsumer, null, "foo")).thenReturn(1);
try {
p4.execute(line, "foo", outputStreamConsumer, true);
fail("did't bomb for non zero return code");
} catch (Exception ignored) {
}
verify(line).run(outputStreamConsumer, null, "foo");
}
use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class CommandBuilderTest method commandWithArgsList_shouldAddCmdBeforeAWindowsCommand.
@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { EnhancedOSChecker.WINDOWS })
public void commandWithArgsList_shouldAddCmdBeforeAWindowsCommand() {
String[] args = { "some thing" };
CommandBuilderWithArgList commandBuilderWithArgList = new CommandBuilderWithArgList("echo", args, tempWorkDir, null, null, "some desc");
CommandLine commandLine = commandBuilderWithArgList.buildCommandLine();
assertThat(commandLine.toStringForDisplay(), is("cmd /c echo some thing"));
}
use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class HgTestRepo method hgAt.
private CommandLine hgAt(File workingFolder, String... arguments) {
CommandLine hg = CommandLine.createCommandLine("hg").withArgs(arguments).withEncoding("utf-8");
hg.setWorkingDir(workingFolder);
return hg;
}
use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class SvnRemoteRepository method start.
public void start() throws Exception {
if (processWrapper != null) {
throw new RuntimeException("Cannot start repository twice!");
}
port = RandomPort.find(toString());
CommandLine svnserve = CommandLine.createCommandLine("svnserve").withArgs("-d", "--foreground", "--listen-port", Integer.toString(port), "-r", repo.projectRepositoryRoot().getCanonicalPath()).withEncoding("utf-8");
consumer = inMemoryConsumer();
processWrapper = svnserve.execute(consumer, new EnvironmentVariableContext(), null);
RandomPort.waitForPort(port);
if (!processWrapper.isRunning()) {
throw new RuntimeException("Could not run command " + svnserve);
}
}
use of com.thoughtworks.go.util.command.CommandLine in project gocd by gocd.
the class ExecCommandExecutor method createCommandLine.
private CommandLine createCommandLine(String cmd, String consoleLogCharset) {
CommandLine commandLine;
if (SystemUtils.IS_OS_WINDOWS) {
commandLine = CommandLine.createCommandLine("cmd");
commandLine.withArg("/c");
commandLine.withArg(StringUtils.replace(cmd, "/", "\\"));
} else {
commandLine = CommandLine.createCommandLine(cmd);
}
commandLine.withEncoding(consoleLogCharset);
return commandLine;
}
Aggregations