From 5e5fbb6035b4bcee6717d8a7417e8f8905d1b563 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Sun, 19 Mar 2017 10:23:29 +0900 Subject: [PATCH] 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 --- org.eclipse.jgit.test/pom.xml | 4 ++++ .../tst/org/eclipse/jgit/lib/RacyGitTests.java | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/org.eclipse.jgit.test/pom.xml b/org.eclipse.jgit.test/pom.xml index 266cc53a9..f57323f46 100644 --- a/org.eclipse.jgit.test/pom.xml +++ b/org.eclipse.jgit.test/pom.xml @@ -155,6 +155,10 @@ maven-surefire-plugin -Xmx256m -Dfile.encoding=UTF-8 -Djava.io.tmpdir=${project.build.directory} + + **/*Test.java + **/*Tests.java + diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java index 2da144c87..9236b4e82 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java +++ b/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 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 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())));