add support for -Dtests.codec=random... all core tests pass with this

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/preflexfixes@967177 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-07-23 17:33:26 +00:00
parent 68fe4bfc74
commit 9098d7ea17
2 changed files with 17 additions and 1 deletions

View File

@ -35,6 +35,7 @@ import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.CacheEntry;
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.index.codecs.preflex.PreFlexCodec;
import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
/**
@ -117,6 +118,8 @@ public abstract class LuceneTestCase extends TestCase {
savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount();
savedDefaultCodec = CodecProvider.getDefaultCodec();
codec = _TestUtil.getTestCodec();
if (codec.equals("random"))
codec = CodecProvider.CORE_CODECS[seedRnd.nextInt(CodecProvider.CORE_CODECS.length)];
//nocommit
if (codec.equals("PreFlex")) {
CodecProvider.getDefault().register(new PreFlexRWCodec());
@ -150,6 +153,7 @@ public abstract class LuceneTestCase extends TestCase {
// nocommit
if (codec.equals("PreFlex")) {
CodecProvider.getDefault().unregister(new PreFlexRWCodec());
CodecProvider.getDefault().register(new PreFlexCodec());
}
CodecProvider.setDefaultCodec(savedDefaultCodec);
@ -301,6 +305,9 @@ public abstract class LuceneTestCase extends TestCase {
seed = null;
super.runBare();
} catch (Throwable e) {
if (_TestUtil.getTestCodec().equals("random")) {
System.out.println("NOTE: random codec of testcase '" + getName() + "' was: " + codec);
}
if (seed != null) {
System.out.println("NOTE: random seed of testcase '" + getName() + "' was: " + seed);
}

View File

@ -23,6 +23,7 @@ import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.CacheEntry;
import org.apache.lucene.util.FieldCacheSanityChecker.Insanity;
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.index.codecs.preflex.PreFlexCodec;
import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
import org.junit.After;
@ -140,6 +141,8 @@ public class LuceneTestCaseJ4 {
public static void beforeClassLuceneTestCaseJ4() {
savedDefaultCodec = CodecProvider.getDefaultCodec();
codec = _TestUtil.getTestCodec();
if (codec.equals("random"))
codec = CodecProvider.CORE_CODECS[seedRnd.nextInt(CodecProvider.CORE_CODECS.length)];
//nocommit
if (codec.equals("PreFlex")) {
CodecProvider.getDefault().register(new PreFlexRWCodec());
@ -150,8 +153,10 @@ public class LuceneTestCaseJ4 {
@AfterClass
public static void afterClassLuceneTestCaseJ4() {
//nocommit
if (codec.equals("PreFlex"))
if (codec.equals("PreFlex")) {
CodecProvider.getDefault().unregister(new PreFlexRWCodec());
CodecProvider.getDefault().register(new PreFlexCodec());
}
CodecProvider.setDefaultCodec(savedDefaultCodec);
}
@ -420,6 +425,10 @@ public class LuceneTestCaseJ4 {
System.out.println("NOTE: random static seed of testclass '" + getName() + "' was: " + staticSeed);
}
if (_TestUtil.getTestCodec().equals("random")) {
System.out.println("NOTE: random codec of testcase '" + getName() + "' was: " + codec);
}
if (seed != null) {
System.out.println("NOTE: random seed of testcase '" + getName() + "' was: " + seed);
}