diff options
author | Chris Aniszczyk <caniszczyk@gmail.com> | 2011-04-09 19:12:23 -0400 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2011-04-09 19:12:23 -0400 |
commit | 72c2203117feb161d66a5403790ba27e5029804f (patch) | |
tree | f42170df57ac4b85cd6e11ba022cd3c7b1186fa1 | |
parent | b8669ed5c06633a46f434894206594edd0dfbe19 (diff) | |
parent | ea0f2f9e39a743a90a9dcdf3341ff907a0ec83d3 (diff) | |
download | jgit-72c2203117feb161d66a5403790ba27e5029804f.tar.gz jgit-72c2203117feb161d66a5403790ba27e5029804f.zip |
Merge "Create all test data in trash folder"
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java | 22 | ||||
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java | 3 |
2 files changed, 20 insertions, 5 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 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 4075586b51..0e0b18732b 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 @@ -68,7 +68,8 @@ public class GitConstructionTest extends RepositoryTestCase { git.commit().setMessage("Initial commit").call(); bareRepo = Git.cloneRepository().setBare(true) - .setURI(db.getDirectory().toURI().toString()).call() + .setURI(db.getDirectory().toURI().toString()) + .setDirectory(createUniqueTestGitDir(true)).call() .getRepository(); } |