aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit/src/org
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2011-04-10 01:02:29 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2011-04-10 01:02:29 +0200
commitea0f2f9e39a743a90a9dcdf3341ff907a0ec83d3 (patch)
tree271752b478604cf9fd00475e23c4cdadfbcf7836 /org.eclipse.jgit.junit/src/org
parent5dbef3fa51053b37f68b44ed390cab6dc8336dcc (diff)
downloadjgit-ea0f2f9e39a743a90a9dcdf3341ff907a0ec83d3.tar.gz
jgit-ea0f2f9e39a743a90a9dcdf3341ff907a0ec83d3.zip
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 <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src/org')
-rw-r--r--org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java22
1 files changed, 18 insertions, 4 deletions
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,11 +293,8 @@ 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);
@@ -305,6 +302,23 @@ public abstract class LocalDiskRepositoryTestCase {
}
/**
+ * 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.
*
* @param db