You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2013/04/30 20:49:13 UTC
svn commit: r1477775 - in
/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util:
LuceneTestCase.java TestRuleSetupAndRestoreClassEnv.java
Author: mikemccand
Date: Tue Apr 30 18:49:12 2013
New Revision: 1477775
URL: http://svn.apache.org/r1477775
Log:
also set IW's infoStream in LTC.newIndexWriterConfig, so we get a new messageID each time an IW is created when running verbose
Modified:
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1477775&r1=1477774&r2=1477775&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Tue Apr 30 18:49:12 2013
@@ -704,6 +704,16 @@ public abstract class LuceneTestCase ext
public static IndexWriterConfig newIndexWriterConfig(Random r, Version v, Analyzer a) {
IndexWriterConfig c = new IndexWriterConfig(v, a);
c.setSimilarity(classEnvRule.similarity);
+ if (VERBOSE) {
+ // Even though TestRuleSetupAndRestoreClassEnv calls
+ // InfoStream.setDefault, we do it again here so that
+ // the PrintStreamInfoStream.messageID increments so
+ // that when there are separate instances of
+ // IndexWriter created we see "IW 0", "IW 1", "IW 2",
+ // ... instead of just always "IW 0":
+ c.setInfoStream(new TestRuleSetupAndRestoreClassEnv.ThreadNameFixingPrintStreamInfoStream(System.out));
+ }
+
if (r.nextBoolean()) {
c.setMergeScheduler(new SerialMergeScheduler());
}
Modified: lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java?rev=1477775&r1=1477774&r2=1477775&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java (original)
+++ lucene/dev/trunk/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java Tue Apr 30 18:49:12 2013
@@ -17,6 +17,7 @@ package org.apache.lucene.util;
* limitations under the License.
*/
+import java.io.PrintStream;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
@@ -33,21 +34,17 @@ import org.apache.lucene.codecs.Postings
import org.apache.lucene.codecs.asserting.AssertingCodec;
import org.apache.lucene.codecs.cheapbastard.CheapBastardCodec;
import org.apache.lucene.codecs.compressing.CompressingCodec;
-import org.apache.lucene.codecs.lucene40.Lucene40Codec;
import org.apache.lucene.codecs.lucene40.Lucene40RWCodec;
import org.apache.lucene.codecs.lucene40.Lucene40RWPostingsFormat;
-import org.apache.lucene.codecs.lucene41.Lucene41Codec;
import org.apache.lucene.codecs.lucene41.Lucene41RWCodec;
import org.apache.lucene.codecs.lucene42.Lucene42Codec;
-import org.apache.lucene.codecs.mockrandom.MockRandomPostingsFormat;
import org.apache.lucene.codecs.simpletext.SimpleTextCodec;
import org.apache.lucene.index.RandomCodec;
import org.apache.lucene.search.RandomSimilarityProvider;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; // javadocs
import org.junit.internal.AssumptionViolatedException;
-
import com.carrotsearch.randomizedtesting.RandomizedContext;
import static org.apache.lucene.util.LuceneTestCase.*;
@@ -79,6 +76,25 @@ final class TestRuleSetupAndRestoreClass
*/
HashSet<String> avoidCodecs;
+ static class ThreadNameFixingPrintStreamInfoStream extends PrintStreamInfoStream {
+
+ public ThreadNameFixingPrintStreamInfoStream(PrintStream out) {
+ super(out);
+ }
+
+ @Override
+ public void message(String component, String message) {
+ final String name;
+ if (Thread.currentThread().getName().startsWith("TEST-")) {
+ // The name of the main thread is way too
+ // long when looking at IW verbose output...
+ name = "main";
+ } else {
+ name = Thread.currentThread().getName();
+ }
+ stream.println(component + " " + messageID + " [" + new Date() + "; " + name + "]: " + message);
+ }
+ }
@Override
protected void before() throws Exception {
@@ -111,20 +127,7 @@ final class TestRuleSetupAndRestoreClass
final Random random = RandomizedContext.current().getRandom();
final boolean v = random.nextBoolean();
if (INFOSTREAM) {
- InfoStream.setDefault(new PrintStreamInfoStream(System.out) {
- @Override
- public void message(String component, String message) {
- final String name;
- if (Thread.currentThread().getName().startsWith("TEST-")) {
- // The name of the main thread is way too
- // long when looking at IW verbose output...
- name = "main";
- } else {
- name = Thread.currentThread().getName();
- }
- stream.println(component + " " + messageID + " [" + new Date() + "; " + name + "]: " + message);
- }
- });
+ InfoStream.setDefault(new ThreadNameFixingPrintStreamInfoStream(System.out));
} else if (v) {
InfoStream.setDefault(new NullInfoStream());
}