lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1420941 - /lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java
Date Wed, 12 Dec 2012 20:03:52 GMT
Author: hossman
Date: Wed Dec 12 20:03:51 2012
New Revision: 1420941

URL: http://svn.apache.org/viewvc?rev=1420941&view=rev
Log:
LUCENE-4618: fix test to not be so lucky about avoiding failures when we actually want them

Modified:
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java?rev=1420941&r1=1420940&r2=1420941&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java
(original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/util/TestMaxFailuresRule.java
Wed Dec 12 20:03:51 2012
@@ -45,9 +45,22 @@ public class TestMaxFailuresRule extends
   }
 
   public static class Nested extends WithNestedTests.AbstractNestedTest {
-    @Repeat(iterations = 500)
+    public static final int TOTAL_ITERS = 500;
+    public static final int DESIRED_FAILURES = TOTAL_ITERS / 10;
+    private int numFails = 0;
+    private int numIters = 0;
+
+    @Repeat(iterations = TOTAL_ITERS)
     public void testFailSometimes() {
-      assertFalse(random().nextInt(5) == 0);
+      numIters++;
+      boolean fail = random().nextInt(5) == 0;
+      if (fail) numFails++;
+      // some seeds are really lucky ... so cheat.
+      if (numFails < DESIRED_FAILURES && 
+          DESIRED_FAILURES <= TOTAL_ITERS - numIters) {
+        fail = true;
+      }
+      assertFalse(fail);
     }
   }
 
@@ -95,6 +108,7 @@ public class TestMaxFailuresRule extends
       // resulting from ignored tests.
       Assert.assertTrue(results.toString(), 
           results.toString().matches("(S*F){2}A+"));
+
     } finally {
       LuceneTestCase.ignoreAfterMaxFailures.maxFailures = maxFailures;
       LuceneTestCase.ignoreAfterMaxFailures.failuresSoFar = failuresSoFar;



Mime
View raw message