diff options
author | Christian Halstrick <christian.halstrick@sap.com> | 2011-05-24 09:36:45 +0200 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-05-31 08:58:45 -0700 |
commit | c1525e2aa5e444a2a234de27d6b7189d5d7f715e (patch) | |
tree | 271f0a6a5661572543cddfb126ed2816dbf2f471 /org.eclipse.jgit.test | |
parent | cc2197ed9c3be35c875c8316f17a2d6e8d338c88 (diff) | |
download | jgit-c1525e2aa5e444a2a234de27d6b7189d5d7f715e.tar.gz jgit-c1525e2aa5e444a2a234de27d6b7189d5d7f715e.zip |
Make sure test repositories are closed
Some repositories created during tests are not added to the 'toClose'
list in LocalDiskRepositoryTestCase. Therefore when the tests end
we may have open FileHandles and on Windows this may cause the
tests to fail because we can't delete those files.
This is fixed by adding the possibility to explicitly add
repositories to the list of repos which are closed automatically.
Change-Id: I1261baeef4c7d9aaedd7c34b546393bfa005bbcc
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Diffstat (limited to 'org.eclipse.jgit.test')
4 files changed, 16 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java index 9d01291b7a..2e3345756d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java @@ -101,6 +101,7 @@ public class CloneCommandTest extends RepositoryTestCase { command.setURI("file://" + git.getRepository().getWorkTree().getPath()); Git git2 = command.call(); + addRepoToClose(git2.getRepository()); assertNotNull(git2); ObjectId id = git2.getRepository().resolve("tag-for-blob"); assertNotNull(id); @@ -135,6 +136,8 @@ public class CloneCommandTest extends RepositoryTestCase { command.setURI("file://" + git.getRepository().getWorkTree().getPath()); Git git2 = command.call(); + addRepoToClose(git2.getRepository()); + assertNotNull(git2); assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master"); @@ -152,6 +155,8 @@ public class CloneCommandTest extends RepositoryTestCase { + git.getRepository().getWorkTree().getPath()); command.setNoCheckout(true); git2 = command.call(); + addRepoToClose(git2.getRepository()); + assertNotNull(git2); assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master"); @@ -169,6 +174,8 @@ public class CloneCommandTest extends RepositoryTestCase { + git.getRepository().getWorkTree().getPath()); command.setBare(true); git2 = command.call(); + addRepoToClose(git2.getRepository()); + assertNotNull(git2); assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master"); @@ -191,6 +198,7 @@ public class CloneCommandTest extends RepositoryTestCase { command.setURI("file://" + git.getRepository().getWorkTree().getPath()); Git git2 = command.call(); + addRepoToClose(git2.getRepository()); assertNotNull(git2); assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master"); @@ -209,6 +217,7 @@ public class CloneCommandTest extends RepositoryTestCase { + git.getRepository().getWorkTree().getPath()); command.setBare(true); git2 = command.call(); + addRepoToClose(git2.getRepository()); assertNotNull(git2); assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java index b6ba4c927d..4d2b241dcb 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java @@ -71,6 +71,7 @@ public class GitConstructionTest extends RepositoryTestCase { .setURI(db.getDirectory().toURI().toString()) .setDirectory(createUniqueTestGitDir(true)).call() .getRepository(); + addRepoToClose(bareRepo); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java index 15aafc9060..28c54c269f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java @@ -70,6 +70,7 @@ public class InitCommandTest extends RepositoryTestCase { InitCommand command = new InitCommand(); command.setDirectory(directory); Repository repository = command.call().getRepository(); + addRepoToClose(repository); assertNotNull(repository); } catch (Exception e) { fail(e.getMessage()); @@ -84,6 +85,7 @@ public class InitCommandTest extends RepositoryTestCase { command.setDirectory(directory); command.setBare(true); Repository repository = command.call().getRepository(); + addRepoToClose(repository); assertNotNull(repository); assertTrue(repository.isBare()); } catch (Exception e) { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java index 81aa25f981..a4a5a2671b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java @@ -89,6 +89,8 @@ public class LsRemoteCommandTest extends RepositoryTestCase { + git.getRepository().getWorkTree().getPath()); command.setCloneAllBranches(true); Git git2 = command.call(); + addRepoToClose(git2.getRepository()); + LsRemoteCommand lsRemoteCommand = git2.lsRemote(); Collection<Ref> refs = lsRemoteCommand.call(); @@ -109,6 +111,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase { + git.getRepository().getWorkTree().getPath()); command.setCloneAllBranches(true); Git git2 = command.call(); + addRepoToClose(git2.getRepository()); LsRemoteCommand lsRemoteCommand = git2.lsRemote(); lsRemoteCommand.setTags(true); @@ -130,6 +133,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase { + git.getRepository().getWorkTree().getPath()); command.setCloneAllBranches(true); Git git2 = command.call(); + addRepoToClose(git2.getRepository()); LsRemoteCommand lsRemoteCommand = git2.lsRemote(); lsRemoteCommand.setHeads(true); |