Browse Source

Merge "Fix failed tests when the tmp directory is a symlink"

stable-3.2
Matthias Sohn 11 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
a0cef63f6d
  1. 5
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
  2. 30
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java
  3. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java

5
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java

@ -498,4 +498,9 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase {
Constants.OBJ_BLOB, Constants.encode(content))); Constants.OBJ_BLOB, Constants.encode(content)));
return entry; return entry;
} }
public static void assertEqualsFile(File expected, File actual)
throws IOException {
assertEquals(expected.getCanonicalFile(), actual.getCanonicalFile());
}
} }

30
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryCacheTest.java

@ -61,17 +61,17 @@ import org.junit.Test;
public class RepositoryCacheTest extends RepositoryTestCase { public class RepositoryCacheTest extends RepositoryTestCase {
@Test @Test
public void testNonBareFileKey() { public void testNonBareFileKey() throws IOException {
File gitdir = db.getDirectory(); File gitdir = db.getDirectory();
File parent = gitdir.getParentFile(); File parent = gitdir.getParentFile();
File other = new File(parent, "notagit"); File other = new File(parent, "notagit");
assertEquals(gitdir, FileKey.exact(gitdir, db.getFS()).getFile()); assertEqualsFile(gitdir, FileKey.exact(gitdir, db.getFS()).getFile());
assertEquals(parent, FileKey.exact(parent, db.getFS()).getFile()); assertEqualsFile(parent, FileKey.exact(parent, db.getFS()).getFile());
assertEquals(other, FileKey.exact(other, db.getFS()).getFile()); assertEqualsFile(other, FileKey.exact(other, db.getFS()).getFile());
assertEquals(gitdir, FileKey.lenient(gitdir, db.getFS()).getFile()); assertEqualsFile(gitdir, FileKey.lenient(gitdir, db.getFS()).getFile());
assertEquals(gitdir, FileKey.lenient(parent, db.getFS()).getFile()); assertEqualsFile(gitdir, FileKey.lenient(parent, db.getFS()).getFile());
assertEquals(other, FileKey.lenient(other, db.getFS()).getFile()); assertEqualsFile(other, FileKey.lenient(other, db.getFS()).getFile());
} }
@Test @Test
@ -83,10 +83,11 @@ public class RepositoryCacheTest extends RepositoryTestCase {
assertTrue(name.endsWith(".git")); assertTrue(name.endsWith(".git"));
name = name.substring(0, name.length() - 4); name = name.substring(0, name.length() - 4);
assertEquals(gitdir, FileKey.exact(gitdir, db.getFS()).getFile()); assertEqualsFile(gitdir, FileKey.exact(gitdir, db.getFS()).getFile());
assertEquals(gitdir, FileKey.lenient(gitdir, db.getFS()).getFile()); assertEqualsFile(gitdir, FileKey.lenient(gitdir, db.getFS()).getFile());
assertEquals(gitdir, FileKey.lenient(new File(parent, name), db.getFS()).getFile()); assertEqualsFile(gitdir,
FileKey.lenient(new File(parent, name), db.getFS()).getFile());
} }
@Test @Test
@ -95,12 +96,12 @@ public class RepositoryCacheTest extends RepositoryTestCase {
r = new FileKey(db.getDirectory(), db.getFS()).open(true); r = new FileKey(db.getDirectory(), db.getFS()).open(true);
assertNotNull(r); assertNotNull(r);
assertEquals(db.getDirectory(), r.getDirectory()); assertEqualsFile(db.getDirectory(), r.getDirectory());
r.close(); r.close();
r = new FileKey(db.getDirectory(), db.getFS()).open(false); r = new FileKey(db.getDirectory(), db.getFS()).open(false);
assertNotNull(r); assertNotNull(r);
assertEquals(db.getDirectory(), r.getDirectory()); assertEqualsFile(db.getDirectory(), r.getDirectory());
r.close(); r.close();
} }
@ -116,12 +117,13 @@ public class RepositoryCacheTest extends RepositoryTestCase {
new FileKey(gitdir, db.getFS()).open(true); new FileKey(gitdir, db.getFS()).open(true);
fail("incorrectly opened a non existant repository"); fail("incorrectly opened a non existant repository");
} catch (RepositoryNotFoundException e) { } catch (RepositoryNotFoundException e) {
assertEquals("repository not found: " + gitdir, e.getMessage()); assertEquals("repository not found: " + gitdir.getCanonicalPath(),
e.getMessage());
} }
final Repository o = new FileKey(gitdir, db.getFS()).open(false); final Repository o = new FileKey(gitdir, db.getFS()).open(false);
assertNotNull(o); assertNotNull(o);
assertEquals(gitdir, o.getDirectory()); assertEqualsFile(gitdir, o.getDirectory());
assertFalse(gitdir.exists()); assertFalse(gitdir.exists());
} }

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java

@ -221,8 +221,9 @@ public class SubmoduleWalkTest extends RepositoryTestCase {
Repository subRepo = gen.getRepository(); Repository subRepo = gen.getRepository();
addRepoToClose(subRepo); addRepoToClose(subRepo);
assertNotNull(subRepo); assertNotNull(subRepo);
assertEquals(modulesGitDir, subRepo.getDirectory()); assertEqualsFile(modulesGitDir, subRepo.getDirectory());
assertEquals(new File(db.getWorkTree(), path), subRepo.getWorkTree()); assertEqualsFile(new File(db.getWorkTree(), path),
subRepo.getWorkTree());
assertFalse(gen.next()); assertFalse(gen.next());
} }

Loading…
Cancel
Save