Skip to content
Permalink
Browse files
Merge pull request #4 from jglick/JENKINS-25678-space-in-path
[JENKINS-25678] Space-in-path bug
  • Loading branch information
jglick committed Mar 6, 2015
2 parents bf5101c + faa0648 commit 89be896b84a70ec34fe83b90c53cfee989256bf0
@@ -52,7 +52,7 @@ public String getScript() {
}
BatchController c = new BatchController(ws);

c.getBatchFile1(ws).write(String.format("call %s > %s 2>&1\r\necho %%ERRORLEVEL%% > %s\r\n",
c.getBatchFile1(ws).write(String.format("call \"%s\" > \"%s\" 2>&1\r\necho %%ERRORLEVEL%% > \"%s\"\r\n",
c.getBatchFile2(ws),
c.getLogFile(ws),
c.getResultFile(ws)
@@ -0,0 +1,59 @@
/*
* The MIT License
*
* Copyright 2015 Jesse Glick.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.jenkinsci.plugins.durabletask;

import hudson.EnvVars;
import hudson.FilePath;
import hudson.util.StreamTaskListener;
import java.io.ByteArrayOutputStream;
import java.io.File;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Assume;
import org.junit.Rule;
import org.jvnet.hudson.test.JenkinsRule;

public class WindowsBatchScriptTest {

@Rule public JenkinsRule j = new JenkinsRule();

//@Issue("JENKINS-25678")
@Test public void spaceInPath() throws Exception {
Assume.assumeTrue("This test is only for Windows", File.pathSeparatorChar == ';');
StreamTaskListener l = StreamTaskListener.fromStdout();
FilePath ws = j.jenkins.getRootPath().child("space in path");
Controller c = new WindowsBatchScript("echo hello world").launch(new EnvVars(), ws, j.jenkins.createLauncher(l), l);
while (c.exitStatus(ws) == null) {
Thread.sleep(100);
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
c.writeLog(ws, baos);
assertEquals(Integer.valueOf(0), c.exitStatus(ws));
String log = baos.toString();
assertTrue(log, log.contains("hello world"));
c.cleanup(ws);
}

}

0 comments on commit 89be896

Please sign in to comment.