From 9f7a1873921c4aa2360ffa96a980b5bbf1a6e838 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Sat, 13 Mar 2010 11:05:13 +0000 Subject: [PATCH] LUCENE-2313: Add VERBOSE flag to LuceneTestCase(J4) git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@922525 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 5 +++++ .../lucene/benchmark/quality/TestQualityRun.java | 11 ++++------- src/test/org/apache/lucene/util/LuceneTestCase.java | 6 ++++++ src/test/org/apache/lucene/util/LuceneTestCaseJ4.java | 6 ++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index fe1d87e5db8..4402cbc295a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -244,6 +244,11 @@ Test Cases from LuceneTestCase(J4), that contains the release version. (Uwe Schindler, Simon Willnauer, Shai Erera) +* LUCENE-2313: Add VERBOSE to LuceneTestCase(J4) to control verbosity + of tests. If VERBOSE==false (default) tests should not print anything + other than errors to System.(out|err). The setting can be changed with + -Dtests.verbose=true on test invokation. (Shai Erera via Uwe Schindler) + ================== Release 2.9.2 / 3.0.1 2010-02-26 ==================== Changes in backwards compatibility policy diff --git a/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java b/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java index 2baa70e900e..7bc4af2b380 100644 --- a/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java +++ b/contrib/benchmark/src/test/org/apache/lucene/benchmark/quality/TestQualityRun.java @@ -35,8 +35,7 @@ import org.apache.lucene.benchmark.quality.utils.SimpleQQParser; import org.apache.lucene.benchmark.quality.utils.SubmissionReport; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.FSDirectory; - -import junit.framework.TestCase; +import org.apache.lucene.util.LuceneTestCase; /** * Test that quality run does its job. @@ -45,9 +44,7 @@ import junit.framework.TestCase; * this test will not work correctly, as it does not dynamically * generate its test trec topics/qrels! */ -public class TestQualityRun extends TestCase { - - private static boolean DEBUG = Boolean.getBoolean("tests.verbose"); +public class TestQualityRun extends LuceneTestCase { public TestQualityRun(String name) { super(name); @@ -63,7 +60,7 @@ public class TestQualityRun extends TestCase { int maxResults = 1000; String docNameField = "doctitle"; // orig docID is in the linedoc format title - PrintWriter logger = DEBUG ? new PrintWriter(System.out,true) : null; + PrintWriter logger = VERBOSE ? new PrintWriter(System.out,true) : null; // for topics/qrels files - src/test/org/apache/lucene/benchmark/quality File srcTestDir = new File(new File(new File(new File(new File( @@ -89,7 +86,7 @@ public class TestQualityRun extends TestCase { QualityQueryParser qqParser = new SimpleQQParser("title","body"); QualityBenchmark qrun = new QualityBenchmark(qqs, qqParser, searcher, docNameField); - SubmissionReport submitLog = DEBUG ? new SubmissionReport(logger, "TestRun") : null; + SubmissionReport submitLog = VERBOSE ? new SubmissionReport(logger, "TestRun") : null; qrun.setMaxResults(maxResults); QualityStats stats[] = qrun.execute(judge, submitLog, logger); diff --git a/src/test/org/apache/lucene/util/LuceneTestCase.java b/src/test/org/apache/lucene/util/LuceneTestCase.java index 0b3cdd6744e..f6aa79b2aea 100644 --- a/src/test/org/apache/lucene/util/LuceneTestCase.java +++ b/src/test/org/apache/lucene/util/LuceneTestCase.java @@ -54,6 +54,12 @@ import org.apache.lucene.util.FieldCacheSanityChecker.Insanity; */ public abstract class LuceneTestCase extends TestCase { + /** + * true iff tests are run in verbose mode. Note: if it is false, tests are not + * expected to print any messages. + */ + public static final boolean VERBOSE = LuceneTestCaseJ4.VERBOSE; + public static final Version TEST_VERSION_CURRENT = LuceneTestCaseJ4.TEST_VERSION_CURRENT; private int savedBoolMaxClauseCount; diff --git a/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java b/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java index ade98dc0838..b109e779b8e 100644 --- a/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java +++ b/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java @@ -77,6 +77,12 @@ import static org.junit.Assert.fail; //@RunWith(RunBareWrapper.class) public class LuceneTestCaseJ4 { + /** + * true iff tests are run in verbose mode. Note: if it is false, tests are not + * expected to print any messages. + */ + public static final boolean VERBOSE = Boolean.getBoolean("tests.verbose"); + /** Change this when development starts for new Lucene version: */ public static final Version TEST_VERSION_CURRENT = Version.LUCENE_31;