[prev in list] [next in list] [prev in thread] [next in thread]
List: git
Subject: [JGIT PATCH 4/8] Add a counter to make sure the test repo name is unique
From: Robin Rosenberg <robin.rosenberg () dewire ! com>
Date: 2008-11-30 23:40:31
Message-ID: 1228088435-23722-5-git-send-email-robin.rosenberg () dewire ! com
[Download RAW message or body]
System.currentTimeMillis() does not have the granularity
necessary to guarantee uniqueness. We keep it to make sure we
have unique names between different runs, but add a counter to
make it unique within the execution of a test suite.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../org/spearce/jgit/lib/RepositoryTestCase.java | 6 ++++--
1 files changed, 4 insertions(+), 2 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 \
3b08fa5..6ea9b45 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
@@ -150,11 +150,13 @@ protected static void checkFile(File f, final String checkData)
protected Repository db;
+ private static int testcount;
+
public void setUp() throws Exception {
super.setUp();
configure();
recursiveDelete(trashParent);
- trash = new File(trashParent,"trash"+System.currentTimeMillis());
+ trash = new File(trashParent,"trash"+System.currentTimeMillis()+"."+(testcount++));
trash_git = new File(trash, ".git");
Runtime.getRuntime().addShutdownHook(new Thread() {
@@ -200,7 +202,7 @@ protected void tearDown() throws Exception {
* @throws IOException
*/
protected Repository createNewEmptyRepo() throws IOException {
- File newTestRepo = new File(trashParent, \
"new"+System.currentTimeMillis()+"/.git"); + File newTestRepo = new \
File(trashParent, "new"+System.currentTimeMillis()+"."+(testcount++)+"/.git"); \
assertFalse(newTestRepo.exists()); final Repository newRepo = new \
Repository(newTestRepo); newRepo.create();
--
1.6.0.3.640.g6331a
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic