Browse Source

Fix test configuration to run RacyGitTests, and fix testRacyGitDetection

With the filename suffix "Tests", the module was not included in tests
when building with Maven, and without the @Test annotations the tests
didn't get executed under Eclipse or buck test.

testRacyGitDetection was failing because the index file did not exist.

Add the missing configuration, the missing annotations, and add a call
to reset() in testRacyGitDetection to force creation of the index file.

Change-Id: I29dd8f89c36fef4ab40bedce7f4a26bd9b2390e4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.7
David Pursehouse 8 years ago
parent
commit
5e5fbb6035
  1. 4
      org.eclipse.jgit.test/pom.xml
  2. 12
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java

4
org.eclipse.jgit.test/pom.xml

@ -155,6 +155,10 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx256m -Dfile.encoding=UTF-8 -Djava.io.tmpdir=${project.build.directory}</argLine>
<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>
</plugins>

12
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java

@ -51,13 +51,16 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.TreeSet;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.FileTreeIteratorWithTimeControl;
import org.eclipse.jgit.treewalk.NameConflictTreeWalk;
import org.eclipse.jgit.util.FileUtils;
import org.junit.Test;
public class RacyGitTests extends RepositoryTestCase {
@Test
public void testIterator() throws IllegalStateException, IOException,
InterruptedException {
TreeSet<Long> modTimes = new TreeSet<>();
@ -121,11 +124,16 @@ public class RacyGitTests extends RepositoryTestCase {
}
}
public void testRacyGitDetection() throws IOException,
IllegalStateException, InterruptedException {
@Test
public void testRacyGitDetection() throws Exception {
TreeSet<Long> modTimes = new TreeSet<>();
File lastFile;
// Reset to force creation of index file
try (Git git = new Git(db)) {
git.reset().call();
}
// wait to ensure that modtimes of the file doesn't match last index
// file modtime
modTimes.add(valueOf(fsTick(db.getIndexFile())));

Loading…
Cancel
Save