Browse Source

Use absolute paths for file:// URIs in tests

When run under Buck the repository paths may be relative.  Request
an absolute path to construct the URI, as relative paths are not
supported in file:// style URIs.

Change-Id: I85470d1db2f4e80cba30f1559c0d99bdfa8ac410
stable-3.2
Shawn Pearce 11 years ago
parent
commit
75cfa03e16
  1. 4
      org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java
  2. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java
  3. 36
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
  4. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java
  5. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
  6. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
  7. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java
  8. 6
      org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule/SubmoduleWalkTest.java
  9. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java

4
org.eclipse.jgit.ant.test/src/org/eclipse/jgit/ant/tasks/GitCloneTaskTest.java

@ -101,7 +101,7 @@ public class GitCloneTaskTest extends LocalDiskRepositoryTestCase {
public void shouldCloneAValidGitRepository() throws Exception {
Repository repo = createBareRepository();
File directory = repo.getDirectory();
task.setUri("file://" + directory);
task.setUri("file://" + directory.getAbsolutePath());
task.execute();
assertTrue(RepositoryCache.FileKey.isGitRepository(new File(dest, ".git"), FS.DETECTED));
@ -111,7 +111,7 @@ public class GitCloneTaskTest extends LocalDiskRepositoryTestCase {
public void shouldCreateABareCloneOfAValidGitRepository() throws Exception {
Repository repo = createBareRepository();
File directory = repo.getDirectory();
task.setUri("file://" + directory);
task.setUri("file://" + directory.getAbsolutePath());
task.setBare(true);
task.execute();

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BranchCommandTest.java

@ -121,7 +121,7 @@ public class BranchCommandTest extends RepositoryTestCase {
Git localGit = new Git(localRepository);
StoredConfig config = localRepository.getConfig();
RemoteConfig rc = new RemoteConfig(config, "origin");
rc.addURI(new URIish(remoteRepository.getDirectory().getPath()));
rc.addURI(new URIish(remoteRepository.getDirectory().getAbsolutePath()));
rc.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
rc.update(config);
config.save();

36
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java

@ -110,7 +110,7 @@ public class CloneCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testCloneRepository");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
@ -142,7 +142,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand command = Git.cloneRepository();
command.setBare(true);
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertEquals(new RefSpec("+refs/heads/*:refs/heads/*"),
@ -162,7 +162,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand command = Git.cloneRepository();
command.setBranch("refs/heads/master");
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
@ -177,7 +177,7 @@ public class CloneCommandTest extends RepositoryTestCase {
command = Git.cloneRepository();
command.setBranch("refs/heads/master");
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
command.setNoCheckout(true);
git2 = command.call();
addRepoToClose(git2.getRepository());
@ -192,7 +192,7 @@ public class CloneCommandTest extends RepositoryTestCase {
command = Git.cloneRepository();
command.setBranch("refs/heads/master");
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
command.setBare(true);
git2 = command.call();
addRepoToClose(git2.getRepository());
@ -209,7 +209,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand command = Git.cloneRepository();
command.setBranch("test");
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
@ -223,7 +223,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand command = Git.cloneRepository();
command.setBranch("tag-initial");
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
@ -242,7 +242,7 @@ public class CloneCommandTest extends RepositoryTestCase {
command.setBranchesToClone(Collections
.singletonList("refs/heads/master"));
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
@ -257,7 +257,7 @@ public class CloneCommandTest extends RepositoryTestCase {
command.setBranchesToClone(Collections
.singletonList("refs/heads/master"));
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
command.setBare(true);
git2 = command.call();
addRepoToClose(git2.getRepository());
@ -284,14 +284,14 @@ public class CloneCommandTest extends RepositoryTestCase {
File directory = createTempDirectory(dirName);
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
// clone again
command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
try {
git2 = command.call();
// we shouldn't get here
@ -310,7 +310,7 @@ public class CloneCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testCloneRepositoryWithMultipleHeadBranches");
CloneCommand clone = Git.cloneRepository();
clone.setDirectory(directory);
clone.setURI("file://" + git.getRepository().getWorkTree().getPath());
clone.setURI(fileUri());
Git git2 = clone.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
@ -343,7 +343,7 @@ public class CloneCommandTest extends RepositoryTestCase {
CloneCommand clone = Git.cloneRepository();
clone.setDirectory(directory);
clone.setCloneSubmodules(true);
clone.setURI("file://" + git.getRepository().getWorkTree().getPath());
clone.setURI(fileUri());
Git git2 = clone.call();
addRepoToClose(git2.getRepository());
assertNotNull(git2);
@ -458,7 +458,7 @@ public class CloneCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testCloneRepository1");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
Git git2 = command.call();
addRepoToClose(git2.getRepository());
assertFalse(git2
@ -476,7 +476,7 @@ public class CloneCommandTest extends RepositoryTestCase {
directory = createTempDirectory("testCloneRepository2");
command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
git2 = command.call();
addRepoToClose(git2.getRepository());
assertTrue(git2
@ -492,7 +492,7 @@ public class CloneCommandTest extends RepositoryTestCase {
directory = createTempDirectory("testCloneRepository2");
command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
git2 = command.call();
addRepoToClose(git2.getRepository());
assertTrue(git2
@ -502,4 +502,8 @@ public class CloneCommandTest extends RepositoryTestCase {
ConfigConstants.CONFIG_KEY_REBASE, false));
}
private String fileUri() {
return "file://" + git.getRepository().getWorkTree().getAbsolutePath();
}
}

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/LsRemoteCommandTest.java

@ -82,7 +82,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
command.setCloneAllBranches(true);
Git git2 = command.call();
addRepoToClose(git2.getRepository());
@ -99,7 +99,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
command.setCloneAllBranches(true);
Git git2 = command.call();
addRepoToClose(git2.getRepository());
@ -116,7 +116,7 @@ public class LsRemoteCommandTest extends RepositoryTestCase {
File directory = createTempDirectory("testRepository");
CloneCommand command = Git.cloneRepository();
command.setDirectory(directory);
command.setURI("file://" + git.getRepository().getWorkTree().getPath());
command.setURI(fileUri());
command.setCloneAllBranches(true);
Git git2 = command.call();
addRepoToClose(git2.getRepository());
@ -130,10 +130,14 @@ public class LsRemoteCommandTest extends RepositoryTestCase {
@Test
public void testLsRemoteWithoutLocalRepository() throws Exception {
String uri = "file://" + git.getRepository().getWorkTree().getPath();
String uri = fileUri();
Collection<Ref> refs = Git.lsRemoteRepository().setRemote(uri).setHeads(true).call();
assertNotNull(refs);
assertEquals(2, refs.size());
}
private String fileUri() {
return "file://" + git.getRepository().getWorkTree().getAbsolutePath();
}
}

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java

@ -139,7 +139,8 @@ public class PullCommandTest extends RepositoryTestCase {
assertEquals(sourceCommit.getId(), mergedCommits[1]);
RevCommit mergeCommit = new RevWalk(dbTarget).parseCommit(mergeResult
.getNewHead());
String message = "Merge branch 'master' of " + db.getWorkTree();
String message = "Merge branch 'master' of "
+ db.getWorkTree().getAbsolutePath();
assertEquals(message, mergeCommit.getShortMessage());
}
@ -255,7 +256,7 @@ public class PullCommandTest extends RepositoryTestCase {
config
.addURI(new URIish(source.getRepository().getWorkTree()
.getPath()));
.getAbsolutePath()));
config.addFetchRefSpec(new RefSpec(
"+refs/heads/*:refs/remotes/origin/*"));
config.update(targetConfig);

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java

@ -319,7 +319,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase {
config
.addURI(new URIish(source.getRepository().getWorkTree()
.getPath()));
.getAbsolutePath()));
config.addFetchRefSpec(new RefSpec(
"+refs/heads/*:refs/remotes/origin/*"));
config.update(targetConfig);

6
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileRepositoryBuilderTest.java

@ -129,7 +129,8 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
builder.setMustExist(true);
Repository repo2 = builder.build();
assertEquals(repo1.getDirectory(), repo2.getDirectory());
assertEquals(repo1.getDirectory().getAbsolutePath(), repo2
.getDirectory().getAbsolutePath());
assertEquals(dir, repo2.getWorkTree());
}
@ -167,7 +168,8 @@ public class FileRepositoryBuilderTest extends LocalDiskRepositoryTestCase {
builder.setWorkTree(dir);
builder.findGitDir(dir);
assertEquals(repo1.getDirectory(), builder.getGitDir());
assertEquals(repo1.getDirectory().getAbsolutePath(), builder
.getGitDir().getAbsolutePath());
builder.setMustExist(true);
Repository repo2 = builder.build();

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

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

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/TransportTest.java

@ -231,7 +231,7 @@ public class TransportTest extends SampleDataRepositoryTestCase {
@Test
public void testLocalTransportFetchWithoutLocalRepository()
throws Exception {
URIish uri = new URIish("file://" + db.getWorkTree().getPath());
URIish uri = new URIish("file://" + db.getWorkTree().getAbsolutePath());
transport = Transport.open(uri);
FetchConnection fetchConnection = transport.openFetch();
try {

Loading…
Cancel
Save