Browse Source

Merge "Create all test data in trash folder"

stable-0.12
Chris Aniszczyk 14 years ago committed by Code Review
parent
commit
72c2203117
  1. 22
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
  2. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/GitConstructionTest.java

22
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.
*

3
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();
}

Loading…
Cancel
Save