You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/12/26 17:20:27 UTC

[lucene] branch branch_9x updated: LUCENE-10338: Scan for tests only by convention file name pattern (#565)

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new aab0413  LUCENE-10338: Scan for tests only by convention file name pattern (#565)
aab0413 is described below

commit aab0413b5700a833339e2532a700d1bd29c19282
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Sun Dec 26 18:18:24 2021 +0100

    LUCENE-10338: Scan for tests only by convention file name pattern (#565)
---
 gradle/testing/defaults-tests.gradle                               | 7 +++++++
 .../query/{TestBooleanQuery.java => BooleanQueryTestFacade.java}   | 4 ++--
 .../{TestExceptionQuery.java => ExceptionQueryTestFacade.java}     | 6 +++---
 .../apache/lucene/queryparser/surround/query/Test01Exceptions.java | 2 +-
 .../apache/lucene/queryparser/surround/query/Test02Boolean.java    | 4 ++--
 .../apache/lucene/queryparser/surround/query/Test03Distance.java   | 6 +++---
 6 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/gradle/testing/defaults-tests.gradle b/gradle/testing/defaults-tests.gradle
index a6d59ee..f497133 100644
--- a/gradle/testing/defaults-tests.gradle
+++ b/gradle/testing/defaults-tests.gradle
@@ -161,6 +161,13 @@ allprojects {
         showStandardStreams false
       }
 
+      // Disable automatic test class detection, rely on class names only. This is needed for testing
+      // against JDKs where the bytecode is unparseable by Gradle, for example.
+      // We require all tests to start with Test*, this simplifies include patterns greatly.
+      scanForTestClasses = false
+      include '**/Test*.class'
+      exclude '**/*$*'
+
       // Set up custom test output handler.
       doFirst {
         project.delete testOutputsDir
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/TestBooleanQuery.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTestFacade.java
similarity index 98%
rename from lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/TestBooleanQuery.java
rename to lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTestFacade.java
index 25c848e..2e0e191 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/TestBooleanQuery.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTestFacade.java
@@ -28,7 +28,7 @@ import org.apache.lucene.search.ScoreMode;
 import org.apache.lucene.search.SimpleCollector;
 import org.junit.Assert;
 
-public class TestBooleanQuery {
+public class BooleanQueryTestFacade {
   String queryText;
   final int[] expectedDocNrs;
   SingleFieldTestDb dBase;
@@ -37,7 +37,7 @@ public class TestBooleanQuery {
   BasicQueryFactory qf;
   boolean verbose = true;
 
-  public TestBooleanQuery(
+  public BooleanQueryTestFacade(
       String queryText,
       int[] expectedDocNrs,
       SingleFieldTestDb dBase,
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/TestExceptionQuery.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/ExceptionQueryTestFacade.java
similarity index 90%
rename from lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/TestExceptionQuery.java
rename to lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/ExceptionQueryTestFacade.java
index 18574c3..2154496 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/TestExceptionQuery.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/ExceptionQueryTestFacade.java
@@ -19,11 +19,11 @@ package org.apache.lucene.queryparser.surround.query;
 import org.apache.lucene.queryparser.surround.parser.ParseException;
 import org.apache.lucene.queryparser.surround.parser.QueryParser;
 
-public class TestExceptionQuery {
+public class ExceptionQueryTestFacade {
   private String queryText;
   private boolean verbose;
 
-  public TestExceptionQuery(String queryText, boolean verbose) {
+  public ExceptionQueryTestFacade(String queryText, boolean verbose) {
     this.queryText = queryText;
     this.verbose = verbose;
   }
@@ -53,7 +53,7 @@ public class TestExceptionQuery {
   public static String getFailQueries(String[] exceptionQueries, boolean verbose) {
     StringBuilder failQueries = new StringBuilder();
     for (int i = 0; i < exceptionQueries.length; i++) {
-      new TestExceptionQuery(exceptionQueries[i], verbose).doTest(failQueries);
+      new ExceptionQueryTestFacade(exceptionQueries[i], verbose).doTest(failQueries);
     }
     return failQueries.toString();
   }
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test01Exceptions.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test01Exceptions.java
index 75f751e..08d476a 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test01Exceptions.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test01Exceptions.java
@@ -57,7 +57,7 @@ public class Test01Exceptions extends LuceneTestCase {
   };
 
   public void test01Exceptions() throws Exception {
-    String m = TestExceptionQuery.getFailQueries(exceptionQueries, verbose);
+    String m = ExceptionQueryTestFacade.getFailQueries(exceptionQueries, verbose);
     if (m.length() > 0) {
       fail("No ParseException for:\n" + m);
     }
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test02Boolean.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test02Boolean.java
index 1a726ec..e796837 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test02Boolean.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test02Boolean.java
@@ -46,8 +46,8 @@ public class Test02Boolean extends LuceneTestCase {
   SingleFieldTestDb db1;
 
   public void normalTest1(String query, int[] expdnrs) throws Exception {
-    TestBooleanQuery tbq =
-        new TestBooleanQuery(
+    BooleanQueryTestFacade tbq =
+        new BooleanQueryTestFacade(
             query, expdnrs, db1, fieldName, this, new BasicQueryFactory(maxBasicQueries));
     tbq.setVerbose(verbose);
     tbq.doTest();
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test03Distance.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test03Distance.java
index 16f02a2..1a76f7b 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test03Distance.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/Test03Distance.java
@@ -41,7 +41,7 @@ public class Test03Distance extends LuceneTestCase {
   };
 
   public void test00Exceptions() throws Exception {
-    String m = TestExceptionQuery.getFailQueries(exceptionQueries, verbose);
+    String m = ExceptionQueryTestFacade.getFailQueries(exceptionQueries, verbose);
     if (m.length() > 0) {
       fail("No ParseException for:\n" + m);
     }
@@ -68,8 +68,8 @@ public class Test03Distance extends LuceneTestCase {
   }
 
   private void distanceTst(String query, int[] expdnrs, SingleFieldTestDb db) throws Exception {
-    TestBooleanQuery tbq =
-        new TestBooleanQuery(
+    BooleanQueryTestFacade tbq =
+        new BooleanQueryTestFacade(
             query, expdnrs, db, fieldName, this, new BasicQueryFactory(maxBasicQueries));
     tbq.setVerbose(verbose);
     tbq.doTest();