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
This commit is contained in:
Uwe Schindler 2010-03-13 11:05:13 +00:00
parent 24d4565049
commit 9f7a187392
4 changed files with 21 additions and 7 deletions

View File

@ -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

View File

@ -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;
// <tests src dir> 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);

View File

@ -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;

View File

@ -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;