From: Jonas Fonseca <fonseca@diku.dk>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: "Shawn O. Pearce" <spearce@spearce.org>, git@vger.kernel.org
Subject: [JGIT PATCH 2/2] Move pathOf to RepositoryTestCase and use it for locating test files
Date: Wed, 3 Sep 2008 11:10:22 +0200 [thread overview]
Message-ID: <20080903091022.GC23406@diku.dk> (raw)
This simplifies the code for accessing files.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
This is a workaround patch disguised as a cleanup patch. For NetBeans I
am not yet sure how to setup JGit as a project where everythng works.
For now I need to be able to override the path to files used by the
tests and this patch reduces that change to one single place.
.../dircache/DirCacheCGitCompatabilityTest.java | 4 ----
.../tst/org/spearce/jgit/lib/PackIndexV1Test.java | 6 ++----
.../tst/org/spearce/jgit/lib/PackIndexV2Test.java | 6 ++----
.../org/spearce/jgit/lib/PackReverseIndexTest.java | 3 +--
.../tst/org/spearce/jgit/lib/PackWriterTest.java | 3 +--
.../org/spearce/jgit/lib/RepositoryTestCase.java | 8 ++++++--
.../tst/org/spearce/jgit/lib/T0004_PackReader.java | 4 ++--
.../org/spearce/jgit/transport/IndexPackTest.java | 4 ++--
8 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/dircache/DirCacheCGitCompatabilityTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/dircache/DirCacheCGitCompatabilityTest.java
index 43b23f6..f8f7fe9 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/dircache/DirCacheCGitCompatabilityTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/dircache/DirCacheCGitCompatabilityTest.java
@@ -137,10 +137,6 @@ assertEquals(ObjectId
}
}
- private File pathOf(final String name) {
- return new File("tst", name);
- }
-
private Map<String, CGitIndexRecord> readLsFiles() throws Exception {
final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<String, CGitIndexRecord>();
final BufferedReader br = new BufferedReader(new InputStreamReader(
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV1Test.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV1Test.java
index 49235ca..036aacb 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV1Test.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV1Test.java
@@ -44,14 +44,12 @@
public class PackIndexV1Test extends PackIndexTest {
@Override
public File getFileForPack34be9032() {
- return new File(new File("tst"),
- "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idx");
+ return pathOf("pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idx");
}
@Override
public File getFileForPackdf2982f28() {
- return new File(new File("tst"),
- "pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.idx");
+ return pathOf("pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.idx");
}
/**
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV2Test.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV2Test.java
index c986c49..c44edcf 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV2Test.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV2Test.java
@@ -44,14 +44,12 @@
public class PackIndexV2Test extends PackIndexTest {
@Override
public File getFileForPack34be9032() {
- return new File(new File("tst"),
- "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idxV2");
+ return pathOf("pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idxV2");
}
@Override
public File getFileForPackdf2982f28() {
- return new File(new File("tst"),
- "pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.idxV2");
+ return pathOf("pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.idxV2");
}
/**
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackReverseIndexTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackReverseIndexTest.java
index 52d1282..63bf083 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackReverseIndexTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackReverseIndexTest.java
@@ -54,8 +54,7 @@
public void setUp() throws Exception {
super.setUp();
// index with both small (< 2^31) and big offsets
- idx = PackIndex.open(new File(new File("tst"),
- "pack-huge.idx"));
+ idx = PackIndex.open(pathOf("pack-huge.idx"));
reverseIdx = new PackReverseIndex(idx);
}
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
index 4dd4b2a..c715182 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
@@ -239,8 +239,7 @@ public void testWritePack2DeltasCRC32Copy() throws IOException {
"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
final File crc32Idx = new File(packDir,
"pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idx");
- copyFile(new File(new File("tst"),
- "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idxV2"),
+ copyFile(pathOf("pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.idxV2"),
crc32Idx);
db.openPack(crc32Pack, crc32Idx);
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 14e7179..610296f 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
@@ -50,7 +50,7 @@
public abstract class RepositoryTestCase extends TestCase {
- protected final File trashParent = new File("trash");
+ protected final File trashParent = pathOf("trash");
protected File trash;
@@ -65,6 +65,10 @@
jcommitter = new PersonIdent("J. Committer", "jcommitter@example.com");
}
+ protected static File pathOf(final String name) {
+ return new File("tst", name);
+ }
+
protected static void recursiveDelete(final File dir) {
final File[] ls = dir.listFiles();
if (ls != null) {
@@ -142,7 +146,7 @@ public void run() {
"pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745",
"pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa"
};
- final File tst = new File("tst");
+ final File tst = pathOf(".");
final File packDir = new File(db.getObjectsDirectory(), "pack");
for (int k = 0; k < packs.length; k++) {
copyFile(new File(tst, packs[k] + ".pack"), new File(packDir,
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0004_PackReader.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0004_PackReader.java
index c036e79..fa95939 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0004_PackReader.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0004_PackReader.java
@@ -43,7 +43,7 @@
public class T0004_PackReader extends RepositoryTestCase {
private static final String PACK_NAME = "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f";
- private static final File TEST_PACK = new File(new File("tst"), PACK_NAME + ".pack");
+ private static final File TEST_PACK = pathOf(PACK_NAME + ".pack");
private static final File TEST_IDX = new File(TEST_PACK.getParentFile(), PACK_NAME + ".idx");
public void test003_lookupCompressedObject() throws IOException {
@@ -77,7 +77,7 @@ public void test004_lookupDeltifiedObject() throws IOException {
}
public void test005_todopack() throws IOException {
- final File todopack = new File(new File("tst"), "todopack");
+ final File todopack = pathOf("todopack");
if (!todopack.isDirectory()) {
System.err.println("Skipping " + getName() + ": no " + todopack);
return;
diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/IndexPackTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/IndexPackTest.java
index ffa9142..18575c8 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/transport/IndexPackTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/transport/IndexPackTest.java
@@ -63,7 +63,7 @@
* @throws IOException
*/
public void test1() throws IOException {
- File packFile = new File("tst/pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
+ File packFile = pathOf("pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f.pack");
final InputStream is = new FileInputStream(packFile);
try {
IndexPack pack = new IndexPack(db, is, new File(trash, "tmp_pack1"));
@@ -89,7 +89,7 @@ public void test1() throws IOException {
* @throws IOException
*/
public void test2() throws IOException {
- File packFile = new File("tst/pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack");
+ File packFile = pathOf("pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371.pack");
final InputStream is = new FileInputStream(packFile);
try {
IndexPack pack = new IndexPack(db, is, new File(trash, "tmp_pack2"));
--
1.6.0.336.ga07ba
--
Jonas Fonseca
next reply other threads:[~2008-09-03 9:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-03 9:10 Jonas Fonseca [this message]
2008-09-03 17:09 ` [JGIT PATCH 2/2] Move pathOf to RepositoryTestCase and use it for locating test files Shawn O. Pearce
2008-09-03 21:48 ` Jonas Fonseca
2008-09-03 23:02 ` Shawn O. Pearce
2008-09-03 23:57 ` Jonas Fonseca
2008-09-04 4:09 ` Shawn O. Pearce
2008-09-04 4:16 ` Imran M Yousuf
2008-09-04 1:47 ` Imran M Yousuf
2008-09-04 3:21 ` Shawn O. Pearce
2008-09-04 9:23 ` Jonas Fonseca
2008-09-04 10:47 ` Jakub Narebski
2008-09-04 11:17 ` Jonas Fonseca
2008-09-05 1:48 ` Imran M Yousuf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080903091022.GC23406@diku.dk \
--to=fonseca@diku.dk \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).