comparison mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/BaseCommandTest.java @ 824:f86c06f4ab8a

MercurialCommandLine now delegates to GeneralCommandLine
author eugene.petrenko@jetbrains.com
date Fri, 30 May 2014 11:49:44 +0200
parents 31a1aca3305c
children 7bf4d943d5bb
comparison
equal deleted inserted replaced
823:7a7a6e255c71 824:f86c06f4ab8a
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 16
17 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; 17 package jetbrains.buildServer.buildTriggers.vcs.mercurial.command;
18 18
19 import com.intellij.execution.configurations.GeneralCommandLine;
20 import com.intellij.openapi.util.SystemInfo; 19 import com.intellij.openapi.util.SystemInfo;
21 import junit.framework.TestCase; 20 import junit.framework.TestCase;
22 import org.testng.annotations.Test; 21 import org.testng.annotations.Test;
23 22
24 import java.io.File; 23 import java.io.File;
31 public class BaseCommandTest extends TestCase { 30 public class BaseCommandTest extends TestCase {
32 31
33 public void should_quote_command_line_arguments() throws IOException { 32 public void should_quote_command_line_arguments() throws IOException {
34 File workingDir = new File("some dir"); 33 File workingDir = new File("some dir");
35 BaseCommand command = new BaseCommand(new CommandSettings(), "/path/to/hg", workingDir); 34 BaseCommand command = new BaseCommand(new CommandSettings(), "/path/to/hg", workingDir);
36 GeneralCommandLine cl = command.createCommandLine(); 35 MercurialCommandLine cl = command.createCommandLine();
37 cl.addParameter("param with spaces"); 36 cl.addParameter("param with spaces");
38 cl.addParameter("param with quote \" rm -rf /"); 37 cl.addParameter("param with quote \" rm -rf /");
39 if (SystemInfo.isWindows) { 38 if (SystemInfo.isWindows) {
40 assertTrue(cl.getCommandLineString().endsWith(" \"param with spaces\" \"param with quote \\\" rm -rf /\"")); 39 assertTrue(cl.getCommandLineString().endsWith(" \"param with spaces\" \"param with quote \\\" rm -rf /\""));
40 assertTrue(cl.toGeneralCommandLine().getCommandLineString().endsWith(" \"param with spaces\" \"param with quote \\\" rm -rf /\""));
41 } else { 41 } else {
42 assertTrue(cl.getCommandLineString().endsWith(" param with spaces param with quote \" rm -rf /")); 42 assertTrue(cl.getCommandLineString().endsWith(" param with spaces param with quote \" rm -rf /"));
43 assertTrue(cl.toGeneralCommandLine().getCommandLineString().endsWith(" param with spaces param with quote \" rm -rf /"));
43 } 44 }
44 } 45 }
45 46
46 } 47 }