Apache Lucene open-source search software
in tests, remove RegExp.toString abuse causing hudson fail, for example negated character classes are parsed as intersections but we have RegExp.INTERSECTION disabled in the test
Robert Muir8b7abe6f1c69
diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.javaindex bce9eedb061..774bcf26ed2 100644--- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java+++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java@@ -138,7 +138,7 @@ public class TestRegexpRandom2 extends LuceneTestCase {String codec = CodecProvider.getDefaultCodec();int num = codec.equals("PreFlex") ? 100 * RANDOM_MULTIPLIER : 1000 * RANDOM_MULTIPLIER;for (int i = 0; i < num; i++) {- String reg = AutomatonTestUtil.randomRegexp(random).toString();+ String reg = AutomatonTestUtil.randomRegexp(random);assertSame(reg);}}diff --git a/lucene/src/test/org/apache/lucene/util/automaton/AutomatonTestUtil.java b/lucene/src/test/org/apache/lucene/util/automaton/AutomatonTestUtil.javaindex a13ebd5939e..1886869058e 100644--- a/lucene/src/test/org/apache/lucene/util/automaton/AutomatonTestUtil.java+++ b/lucene/src/test/org/apache/lucene/util/automaton/AutomatonTestUtil.java@@ -33,16 +33,15 @@ import org.apache.lucene.util._TestUtil;public class AutomatonTestUtil {/** Returns random string, including full unicode range. */- public static RegExp randomRegexp(Random r) {+ public static String randomRegexp(Random r) {while (true) {String regexp = randomRegexpString(r);// we will also generate some undefined unicode queriesif (!UnicodeUtil.validUTF16String(regexp))continue;try {- // NOTE: we parse-tostring-parse again, because we are- // really abusing RegExp.toString() here (its just for debugging)- return new RegExp(new RegExp(regexp, RegExp.NONE).toString(), RegExp.NONE);+ new RegExp(regexp, RegExp.NONE);+ return regexp;} catch (Exception e) {}}}@@ -254,11 +253,11 @@ public class AutomatonTestUtil {/** return a random NFA/DFA for testing */public static Automaton randomAutomaton(Random random) {// get two random Automata from regexps- Automaton a1 = AutomatonTestUtil.randomRegexp(random).toAutomaton();+ Automaton a1 = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton();if (random.nextBoolean())a1 = BasicOperations.complement(a1);- Automaton a2 = AutomatonTestUtil.randomRegexp(random).toAutomaton();+ Automaton a2 = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton();if (random.nextBoolean())a2 = BasicOperations.complement(a2);diff --git a/lucene/src/test/org/apache/lucene/util/automaton/TestBasicOperations.java b/lucene/src/test/org/apache/lucene/util/automaton/TestBasicOperations.javaindex 65d3c23ffea..8fcd2e5f36d 100644--- a/lucene/src/test/org/apache/lucene/util/automaton/TestBasicOperations.java+++ b/lucene/src/test/org/apache/lucene/util/automaton/TestBasicOperations.java@@ -94,7 +94,7 @@ public class TestBasicOperations extends LuceneTestCase {final int ITER2 = 100 * RANDOM_MULTIPLIER;for(int i=0;i<ITER1;i++) {- final RegExp re = AutomatonTestUtil.randomRegexp(random);+ final RegExp re = new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE);final Automaton a = re.toAutomaton();assertFalse(BasicOperations.isEmpty(a));diff --git a/lucene/src/test/org/apache/lucene/util/automaton/TestDeterminism.java b/lucene/src/test/org/apache/lucene/util/automaton/TestDeterminism.javaindex baee909cbfa..f1c89abd939 100644--- a/lucene/src/test/org/apache/lucene/util/automaton/TestDeterminism.java+++ b/lucene/src/test/org/apache/lucene/util/automaton/TestDeterminism.java@@ -29,7 +29,7 @@ public class TestDeterminism extends LuceneTestCase {public void testRegexps() throws Exception {int num = 500 * RANDOM_MULTIPLIER;for (int i = 0; i < num; i++)- assertAutomaton(AutomatonTestUtil.randomRegexp(random).toAutomaton());+ assertAutomaton(new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton());}/** test against a simple, unoptimized det */diff --git a/lucene/src/test/org/apache/lucene/util/automaton/TestUTF32ToUTF8.java b/lucene/src/test/org/apache/lucene/util/automaton/TestUTF32ToUTF8.javaindex cd9a2f5b8b5..2d46df447d6 100644--- a/lucene/src/test/org/apache/lucene/util/automaton/TestUTF32ToUTF8.java+++ b/lucene/src/test/org/apache/lucene/util/automaton/TestUTF32ToUTF8.java@@ -204,7 +204,7 @@ public class TestUTF32ToUTF8 extends LuceneTestCase {public void testRandomRegexes() throws Exception {int num = 250 * RANDOM_MULTIPLIER;for (int i = 0; i < num; i++) {- assertAutomaton(AutomatonTestUtil.randomRegexp(random).toAutomaton());+ assertAutomaton(new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE).toAutomaton());}}