Index: lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java =================================================================== --- lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java (revision 1023250) +++ lucene/src/test/org/apache/lucene/index/TestLazyProxSkipping.java (working copy) @@ -34,7 +34,6 @@ import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.BytesRef; -import static org.junit.Assume.*; /** * Tests lazy skipping on the proximity file. @@ -121,7 +120,7 @@ } public void testLazySkipping() throws IOException { - assumeTrue(!CodecProvider.getDefaultCodec().equals("SimpleText")); + assumeFalse("This test cannot run with SimpleText codec", CodecProvider.getDefaultCodec().equals("SimpleText")); // test whether only the minimum amount of seeks() // are performed performTest(5); Index: lucene/src/test/org/apache/lucene/util/LuceneTestCase.java =================================================================== --- lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (revision 1023250) +++ lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (working copy) @@ -42,6 +42,7 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.MockDirectoryWrapper; import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; +import org.junit.Assume; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -65,6 +66,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.io.PrintWriter; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -351,8 +353,16 @@ // org.junit.internal.AssumptionViolatedException in older releases // org.junit.Assume.AssumptionViolatedException in recent ones if (e.getClass().getName().endsWith("AssumptionViolatedException")) { - System.err.println("NOTE: " + method.getName() + " Assume failed (ignored):"); - e.printStackTrace(); + if (e.getCause() instanceof TestIgnoredException) + e = e.getCause(); + System.err.print("NOTE: Assume failed in '" + method.getName() + "' (ignored):"); + if (VERBOSE) { + System.err.println(); + e.printStackTrace(System.err); + } else { + System.err.print(" "); + System.err.println(e.getMessage()); + } } else { testsFailed = true; reportAdditionalFailureInfo(); @@ -373,7 +383,7 @@ public void setUp() throws Exception { seed = "random".equals(TEST_SEED) ? seedRand.nextLong() : TwoLongs.fromString(TEST_SEED).l2; random.setSeed(seed); - Assert.assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup); + assertFalse("ensure your tearDown() calls super.tearDown()!!!", setup); setup = true; savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @@ -410,7 +420,7 @@ @After public void tearDown() throws Exception { - Assert.assertTrue("ensure your setUp() calls super.setUp()!!!", setup); + assertTrue("ensure your setUp() calls super.setUp()!!!", setup); setup = false; BooleanQuery.setMaxClauseCount(savedBoolMaxClauseCount); try { @@ -515,7 +525,64 @@ static public void assertEquals(String message, float expected, float actual) { assertEquals(message, Float.valueOf(expected), Float.valueOf(actual)); } + + // Replacement for Assume jUnit class, so we can add a messge with explanation: + + private static final class TestIgnoredException extends RuntimeException { + TestIgnoredException(String msg) { + super(msg); + } + + TestIgnoredException(String msg, Throwable t) { + super(msg, t); + } + + @Override + public String getMessage() { + StringBuilder sb = new StringBuilder(super.getMessage()); + if (getCause() != null) + sb.append(" - ").append(getCause()); + return sb.toString(); + } + + @Override + public void printStackTrace(PrintStream s) { + if (getCause() != null) { + s.println(toString() + " - Caused by:"); + getCause().printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + @Override + public void printStackTrace(PrintWriter s) { + if (getCause() != null) { + s.println(toString() + " - Caused by:"); + getCause().printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + @Override + public void printStackTrace() { + printStackTrace(System.err); + } + } + + public static void assumeTrue(String msg, boolean b) { + Assume.assumeNoException(b ? null : new TestIgnoredException(msg)); + } + public static void assumeFalse(String msg, boolean b) { + assumeTrue(msg, !b); + } + + public static void assumeNoException(String msg, Exception e) { + Assume.assumeNoException(e == null ? null : new TestIgnoredException(msg, e)); + } + /** * Convinience method for logging an iterator. * @@ -792,16 +859,14 @@ protected List computeTestMethods() { if (testMethods != null) return testMethods; - // check if the current test's class has methods annotated with @Ignore - final Class clazz = getTestClass().getJavaClass(); - for (Method m : clazz.getMethods()) { - Ignore ignored = m.getAnnotation(Ignore.class); + testMethods = getTestClass().getAnnotatedMethods(Test.class); + for (Method m : getTestClass().getJavaClass().getMethods()) { + // check if the current test's class has methods annotated with @Ignore + final Ignore ignored = m.getAnnotation(Ignore.class); if (ignored != null) { - System.err.println("NOTE: Ignoring test method '" + m.getName() + "' " + ignored.value()); + System.err.println("NOTE: Ignoring test method '" + m.getName() + "': " + ignored.value()); } - } - testMethods = getTestClass().getAnnotatedMethods(Test.class); - for (Method m : getTestClass().getJavaClass().getMethods()) { + // add methods starting with "test" final int mod = m.getModifiers(); if (m.getName().startsWith("test") && m.getAnnotation(Test.class) == null &&