Fix failed tests when the tmp directory is a symlink
On Mac OS X /tmp is by default a symbolic link. Change-Id: I0913ee5ee8db5c5918a9e41abbbfe125b6c70783 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
8de3512890
commit
068e2df1ce
|
@ -498,4 +498,9 @@ protected DirCacheEntry createEntry(final String path, final FileMode mode,
|
|||
Constants.OBJ_BLOB, Constants.encode(content)));
|
||||
return entry;
|
||||
}
|
||||
|
||||
public static void assertEqualsFile(File expected, File actual)
|
||||
throws IOException {
|
||||
assertEquals(expected.getCanonicalFile(), actual.getCanonicalFile());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,17 +61,17 @@
|
|||
|
||||
public class RepositoryCacheTest extends RepositoryTestCase {
|
||||
@Test
|
||||
public void testNonBareFileKey() {
|
||||
public void testNonBareFileKey() throws IOException {
|
||||
File gitdir = db.getDirectory();
|
||||
File parent = gitdir.getParentFile();
|
||||
File other = new File(parent, "notagit");
|
||||
assertEquals(gitdir, FileKey.exact(gitdir, db.getFS()).getFile());
|
||||
assertEquals(parent, FileKey.exact(parent, db.getFS()).getFile());
|
||||
assertEquals(other, FileKey.exact(other, db.getFS()).getFile());
|
||||
assertEqualsFile(gitdir, FileKey.exact(gitdir, db.getFS()).getFile());
|
||||
assertEqualsFile(parent, FileKey.exact(parent, db.getFS()).getFile());
|
||||
assertEqualsFile(other, FileKey.exact(other, db.getFS()).getFile());
|
||||
|
||||
assertEquals(gitdir, FileKey.lenient(gitdir, db.getFS()).getFile());
|
||||
assertEquals(gitdir, FileKey.lenient(parent, db.getFS()).getFile());
|
||||
assertEquals(other, FileKey.lenient(other, db.getFS()).getFile());
|
||||
assertEqualsFile(gitdir, FileKey.lenient(gitdir, db.getFS()).getFile());
|
||||
assertEqualsFile(gitdir, FileKey.lenient(parent, db.getFS()).getFile());
|
||||
assertEqualsFile(other, FileKey.lenient(other, db.getFS()).getFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -83,10 +83,11 @@ public void testBareFileKey() throws IOException {
|
|||
assertTrue(name.endsWith(".git"));
|
||||
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());
|
||||
assertEquals(gitdir, FileKey.lenient(new File(parent, name), db.getFS()).getFile());
|
||||
assertEqualsFile(gitdir, FileKey.lenient(gitdir, db.getFS()).getFile());
|
||||
assertEqualsFile(gitdir,
|
||||
FileKey.lenient(new File(parent, name), db.getFS()).getFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -95,12 +96,12 @@ public void testFileKeyOpenExisting() throws IOException {
|
|||
|
||||
r = new FileKey(db.getDirectory(), db.getFS()).open(true);
|
||||
assertNotNull(r);
|
||||
assertEquals(db.getDirectory(), r.getDirectory());
|
||||
assertEqualsFile(db.getDirectory(), r.getDirectory());
|
||||
r.close();
|
||||
|
||||
r = new FileKey(db.getDirectory(), db.getFS()).open(false);
|
||||
assertNotNull(r);
|
||||
assertEquals(db.getDirectory(), r.getDirectory());
|
||||
assertEqualsFile(db.getDirectory(), r.getDirectory());
|
||||
r.close();
|
||||
}
|
||||
|
||||
|
@ -116,12 +117,13 @@ public void testFileKeyOpenNew() throws IOException {
|
|||
new FileKey(gitdir, db.getFS()).open(true);
|
||||
fail("incorrectly opened a non existant repository");
|
||||
} 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);
|
||||
assertNotNull(o);
|
||||
assertEquals(gitdir, o.getDirectory());
|
||||
assertEqualsFile(gitdir, o.getDirectory());
|
||||
assertFalse(gitdir.exists());
|
||||
}
|
||||
|
||||
|
|
|
@ -221,8 +221,9 @@ public void apply(DirCacheEntry ent) {
|
|||
Repository subRepo = gen.getRepository();
|
||||
addRepoToClose(subRepo);
|
||||
assertNotNull(subRepo);
|
||||
assertEquals(modulesGitDir, subRepo.getDirectory());
|
||||
assertEquals(new File(db.getWorkTree(), path), subRepo.getWorkTree());
|
||||
assertEqualsFile(modulesGitDir, subRepo.getDirectory());
|
||||
assertEqualsFile(new File(db.getWorkTree(), path),
|
||||
subRepo.getWorkTree());
|
||||
assertFalse(gen.next());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue