test fix: LuceneTestCase was reporting the wrong iter that failed

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1126022 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-05-22 16:08:36 +00:00
parent 3ec7abd684
commit 8441023719

View File

@ -66,6 +66,8 @@ import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.NoTestsRemainException;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
@ -1145,6 +1147,7 @@ public abstract class LuceneTestCase extends Assert {
* with one that returns null for getSequentialSubReaders.
*/
public static IndexSearcher newSearcher(IndexReader r, boolean maybeWrap) throws IOException {
if (random.nextBoolean()) {
if (maybeWrap && random.nextBoolean()) {
return new IndexSearcher(new SlowMultiReaderWrapper(r));
@ -1296,17 +1299,25 @@ public abstract class LuceneTestCase extends Assert {
}
// only print iteration info if the user requested more than one iterations
boolean verbose = VERBOSE && TEST_ITER > 1;
final boolean verbose = VERBOSE && TEST_ITER > 1;
final int currentIter[] = new int[1];
arg1.addListener(new RunListener() {
@Override
public void testFailure(Failure failure) throws Exception {
if (verbose) {
System.out.println("\nNOTE: iteration " + currentIter[0] + " failed! ");
}
}
});
for (int i = 0; i < TEST_ITER; i++) {
currentIter[0] = i;
if (verbose) {
System.out.println("\nNOTE: running iter=" + (1+i) + " of " + TEST_ITER);
}
super.runChild(arg0, arg1);
if (testsFailed) {
if (i >= TEST_ITER_MIN - 1) {
if (verbose) {
System.out.println("\nNOTE: iteration " + i + " failed !");
}
if (i >= TEST_ITER_MIN - 1) { // XXX is this still off-by-one?
break;
}
}