dmitry@229: package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; dmitry@229: dmitry@229: import com.intellij.execution.configurations.GeneralCommandLine; dmitry@229: import com.intellij.openapi.util.SystemInfo; dmitry@229: import jetbrains.buildServer.buildTriggers.vcs.mercurial.Constants; dmitry@229: import jetbrains.buildServer.buildTriggers.vcs.mercurial.Util; dmitry@229: import jetbrains.buildServer.vcs.impl.VcsRootImpl; dmitry@229: import junit.framework.TestCase; dmitry@229: import org.testng.annotations.Test; dmitry@229: dmitry@229: import java.io.File; dmitry@229: import java.io.IOException; dmitry@229: dmitry@229: /** dmitry@229: * @author dmitry.neverov dmitry@229: */ dmitry@229: @Test dmitry@229: public class BaseCommandTest extends TestCase { dmitry@229: dmitry@229: public void should_quote_command_line_arguments() throws IOException { dmitry@229: VcsRootImpl root = new VcsRootImpl(1, "rootForTest"); dmitry@229: root.addProperty(Constants.REPOSITORY_PROP, "http://some.org/repo.hg"); dmitry@229: root.addProperty(Constants.HG_COMMAND_PATH_PROP, Util.getHgPath()); dmitry@229: File workingDir = new File("some dir"); dmitry@229: Settings settings = new Settings(root); dmitry@229: dmitry@229: BaseCommand command = new BaseCommand(settings, workingDir); dmitry@229: GeneralCommandLine cl = command.createCommandLine(); dmitry@229: cl.addParameter("param with spaces"); dmitry@229: cl.addParameter("param with quote \" rm -rf /"); dmitry@229: if (SystemInfo.isWindows) { dmitry@229: assertTrue(cl.getCommandLineString().endsWith(" \"param with spaces\" \"param with quote \\\" rm -rf /\"")); dmitry@229: } else { dmitry@229: assertTrue(cl.getCommandLineString().endsWith(" param with spaces param with quote \" rm -rf /")); dmitry@229: } dmitry@229: } dmitry@229: dmitry@229: }