Signed-off-by: Robin Rosenberg <robin.rosenberg@xxxxxxxxxx> --- .../org/spearce/jgit/lib/RepositoryTestCase.java | 21 +++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java index ef4fd1b..cab65a0 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java @@ -45,6 +45,7 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Reader; +import java.util.ArrayList; import junit.framework.TestCase; import org.spearce.jgit.util.JGitTestUtil; @@ -145,6 +146,8 @@ protected static void checkFile(File f, final String checkData) private static int testcount; private static Thread shutdownhook; + private ArrayList<Repository> repositoriesToClose = new ArrayList<Repository>(); + public void setUp() throws Exception { super.setUp(); System.gc(); @@ -192,6 +195,20 @@ copyFile(JGitTestUtil.getTestResourceFile(packs[k] + ".idx"), new File(packDir, protected void tearDown() throws Exception { db.close(); + for (Repository r : repositoriesToClose) { + r.close(); + } + // Since memory mapping is controlled by the GC we need to + // tell it this is a good time to clean up and unlock + // mmemory mapped files. + System.gc(); + + recursiveDelete(trash, false, getName()); + for (Repository r : repositoriesToClose) { + recursiveDelete(r.getWorkDir(), false, getName()); + } + repositoriesToClose.clear(); + super.tearDown(); } @@ -209,12 +226,14 @@ protected Repository createNewEmptyRepo() throws IOException { assertTrue(unusedDir.mkdirs()); final Repository newRepo = new Repository(newTestRepo); newRepo.create(); + final String name = getClass().getName() + "." + getName(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { - recursiveDelete(newTestRepo); + recursiveDelete(newTestRepo, false, name); } }); + repositoriesToClose.add(newRepo); return newRepo; } -- 1.6.0.3.640.g6331a -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html