Skip to contentSkip to conversation

Move pathOf to RepositoryTestCase and use it for locating test files

PATCH In review Jonas Fonseca 5 participants 13 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Move pathOf to RepositoryTestCase and use it for locating test files

This simplifies the code for accessing files.

---

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(-)
org.spearce.jgit.test/tst/org/spearce/jgit/dircache/DirCacheCGitCompatabilityTest.java +0 -4
index 43b23f6..f8f7fe9 100644
@@ -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(
org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV1Test.java +2 -4
index 49235ca..036aacb 100644
@@ -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");
 	}
 
 	/**
org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackIndexV2Test.java +2 -4
index c986c49..c44edcf 100644
@@ -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");
 	}
 
 	/**
org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackReverseIndexTest.java +1 -2
index 52d1282..63bf083 100644
@@ -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);
 	}
 
org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java +1 -2
index 4dd4b2a..c715182 100644
@@ -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);
 
org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryTestCase.java +6 -2
index 14e7179..610296f 100644
@@ -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", "[email protected]");
 	}
 
+	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,
org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0004_PackReader.java +2 -2
index c036e79..fa95939 100644
@@ -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;
org.spearce.jgit.test/tst/org/spearce/jgit/transport/IndexPackTest.java +2 -2
index ffa9142..18575c8 100644
@@ -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"));
Signature · 6 lines
1.6.0.336.ga07ba



-- 
Jonas Fonseca
#1 lore raw
Quoted 4 lines · Jonas Fonseca

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.

I wonder if we shouldn't just prod Imran to finish the Maven stuff. He has some patches in there that are specifically for this same issue under Maven.

http://repo.or.cz/w/egit/imyousuf.git?a=shortlog;h=refs/heads/mavenize-jgit

Signature · 1 line
Shawn.
#2 lore raw

Shawn O. Pearce <[email protected]> wrote Wed, Sep 03, 2008:

Quoted 11 lines
Quoted 4 lines · Jonas Fonseca

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.

I wonder if we shouldn't just prod Imran to finish the Maven stuff. He has some patches in there that are specifically for this same issue under Maven.

http://repo.or.cz/w/egit/imyousuf.git?a=shortlog;h=refs/heads/mavenize-jgit

I think the patch is a nice cleanup, even if it is a workaround. But anything that will help to make the build system more shell friendly is greatly appreciated.

Signature · 1 line
Jonas Fonseca
#3 lore raw
Quoted 11 lines · Jonas Fonseca

Shawn O. Pearce <[email protected]> wrote Wed, Sep 03, 2008:

Quoted 10 lines
Quoted 4 lines · Jonas Fonseca

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.

I wonder if we shouldn't just prod Imran to finish the Maven stuff. He has some patches in there that are specifically for this same issue under Maven.

Quoted 5 lines
Quoted 1 line

http://repo.or.cz/w/egit/imyousuf.git?a=shortlog;h=refs/heads/mavenize-jgit

I think the patch is a nice cleanup, even if it is a workaround. But anything that will help to make the build system more shell friendly is greatly appreciated.

Its going to cause a merge conflict with Imran's work. So I was hoping to avoid that and just take his stuff. But if we can't wait then yea, it is a nice cleanup patch and is worthwhile bringing in.

I'll hold onto it for about a day and see if Imran has any comment, and merge yours if I don't hear anything tomorrow-ish.

Signature · 1 line
Shawn.
#4 lore raw

Shawn O. Pearce <[email protected]> wrote Wed, Sep 03, 2008:

Quoted 9 lines
Quoted 1 line · Jonas Fonseca

I think the patch is a nice cleanup, even if it is a workaround.

Its going to cause a merge conflict with Imran's work. So I was hoping to avoid that and just take his stuff. But if we can't wait then yea, it is a nice cleanup patch and is worthwhile bringing in.

I'll hold onto it for about a day and see if Imran has any comment, and merge yours if I don't hear anything tomorrow-ish.

OK, no hurry.

BTW, I have started a JGit tutorial on the EGit wiki. For now it mostly consists of stub sections, but I hope to put more work into it in the days to follow. "Best viewed" via:

- http://code.google.com/docreader/#p=egit&t=JGitTutorial

Ideas and improvements for the topics and general structure are very welcome. The structure is given in the TableOfContents page.

- http://code.google.com/p/egit/wiki/TableOfContents

Signature · 1 line
Jonas Fonseca
#5 lore raw
Quoted 5 lines · Jonas Fonseca

BTW, I have started a JGit tutorial on the EGit wiki. For now it mostly consists of stub sections, but I hope to put more work into it in the days to follow. "Best viewed" via:

- http://code.google.com/docreader/#p=egit&t=JGitTutorial

This is quite nice. I like the starting page, where you walked through some of the command line tools. Well written IMHO.

Quoted 4 lines

Ideas and improvements for the topics and general structure are very welcome. The structure is given in the TableOfContents page.

- http://code.google.com/p/egit/wiki/TableOfContents

This also looks good. When I can find some time I'll try to fill one of these in. I'm not sure my writing is quite as good as yours though. ;-)

Signature · 1 line
Shawn.
#6 lore raw
Quoted 10 lines · Shawn O. Pearce
Quoted 5 lines · Jonas Fonseca

BTW, I have started a JGit tutorial on the EGit wiki. For now it mostly consists of stub sections, but I hope to put more work into it in the days to follow. "Best viewed" via:

- http://code.google.com/docreader/#p=egit&t=JGitTutorial

This is quite nice. I like the starting page, where you walked through some of the command line tools. Well written IMHO.

A great and welcome initialive.

Best regards,

Imran

Quoted 16 lines
Quoted 4 lines

Ideas and improvements for the topics and general structure are very welcome. The structure is given in the TableOfContents page.

- http://code.google.com/p/egit/wiki/TableOfContents

This also looks good. When I can find some time I'll try to fill one of these in. I'm not sure my writing is quite as good as yours though. ;-)

--
Shawn.
--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 7 lines
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: [email protected]
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557
#7 lore raw
In reply to Shawn O. Pearce
Quoted 10 lines · Shawn O. Pearce
Quoted 4 lines · Jonas Fonseca

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.

I wonder if we shouldn't just prod Imran to finish the Maven stuff. He has some patches in there that are specifically for this same issue under Maven.

Almighty willing, I will submit my patches this weekend (on Saturday). I develop in NetBeans so that would make it easier for sure.

Cheers,

Imran

Quoted 5 lines

http://repo.or.cz/w/egit/imyousuf.git?a=shortlog;h=refs/heads/mavenize-jgit

--
Shawn.

Signature · 4 lines
Imran M Yousuf
Email: [email protected]
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557
#8 lore raw
Quoted 7 lines · Imran M Yousuf
Quoted 6 lines · Shawn O. Pearce
Quoted 4 lines · Jonas Fonseca

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.

Quoted 7 lines
Quoted 4 lines

I wonder if we shouldn't just prod Imran to finish the Maven stuff. He has some patches in there that are specifically for this same issue under Maven.

Almighty willing, I will submit my patches this weekend (on Saturday). I develop in NetBeans so that would make it easier for sure.

Awesome. Then I'll hold off on Jonas' patch for now.

Signature · 1 line
Shawn.
#9 lore raw

Shawn O. Pearce <[email protected]> wrote Wed, Sep 03, 2008:

Quoted 3 lines
Quoted 2 lines · Imran M Yousuf

Almighty willing, I will submit my patches this weekend (on Saturday). I develop in NetBeans so that would make it easier for sure.

Perfect. You might be interested in the hopefully soon to be released jgit-based nbgit module:

- http://nbgit.googlecode.com/

The feature set is limited but some of the basics features should be there.

Quoted 1 line

Awesome. Then I'll hold off on Jonas' patch for now.

Super.

Signature · 1 line
Jonas Fonseca
#10 lore raw
Quoted 5 lines · Jonas Fonseca

Shawn O. Pearce <[email protected]> wrote Wed, Sep 03, 2008:

Quoted 3 lines
Quoted 2 lines · Imran M Yousuf

Almighty willing, I will submit my patches this weekend (on Saturday). I develop in NetBeans so that would make it easier for sure.

Quoted 7 lines

Perfect. You might be interested in the hopefully soon to be released jgit-based nbgit module:

- http://nbgit.googlecode.com/

The feature set is limited but some of the basics features should be there.

Ah great! I am really interested in it, I scheduled time on November to develop it since you have already started on it I guess I will join you guys. I had a discussion with Alex Coles couple of months back he was using CLI output for the purpose, its nice to see JGit being used as I suggested him the same. Let me get a little free and I will join that project as well.

Cheers,

Imran

Quoted 8 lines
Quoted 2 lines

Awesome. Then I'll hold off on Jonas' patch for now.

Super.

--
Jonas Fonseca

Signature · 7 lines
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: [email protected]
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557
#11 lore raw
In reply to Jonas Fonseca
Quoted 6 lines · Jonas Fonseca

Shawn O. Pearce <[email protected]> wrote Wed, Sep 03, 2008:

Quoted 4 lines
Quoted 2 lines · Imran M Yousuf

Almighty willing, I will submit my patches this weekend (on Saturday). I develop in NetBeans so that would make it easier for sure.

Quoted 7 lines

Perfect. You might be interested in the hopefully soon to be released jgit-based nbgit module:

- http://nbgit.googlecode.com/

The feature set is limited but some of the basics features should be there.

Could you please add it to Git Wiki
http://git.or.cz/gitwiki/InterfacesFrontendsAndTools
when it is ready, at least for testing purposes?

TIA

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git