]> source.dussan.org Git - jgit.git/commitdiff
Remove hardcoded target/trash from test cases 85/17985/1
authorShawn Pearce <sop@google.com>
Fri, 1 Nov 2013 15:04:44 +0000 (16:04 +0100)
committerShawn Pearce <sop@google.com>
Sat, 2 Nov 2013 02:57:47 +0000 (19:57 -0700)
Buck does not create a target directory for the build output, this
is Maven specific and the project unit tests should not rely on it.

Instead follow the pattern used by org.eclipse.jgit.test which is to
create a temporary directory in the system temporary folder, and
configure the Maven surefire plugin to use the target directory.

Change-Id: Iebe5093332343a90f51080614e083aac0d29c26d

org.eclipse.jgit.java7.test/pom.xml
org.eclipse.jgit.java7.test/src/org/eclipse/jgit/util/FSJava7Test.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/FileSnapshotTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java

index 6c0dd33bc0be71b5bfac5b87d77ebf78c9abb6bf..3641f59aef4f223b2431f5b42356c9001144f3cc 100644 (file)
       <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>
index d735bd3ce52d5554134b0b13453c4c00c1341184..4b5fe5979eeef4ece4d5769d35a48ede8cb0a3e2 100644 (file)
@@ -58,13 +58,13 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class FSJava7Test {
-
-       private final File trash = new File(new File("target"), "trash");
+       private File trash;
 
        @Before
        public void setUp() throws Exception {
-               FileUtils.delete(trash, FileUtils.RECURSIVE | FileUtils.RETRY | FileUtils.SKIP_MISSING);
-               assertTrue(trash.mkdirs());
+               trash = File.createTempFile("tmp_", "");
+               trash.delete();
+               assertTrue("mkdir " + trash, trash.mkdir());
        }
 
        @After
index 17c44dce8274e9389badd2670010f8f54717651d..902416bdfff9296fccf2f7c93f36651a7c01e93c 100644 (file)
@@ -61,7 +61,14 @@ public class FileSnapshotTest {
 
        private List<File> files = new ArrayList<File>();
 
-       private final File trash = new File(new File("target"), "trash");
+       private File trash;
+
+       @Before
+       public void setUp() throws Exception {
+               trash = File.createTempFile("tmp_", "");
+               trash.delete();
+               assertTrue("mkdir " + trash, trash.mkdir());
+       }
 
        @Before
        @After
index 31938b98b39bfe9e2ee373eaf2824ceb66c71407..ee845c5325787a06ffbed1fbc9e7a30207c76c53 100644 (file)
@@ -44,6 +44,7 @@ package org.eclipse.jgit.storage.file;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -55,6 +56,7 @@ import org.eclipse.jgit.util.FS;
 import org.eclipse.jgit.util.FileUtils;
 import org.eclipse.jgit.util.IO;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 public class FileBasedConfigTest {
@@ -73,7 +75,14 @@ public class FileBasedConfigTest {
        private static final String CONTENT2 = "[" + USER + "]\n\t" + NAME + " = "
                        + BOB + "\n";
 
-       private final File trash = new File(new File("target"), "trash");
+       private File trash;
+
+       @Before
+       public void setUp() throws Exception {
+               trash = File.createTempFile("tmp_", "");
+               trash.delete();
+               assertTrue("mkdir " + trash, trash.mkdir());
+       }
 
        @After
        public void tearDown() throws Exception {
index df39f2b9d80fd9e846cf59ebeab8515289e49751..7b1627854f11a73635a3e7e721f023c8cc70a8ba 100644 (file)
@@ -57,12 +57,13 @@ import org.junit.Before;
 import org.junit.Test;
 
 public class FileUtilTest {
-
-       private final File trash = new File(new File("target"), "trash");
+       private File trash;
 
        @Before
        public void setUp() throws Exception {
-               assertTrue(trash.mkdirs());
+               trash = File.createTempFile("tmp_", "");
+               trash.delete();
+               assertTrue("mkdir " + trash, trash.mkdir());
        }
 
        @After