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
This commit is contained in:
Christian Halstrick 2015-11-20 14:38:24 +01:00 committed by Matthias Sohn
parent 55fb18feaa
commit 5c8f2d8feb
1 changed files with 8 additions and 13 deletions

View File

@ -92,11 +92,9 @@ public void testFailedCommitMsgHookBlocksCommit() throws Exception {
fail("expected commit-msg hook to abort commit"); fail("expected commit-msg hook to abort commit");
} catch (AbortedByHookException e) { } catch (AbortedByHookException e) {
assertEquals("unexpected error message from commit-msg hook", assertEquals("unexpected error message from commit-msg hook",
"Rejected by \"commit-msg\" hook.\nstderr" "Rejected by \"commit-msg\" hook.\nstderr\n",
+ System.lineSeparator(),
e.getMessage()); e.getMessage());
assertEquals("unexpected output from commit-msg hook", assertEquals("unexpected output from commit-msg hook", "test\n",
"test" + System.lineSeparator(),
out.toString()); out.toString());
} }
} }
@ -114,7 +112,7 @@ public void testCommitMsgHookReceivesCorrectParameter() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
git.commit().setMessage("commit") git.commit().setMessage("commit")
.setHookOutputStream(new PrintStream(out)).call(); .setHookOutputStream(new PrintStream(out)).call();
assertEquals(".git/COMMIT_EDITMSG" + System.lineSeparator(), assertEquals(".git/COMMIT_EDITMSG\n",
out.toString("UTF-8")); out.toString("UTF-8"));
} }
@ -147,11 +145,10 @@ public void testRunHook() throws Exception {
new String[] { new String[] {
"arg1", "arg2" }, "arg1", "arg2" },
new PrintStream(out), new PrintStream(err), "stdin"); 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")); out.toString("UTF-8"));
assertEquals("unexpected output on stderr stream", assertEquals("unexpected output on stderr stream", "stderr\n",
"stderr" + System.lineSeparator(),
err.toString("UTF-8")); err.toString("UTF-8"));
assertEquals("unexpected exit code", 0, res.getExitCode()); assertEquals("unexpected exit code", 0, res.getExitCode());
assertEquals("unexpected process status", ProcessResult.Status.OK, assertEquals("unexpected process status", ProcessResult.Status.OK,
@ -175,11 +172,9 @@ public void testFailedPreCommitHookBlockCommit() throws Exception {
fail("expected pre-commit hook to abort commit"); fail("expected pre-commit hook to abort commit");
} catch (AbortedByHookException e) { } catch (AbortedByHookException e) {
assertEquals("unexpected error message from pre-commit hook", assertEquals("unexpected error message from pre-commit hook",
"Rejected by \"pre-commit\" hook.\nstderr" "Rejected by \"pre-commit\" hook.\nstderr\n",
+ System.lineSeparator(),
e.getMessage()); e.getMessage());
assertEquals("unexpected output from pre-commit hook", assertEquals("unexpected output from pre-commit hook", "test\n",
"test" + System.lineSeparator(),
out.toString()); out.toString());
} }
} }