From ea0f2f9e39a743a90a9dcdf3341ff907a0ec83d3 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Sun, 10 Apr 2011 01:02:29 +0200 Subject: Create all test data in trash folder This ensures that all test data is separated from project sources and cleaned up after the test. Previously the cloned bare test repository was created in org.eclipse.jgit.test/ and not deleted after the test run. Change-Id: I55110442e365fc8fe610f1c372f72a71ee6e1412 Signed-off-by: Matthias Sohn --- .../jgit/junit/LocalDiskRepositoryTestCase.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'org.eclipse.jgit.junit') diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java index 45c6c41f2c..4b512ed09e 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java @@ -293,17 +293,31 @@ public abstract class LocalDiskRepositoryTestCase { * the repository could not be created in the temporary area */ private FileRepository createRepository(boolean bare) throws IOException { - String uniqueId = System.currentTimeMillis() + "_" + (testCount++); - String gitdirName = "test" + uniqueId + (bare ? "" : "/") + Constants.DOT_GIT; - File gitdir = new File(trash, gitdirName).getCanonicalFile(); + File gitdir = createUniqueTestGitDir(bare); FileRepository db = new FileRepository(gitdir); - assertFalse(gitdir.exists()); db.create(); toClose.add(db); return db; } + /** + * Creates a new unique directory for a test repository + * + * @param bare + * true for a bare repository; false for a repository with a + * working directory + * @return a unique directory for a test repository + * @throws IOException + */ + protected File createUniqueTestGitDir(boolean bare) throws IOException { + String uniqueId = System.currentTimeMillis() + "_" + (testCount++); + String gitdirName = "test" + uniqueId + (bare ? "" : "/") + + Constants.DOT_GIT; + File gitdir = new File(trash, gitdirName).getCanonicalFile(); + return gitdir; + } + /** * Run a hook script in the repository, returning the exit status. * -- cgit v1.2.3