Apache Lucene open-source search software
LUCENE-3002: Add tests.iter.min to control tests.iter's behavior
Shai Ereraa4c7a8883469
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 448f11b0707..0221b958c3f 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -337,7 +337,6 @@ New features* LUCENE-3001: Added TrieFieldHelper to write solr compatible numericfields without the solr dependency. (ryan)-Optimizations* LUCENE-2588: Don't store unnecessary suffixes when writing the terms@@ -374,6 +373,12 @@ Bug fixesindexes, causing existing deletions to be applied on the incoming indexes aswell. (Shai Erera, Mike McCandless)+Test Cases++* LUCENE-3002: added 'tests.iter.min' to control 'tests.iter' by allowing to+ stop iterating if at least 'tests.iter.min' ran and a failure occured.+ (Shai Erera, Chris Hostetter)+======================= Lucene 3.x (not yet released) =======================Changes in backwards compatibility policydiff --git a/lucene/common-build.xml b/lucene/common-build.xmlindex 38327fec496..7415bbcd916 100644--- a/lucene/common-build.xml+++ b/lucene/common-build.xml@@ -78,6 +78,7 @@<property name="tests.directory" value="random" /><property name="tests.linedocsfile" value="europarl.lines.txt.gz" /><property name="tests.iter" value="1" />+ <property name="tests.iter.min" value="${tests.iter}" /><property name="tests.seed" value="random" /><property name="tests.loggingfile" value="/dev/null"/><property name="tests.nightly" value="false" />@@ -507,6 +508,8 @@<sysproperty key="tests.linedocsfile" value="${tests.linedocsfile}"/><!-- set the number of times tests should run --><sysproperty key="tests.iter" value="${tests.iter}"/>+ <!-- set the minimum number of times tests should run unless failure -->+ <sysproperty key="tests.iter.min" value="${tests.iter.min}"/><!-- set the test seed --><sysproperty key="tests.seed" value="${tests.seed}"/><!-- set the Version that tests should run against -->diff --git a/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.javaindex b56aaf2e4d5..65f731f005f 100644--- a/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java+++ b/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java@@ -142,6 +142,8 @@ public abstract class LuceneTestCase extends Assert {public static final String TEST_DIRECTORY = System.getProperty("tests.directory", "random");/** Get the number of times to run tests */public static final int TEST_ITER = Integer.parseInt(System.getProperty("tests.iter", "1"));+ /** Get the minimum number of times to run tests until a failure happens */+ public static final int TEST_ITER_MIN = Integer.parseInt(System.getProperty("tests.iter.min", Integer.toString(TEST_ITER)));/** Get the random seed for tests */public static final String TEST_SEED = System.getProperty("tests.seed", "random");/** whether or not nightly tests should run */@@ -1208,11 +1210,24 @@ public abstract class LuceneTestCase extends Assert {if (VERBOSE) {System.out.println("\nNOTE: running test " + arg0.getName());}++ // only print iteration info if the user requested more than one iterations+ boolean verbose = VERBOSE && TEST_ITER > 1;+ int lastIterFailed = -1;for (int i = 0; i < TEST_ITER; i++) {- if (VERBOSE && TEST_ITER > 1) {+ if (verbose) {System.out.println("\nNOTE: running iter=" + (1+i) + " of " + TEST_ITER);}super.runChild(arg0, arg1);+ if (testsFailed) {+ lastIterFailed = i;+ if (i == TEST_ITER_MIN - 1) {+ if (verbose) {+ System.out.println("\nNOTE: iteration " + lastIterFailed + " failed !");+ }+ break;+ }+ }}}