jenkins-bot has submitted this change and it was merged.

Change subject: Fix randomized test failure
......................................................................


Fix randomized test failure

We have a test that asserts that compiling automata doesn't fail in unexpected
way but it never covered one of the ways in which they are expected to
sometimes fail. Now it does.

Change-Id: I91616428c786d5dc9adfae4c9e63367b68c64b25
---
M src/test/java/org/wikimedia/search/extra/regex/ngram/NGramAutomatonTest.java
1 file changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Jdouglas: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/src/test/java/org/wikimedia/search/extra/regex/ngram/NGramAutomatonTest.java 
b/src/test/java/org/wikimedia/search/extra/regex/ngram/NGramAutomatonTest.java
index 00f8237..423098e 100644
--- 
a/src/test/java/org/wikimedia/search/extra/regex/ngram/NGramAutomatonTest.java
+++ 
b/src/test/java/org/wikimedia/search/extra/regex/ngram/NGramAutomatonTest.java
@@ -208,10 +208,20 @@
         assertTrigramExpression(str, null);
     }
 
+    /**
+     * Tests that building the automaton doesn't blow up in unexpected ways.
+     */
     @Test
     @Repeat(iterations=100)
     public void randomAutomaton() {
-        NGramAutomaton ngramAutomaton = new 
NGramAutomaton(XAutomatonTestUtil.randomAutomaton(getRandom()), between(2, 7), 
4, 10000, 500);
+        XAutomaton automaton = XAutomatonTestUtil.randomAutomaton(getRandom());
+        NGramAutomaton ngramAutomaton;
+        try {
+            ngramAutomaton = new NGramAutomaton(automaton, between(2, 7), 4, 
10000, 500);
+        } catch (AutomatonTooComplexException e) {
+            // This is fine - some automata are genuinely too complex to 
ngramify.
+            return;
+        }
         Expression<String> expression = ngramAutomaton.expression();
         expression = expression.simplify();
     }

-- 
To view, visit https://gerrit.wikimedia.org/r/215915
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I91616428c786d5dc9adfae4c9e63367b68c64b25
Gerrit-PatchSet: 1
Gerrit-Project: search/extra
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Jdouglas <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to