aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2013-05-08 17:34:47 -0700
committerShawn Pearce <spearce@spearce.org>2013-05-08 17:59:34 -0700
commit36144e12d80c97c64840e0d744c7f64f7ca624c1 (patch)
treedd5eb71871d84fc16d56961d1af3bb96c73696ad /org.eclipse.jgit.test
parente27993f1f881a0a4aad66679dc10fe0d749f6c83 (diff)
downloadjgit-36144e12d80c97c64840e0d744c7f64f7ca624c1.tar.gz
jgit-36144e12d80c97c64840e0d744c7f64f7ca624c1.zip
Fix hardcoded use of target/trash in LocalDiskRepositoryTestCase
`pwd`/target is only valid in Maven Reactor builds where Maven has moved into the project directory and created a target for the build output. Most other build systems do not use "target" and may not even perform a directory change between test suites. Rewrite LocalDiskRepositoryTestCase's temporary directory code to use the system specified location and create new unique names. This prevents fixes between concurrently running tests and allows the caller to specify the root using java.io.tmpdir. Update the surefire command lines to use target within each project as the system temporary directory during unit testing, preventing JGit's own test suite from writing to /tmp or somewhere like C:\tmp. Change-Id: I9e8431f6ddfc16fee89f677bcce67c99cfb56782
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/pom.xml2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RepositorySetupWorkDirTest.java21
2 files changed, 11 insertions, 12 deletions
diff --git a/org.eclipse.jgit.test/pom.xml b/org.eclipse.jgit.test/pom.xml
index 4d9eae99b8..c794102667 100644
--- a/org.eclipse.jgit.test/pom.xml
+++ b/org.eclipse.jgit.test/pom.xml
@@ -136,7 +136,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <argLine>-Xmx256m -Dfile.encoding=UTF-8</argLine>
+ <argLine>-Xmx256m -Dfile.encoding=UTF-8 -Djava.io.tmpdir=${project.build.directory}</argLine>
</configuration>
</plugin>
</plugins>
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RepositorySetupWorkDirTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RepositorySetupWorkDirTest.java
index bc47782ea0..295ef45a79 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RepositorySetupWorkDirTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RepositorySetupWorkDirTest.java
@@ -187,16 +187,15 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
}
}
- private static File getFile(String... pathComponents) throws IOException {
- String rootPath = new File(new File("target"), "trash").getPath();
+ private File getFile(String... pathComponents) throws IOException {
+ File dir = getTemporaryDirectory();
for (String pathComponent : pathComponents)
- rootPath = rootPath + File.separatorChar + pathComponent;
- File result = new File(rootPath);
- FileUtils.mkdirs(result, true);
- return result;
+ dir = new File(dir, pathComponent);
+ FileUtils.mkdirs(dir, true);
+ return dir;
}
- private static void setBare(File gitDir, boolean bare) throws IOException,
+ private void setBare(File gitDir, boolean bare) throws IOException,
ConfigInvalidException {
FileBasedConfig cfg = configFor(gitDir);
cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
@@ -204,7 +203,7 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
cfg.save();
}
- private static void setWorkTree(File gitDir, File workTree)
+ private void setWorkTree(File gitDir, File workTree)
throws IOException,
ConfigInvalidException {
String path = workTree.getAbsolutePath();
@@ -214,7 +213,7 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
cfg.save();
}
- private static FileBasedConfig configFor(File gitDir) throws IOException,
+ private FileBasedConfig configFor(File gitDir) throws IOException,
ConfigInvalidException {
File configPath = new File(gitDir, Constants.CONFIG);
FileBasedConfig cfg = new FileBasedConfig(configPath, FS.DETECTED);
@@ -222,14 +221,14 @@ public class RepositorySetupWorkDirTest extends LocalDiskRepositoryTestCase {
return cfg;
}
- private static void assertGitdirPath(Repository repo, String... expected)
+ private void assertGitdirPath(Repository repo, String... expected)
throws IOException {
File exp = getFile(expected).getCanonicalFile();
File act = repo.getDirectory().getCanonicalFile();
assertEquals("Wrong Git Directory", exp, act);
}
- private static void assertWorkdirPath(Repository repo, String... expected)
+ private void assertWorkdirPath(Repository repo, String... expected)
throws IOException {
File exp = getFile(expected).getCanonicalFile();
File act = repo.getWorkTree().getCanonicalFile();