diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java index c6c7ea0eb..b6649b3f0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java @@ -722,18 +722,23 @@ public void testRecordRemoteBranch() throws Exception { .call(); // Clone it File directory = createTempDirectory("testBareRepo"); - Repository localDb = Git.cloneRepository().setDirectory(directory) + try (Repository localDb = Git.cloneRepository() + .setDirectory(directory) .setURI(remoteDb.getDirectory().toURI().toString()).call() - .getRepository(); - // The .gitmodules file should exist - File gitmodules = new File(localDb.getWorkTree(), ".gitmodules"); - assertTrue("The .gitmodules file should exist", gitmodules.exists()); - FileBasedConfig c = new FileBasedConfig(gitmodules, FS.DETECTED); - c.load(); - assertEquals("standard branches work", "master", - c.getString("submodule", "with-branch", "branch")); - assertEquals("long branches work", "refs/heads/master", - c.getString("submodule", "with-long-branch", "branch")); + .getRepository();) { + // The .gitmodules file should exist + File gitmodules = new File(localDb.getWorkTree(), + ".gitmodules"); + assertTrue("The .gitmodules file should exist", + gitmodules.exists()); + FileBasedConfig c = new FileBasedConfig(gitmodules, + FS.DETECTED); + c.load(); + assertEquals("standard branches work", "master", + c.getString("submodule", "with-branch", "branch")); + assertEquals("long branches work", "refs/heads/master", + c.getString("submodule", "with-long-branch", "branch")); + } } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java index 9722ac675..5893d8c40 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java @@ -63,6 +63,7 @@ import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.treewalk.WorkingTreeIterator; import org.eclipse.jgit.util.FileUtils; +import org.eclipse.jgit.util.SystemReader; import org.junit.Test; /** @@ -468,6 +469,9 @@ public void testLeadingSpaces() throws IOException { @Test public void testTrailingSpaces() throws IOException { + // Windows can't create files with trailing spaces + // If this assumption fails the test is halted and ignored. + org.junit.Assume.assumeFalse(SystemReader.getInstance().isWindows()); writeTrashFile("a /a", ""); writeTrashFile("a /a ", ""); writeTrashFile("a /a ", ""); 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 b14a9bf2f..8aa14c521 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,9 +92,11 @@ public void testFailedCommitMsgHookBlocksCommit() throws Exception { 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\n", + "Rejected by \"commit-msg\" hook.\nstderr" + + System.lineSeparator(), e.getMessage()); - assertEquals("unexpected output from commit-msg hook", "test\n", + assertEquals("unexpected output from commit-msg hook", + "test" + System.lineSeparator(), out.toString()); } } @@ -112,7 +114,8 @@ public void testCommitMsgHookReceivesCorrectParameter() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(); git.commit().setMessage("commit") .setHookOutputStream(new PrintStream(out)).call(); - assertEquals(".git/COMMIT_EDITMSG\n", out.toString("UTF-8")); + assertEquals(".git/COMMIT_EDITMSG" + System.lineSeparator(), + out.toString("UTF-8")); } @Test @@ -144,9 +147,11 @@ public void testRunHook() throws Exception { new String[] { "arg1", "arg2" }, new PrintStream(out), new PrintStream(err), "stdin"); - assertEquals("unexpected hook output", "test arg1 arg2\nstdin\n", + assertEquals("unexpected hook output", "test arg1 arg2" + + System.lineSeparator() + "stdin" + System.lineSeparator(), out.toString("UTF-8")); - assertEquals("unexpected output on stderr stream", "stderr\n", + assertEquals("unexpected output on stderr stream", + "stderr" + System.lineSeparator(), err.toString("UTF-8")); assertEquals("unexpected exit code", 0, res.getExitCode()); assertEquals("unexpected process status", ProcessResult.Status.OK, @@ -170,9 +175,11 @@ public void testFailedPreCommitHookBlockCommit() throws Exception { 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\n", + "Rejected by \"pre-commit\" hook.\nstderr" + + System.lineSeparator(), e.getMessage()); - assertEquals("unexpected output from pre-commit hook", "test\n", + assertEquals("unexpected output from pre-commit hook", + "test" + System.lineSeparator(), out.toString()); } }