From 5c8f2d8feb60ddf380c46080ff290936b18f6277 Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Fri, 20 Nov 2015 14:38:24 +0100 Subject: [PATCH] Fix HookTest when running on Win32_Cygwin This test expected that the test scripts emit a platform-dependent newline (crlf on windows, lf on linux). But that's not true. Expected result should always be a trailing "\n" because the test scripts explicitly echo a "\n" in the end. Change-Id: I604e08cda8cebe276b5214ba0f618b6112c3441f --- .../tst/org/eclipse/jgit/util/HookTest.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java index 8aa14c521..e07076e32 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java @@ -92,11 +92,9 @@ public class HookTest extends RepositoryTestCase { fail("expected commit-msg hook to abort commit"); } catch (AbortedByHookException e) { assertEquals("unexpected error message from commit-msg hook", - "Rejected by \"commit-msg\" hook.\nstderr" - + System.lineSeparator(), + "Rejected by \"commit-msg\" hook.\nstderr\n", e.getMessage()); - assertEquals("unexpected output from commit-msg hook", - "test" + System.lineSeparator(), + assertEquals("unexpected output from commit-msg hook", "test\n", out.toString()); } } @@ -114,7 +112,7 @@ public class HookTest extends RepositoryTestCase { ByteArrayOutputStream out = new ByteArrayOutputStream(); git.commit().setMessage("commit") .setHookOutputStream(new PrintStream(out)).call(); - assertEquals(".git/COMMIT_EDITMSG" + System.lineSeparator(), + assertEquals(".git/COMMIT_EDITMSG\n", out.toString("UTF-8")); } @@ -147,11 +145,10 @@ public class HookTest extends RepositoryTestCase { new String[] { "arg1", "arg2" }, new PrintStream(out), new PrintStream(err), "stdin"); - assertEquals("unexpected hook output", "test arg1 arg2" - + System.lineSeparator() + "stdin" + System.lineSeparator(), + + assertEquals("unexpected hook output", "test arg1 arg2\nstdin\n", out.toString("UTF-8")); - assertEquals("unexpected output on stderr stream", - "stderr" + System.lineSeparator(), + assertEquals("unexpected output on stderr stream", "stderr\n", err.toString("UTF-8")); assertEquals("unexpected exit code", 0, res.getExitCode()); assertEquals("unexpected process status", ProcessResult.Status.OK, @@ -175,11 +172,9 @@ public class HookTest extends RepositoryTestCase { fail("expected pre-commit hook to abort commit"); } catch (AbortedByHookException e) { assertEquals("unexpected error message from pre-commit hook", - "Rejected by \"pre-commit\" hook.\nstderr" - + System.lineSeparator(), + "Rejected by \"pre-commit\" hook.\nstderr\n", e.getMessage()); - assertEquals("unexpected output from pre-commit hook", - "test" + System.lineSeparator(), + assertEquals("unexpected output from pre-commit hook", "test\n", out.toString()); } }