From fb57fd149ac76bd63714eaade1b335ea2237ab68 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Sat, 16 Oct 2010 11:27:54 +0000 Subject: [PATCH] LUCENE-2710: reproduce-with on test failure isnt right if you manually override things git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1023250 13f79535-47bb-0310-9956-ffa450edef68 --- lucene/src/test/org/apache/lucene/TestDemo.java | 2 +- .../org/apache/lucene/util/LuceneTestCase.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lucene/src/test/org/apache/lucene/TestDemo.java b/lucene/src/test/org/apache/lucene/TestDemo.java index b865efb17ca..9ae2329c7ea 100644 --- a/lucene/src/test/org/apache/lucene/TestDemo.java +++ b/lucene/src/test/org/apache/lucene/TestDemo.java @@ -43,7 +43,7 @@ import org.apache.lucene.util.LuceneTestCase; public class TestDemo extends LuceneTestCase { public void testDemo() throws IOException, ParseException { - + fail(); Analyzer analyzer = new MockAnalyzer(); // Store the index in memory: diff --git a/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java index 92590b5bdfc..21ebe8f63a8 100644 --- a/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java @@ -759,7 +759,19 @@ public abstract class LuceneTestCase extends Assert { // We get here from InterceptTestCaseEvents on the 'failed' event.... public void reportAdditionalFailureInfo() { System.out.println("NOTE: reproduce with: ant test -Dtestcase=" + getClass().getSimpleName() - + " -Dtestmethod=" + getName() + " -Dtests.seed=" + new TwoLongs(staticSeed, seed)); + + " -Dtestmethod=" + getName() + " -Dtests.seed=" + new TwoLongs(staticSeed, seed) + + reproduceWithExtraParams()); + } + + // extra params that were overridden needed to reproduce the command + private String reproduceWithExtraParams() { + StringBuilder sb = new StringBuilder(); + if (!TEST_CODEC.equals("random")) sb.append(" -Dtests.codec=").append(TEST_CODEC); + if (!TEST_LOCALE.equals("random")) sb.append(" -Dtests.locale=").append(TEST_LOCALE); + if (!TEST_TIMEZONE.equals("random")) sb.append(" -Dtests.timezone=").append(TEST_TIMEZONE); + if (!TEST_DIRECTORY.equals("random")) sb.append(" -Dtests.directory=").append(TEST_DIRECTORY); + if (RANDOM_MULTIPLIER > 1) sb.append(" -Dtests.multiplier=").append(RANDOM_MULTIPLIER); + return sb.toString(); } // recorded seed: for beforeClass