summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2015-11-24 15:16:42 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2015-11-26 01:26:32 +0100
commitadbe9006831a5d03a3513f4a09dbda8703e19f7c (patch)
tree34ba6b26498b0eb6393716ca42f85e7fcb0164f1
parent2cdc130dfc06179acce47a57cfa9562290598b64 (diff)
downloadjgit-adbe9006831a5d03a3513f4a09dbda8703e19f7c.tar.gz
jgit-adbe9006831a5d03a3513f4a09dbda8703e19f7c.zip
Fix unit tests on Windows
PushCommandTest and RunExternalScriptTest didn't succeed on Windows. Fix this by expecting a simple line-feed as line ending (instead of the platform dependent line separator. Additionally correct the computation of expected URLs in PushCommandTest. Change-Id: Idcdc41cd7e535ff88df33ea0a249333ed8fc91b0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java8
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java35
2 files changed, 21 insertions, 22 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java
index ccf1a51f1b..1fcfef9c71 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PushCommandTest.java
@@ -138,11 +138,9 @@ public class PushCommandTest extends RepositoryTestCase {
RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
git1.push().setRemote("test").setRefSpecs(spec).call();
- assertEquals(
- "1:test, 2:file://" + db2.getDirectory().toPath() //
- + "/, 3:\n" + "refs/heads/master " + commit.getName()
- + " refs/heads/x " + ObjectId.zeroId().name(),
- read(hookOutput));
+ assertEquals("1:test, 2:" + uri + ", 3:\n" + "refs/heads/master "
+ + commit.getName() + " refs/heads/x "
+ + ObjectId.zeroId().name(), read(hookOutput));
}
private File writeHookFile(final String name, final String data)
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java
index b6a2519c59..7c0985ef42 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java
@@ -57,12 +57,12 @@ import org.junit.Before;
import org.junit.Test;
public class RunExternalScriptTest {
+ private static final String LF = "\n";
+
private ByteArrayOutputStream out;
private ByteArrayOutputStream err;
- private String sep = System.getProperty("line.separator");
-
@Before
public void setUp() throws Exception {
out = new ByteArrayOutputStream();
@@ -74,7 +74,7 @@ public class RunExternalScriptTest {
String inputStr = "a\nb\rc\r\nd";
File script = writeTempFile("cat -");
int rc = FS.DETECTED.runProcess(
- new ProcessBuilder("/bin/sh", script.getPath()), out, err,
+ new ProcessBuilder("sh", script.getPath()), out, err,
new ByteArrayInputStream(inputStr.getBytes()));
assertEquals(0, rc);
assertEquals(inputStr, new String(out.toByteArray()));
@@ -85,7 +85,7 @@ public class RunExternalScriptTest {
public void testCopyNullStdIn() throws IOException, InterruptedException {
File script = writeTempFile("cat -");
int rc = FS.DETECTED.runProcess(
- new ProcessBuilder("/bin/sh", script.getPath()), out, err,
+ new ProcessBuilder("sh", script.getPath()), out, err,
(InputStream) null);
assertEquals(0, rc);
assertEquals("", new String(out.toByteArray()));
@@ -95,7 +95,8 @@ public class RunExternalScriptTest {
@Test
public void testArguments() throws IOException, InterruptedException {
File script = writeTempFile("echo $#,$1,$2,$3,$4,$5,$6");
- int rc = FS.DETECTED.runProcess(new ProcessBuilder("/bin/bash",
+ int rc = FS.DETECTED.runProcess(
+ new ProcessBuilder("sh",
script.getPath(), "a", "b", "c"), out, err, (InputStream) null);
assertEquals(0, rc);
assertEquals("3,a,b,c,,,\n", new String(out.toByteArray()));
@@ -106,7 +107,7 @@ public class RunExternalScriptTest {
public void testRc() throws IOException, InterruptedException {
File script = writeTempFile("exit 3");
int rc = FS.DETECTED.runProcess(
- new ProcessBuilder("/bin/sh", script.getPath(), "a", "b", "c"),
+ new ProcessBuilder("sh", script.getPath(), "a", "b", "c"),
out, err, (InputStream) null);
assertEquals(3, rc);
assertEquals("", new String(out.toByteArray()));
@@ -117,7 +118,7 @@ public class RunExternalScriptTest {
public void testNullStdout() throws IOException, InterruptedException {
File script = writeTempFile("echo hi");
int rc = FS.DETECTED.runProcess(
- new ProcessBuilder("/bin/sh", script.getPath()), null, err,
+ new ProcessBuilder("sh", script.getPath()), null, err,
(InputStream) null);
assertEquals(0, rc);
assertEquals("", new String(out.toByteArray()));
@@ -128,11 +129,11 @@ public class RunExternalScriptTest {
public void testStdErr() throws IOException, InterruptedException {
File script = writeTempFile("echo hi >&2");
int rc = FS.DETECTED.runProcess(
- new ProcessBuilder("/bin/sh", script.getPath()), null, err,
+ new ProcessBuilder("sh", script.getPath()), null, err,
(InputStream) null);
assertEquals(0, rc);
assertEquals("", new String(out.toByteArray()));
- assertEquals("hi" + sep, new String(err.toByteArray()));
+ assertEquals("hi" + LF, new String(err.toByteArray()));
}
@Test
@@ -140,11 +141,11 @@ public class RunExternalScriptTest {
String inputStr = "a\nb\rc\r\nd";
File script = writeTempFile("echo $#,$1,$2,$3,$4,$5,$6 >&2 ; cat -; exit 5");
int rc = FS.DETECTED.runProcess(
- new ProcessBuilder("/bin/sh", script.getPath(), "a", "b", "c"),
+ new ProcessBuilder("sh", script.getPath(), "a", "b", "c"),
out, err, new ByteArrayInputStream(inputStr.getBytes()));
assertEquals(5, rc);
assertEquals(inputStr, new String(out.toByteArray()));
- assertEquals("3,a,b,c,,," + sep, new String(err.toByteArray()));
+ assertEquals("3,a,b,c,,," + LF, new String(err.toByteArray()));
}
@Test(expected = IOException.class)
@@ -159,7 +160,7 @@ public class RunExternalScriptTest {
public void testWrongScript() throws IOException, InterruptedException {
File script = writeTempFile("cat-foo -");
int rc = FS.DETECTED.runProcess(
- new ProcessBuilder("/bin/sh", script.getPath(), "a", "b", "c"),
+ new ProcessBuilder("sh", script.getPath(), "a", "b", "c"),
out, err, (InputStream) null);
assertEquals(127, rc);
}
@@ -169,7 +170,7 @@ public class RunExternalScriptTest {
throws IOException, InterruptedException {
String inputStr = "a\nb\rc\r\nd";
File script = writeTempFile("cat -");
- ProcessBuilder pb = new ProcessBuilder("/bin/sh", script.getPath());
+ ProcessBuilder pb = new ProcessBuilder("sh", script.getPath());
ExecutionResult res = FS.DETECTED.execute(pb,
new ByteArrayInputStream(inputStr.getBytes()));
assertEquals(0, res.getRc());
@@ -180,11 +181,11 @@ public class RunExternalScriptTest {
@Test
public void testStdErrExecute() throws IOException, InterruptedException {
File script = writeTempFile("echo hi >&2");
- ProcessBuilder pb = new ProcessBuilder("/bin/sh", script.getPath());
+ ProcessBuilder pb = new ProcessBuilder("sh", script.getPath());
ExecutionResult res = FS.DETECTED.execute(pb, null);
assertEquals(0, res.getRc());
assertEquals("", new String(res.getStdout().toByteArray()));
- assertEquals("hi" + sep, new String(res.getStderr().toByteArray()));
+ assertEquals("hi" + LF, new String(res.getStderr().toByteArray()));
}
@Test
@@ -193,13 +194,13 @@ public class RunExternalScriptTest {
String inputStr = "a\nb\rc\r\nd";
File script = writeTempFile(
"echo $#,$1,$2,$3,$4,$5,$6 >&2 ; cat -; exit 5");
- ProcessBuilder pb = new ProcessBuilder("/bin/sh", script.getPath(), "a",
+ ProcessBuilder pb = new ProcessBuilder("sh", script.getPath(), "a",
"b", "c");
ExecutionResult res = FS.DETECTED.execute(pb,
new ByteArrayInputStream(inputStr.getBytes()));
assertEquals(5, res.getRc());
assertEquals(inputStr, new String(res.getStdout().toByteArray()));
- assertEquals("3,a,b,c,,," + sep,
+ assertEquals("3,a,b,c,,," + LF,
new String(res.getStderr().toByteArray()));
}