dmitry@732: /* dmitry@732: * Copyright 2000-2014 JetBrains s.r.o. dmitry@732: * dmitry@732: * Licensed under the Apache License, Version 2.0 (the "License"); dmitry@732: * you may not use this file except in compliance with the License. dmitry@732: * You may obtain a copy of the License at dmitry@732: * dmitry@732: * http://www.apache.org/licenses/LICENSE-2.0 dmitry@732: * dmitry@732: * Unless required by applicable law or agreed to in writing, software dmitry@732: * distributed under the License is distributed on an "AS IS" BASIS, dmitry@732: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. dmitry@732: * See the License for the specific language governing permissions and dmitry@732: * limitations under the License. dmitry@732: */ dmitry@732: dmitry@229: package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; dmitry@229: dmitry@229: import com.intellij.openapi.util.SystemInfo; 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: File workingDir = new File("some dir"); dmitry@480: BaseCommand command = new BaseCommand(new CommandSettings(), "/path/to/hg", workingDir); eugene@824: MercurialCommandLine 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 /\"")); eugene@824: assertTrue(cl.toGeneralCommandLine().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 /")); eugene@824: assertTrue(cl.toGeneralCommandLine().getCommandLineString().endsWith(" param with spaces param with quote \" rm -rf /")); dmitry@229: } dmitry@229: } dmitry@229: dmitry@229: }