You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2010/08/09 15:17:39 UTC
svn commit: r983632 - in /lucene/dev/trunk: lucene/
lucene/src/test/org/apache/lucene/util/ solr/
solr/contrib/dataimporthandler/ solr/contrib/extraction/
Author: rmuir
Date: Mon Aug 9 13:17:39 2010
New Revision: 983632
URL: http://svn.apache.org/viewvc?rev=983632&view=rev
Log:
SOLR-2002: add support for -Dtestmethod=xxx when running tests
Modified:
lucene/dev/trunk/lucene/common-build.xml
lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
lucene/dev/trunk/solr/build.xml
lucene/dev/trunk/solr/common-build.xml
lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml
lucene/dev/trunk/solr/contrib/extraction/build.xml
Modified: lucene/dev/trunk/lucene/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/common-build.xml?rev=983632&r1=983631&r2=983632&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/common-build.xml (original)
+++ lucene/dev/trunk/lucene/common-build.xml Mon Aug 9 13:17:39 2010
@@ -53,6 +53,7 @@
</path>
<!-- default arguments to pass to JVM executing tests -->
+ <property name="testmethod" value=""/>
<property name="args" value=""/>
<property name="threadsPerProcessor" value="1" />
<property name="random.multiplier" value="1" />
@@ -449,6 +450,8 @@
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
<sysproperty key="lucene.version" value="${dev.version}"/>
+
+ <sysproperty key="testmethod" value="${testmethod}"/>
<formatter type="xml"/>
<formatter classname="${junit.details.formatter}" usefile="false"/>
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=983632&r1=983631&r2=983632&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java Mon Aug 9 13:17:39 2010
@@ -30,6 +30,7 @@ import java.util.Collections;
import java.util.TimeZone;
import junit.framework.TestCase;
+import junit.framework.TestResult;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.index.ConcurrentMergeScheduler;
@@ -324,6 +325,14 @@ public abstract class LuceneTestCase ext
}
}
+
+ @Override
+ public void run(TestResult result) {
+ if (LuceneTestCaseJ4.TEST_METHOD == null ||
+ getName().equals(LuceneTestCaseJ4.TEST_METHOD))
+ super.run(result);
+ }
+
@Override
public void runBare() throws Throwable {
//long t0 = System.currentTimeMillis();
Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java?rev=983632&r1=983631&r2=983632&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java Mon Aug 9 13:17:39 2010
@@ -44,7 +44,13 @@ import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestWatchman;
+import org.junit.runner.Description;
+import org.junit.runner.RunWith;
+import org.junit.runner.manipulation.Filter;
+import org.junit.runner.manipulation.NoTestsRemainException;
+import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
+import org.junit.runners.model.InitializationError;
import java.io.File;
import java.io.PrintStream;
@@ -101,6 +107,7 @@ import static org.junit.Assert.fail;
// every test. But the functionality we used to
// get from that override is provided by InterceptTestCaseEvents
//@RunWith(RunBareWrapper.class)
+@RunWith(LuceneTestCaseJ4.LuceneTestCaseRunner.class)
public class LuceneTestCaseJ4 {
/**
@@ -114,9 +121,16 @@ public class LuceneTestCaseJ4 {
*/
public static final Version TEST_VERSION_CURRENT = Version.LUCENE_40;
+ /**
+ * If this is set, it is the only method that should run.
+ */
+ static final String TEST_METHOD;
+
/** Create indexes in this directory, optimally use a subdir, named after the test */
public static final File TEMP_DIR;
static {
+ String method = System.getProperty("testmethod", "").trim();
+ TEST_METHOD = method.length() == 0 ? null : method;
String s = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
if (s == null)
throw new RuntimeException("To run tests, you need to define system property 'tempDir' or 'java.io.tmpdir'.");
@@ -615,4 +629,27 @@ public class LuceneTestCaseJ4 {
private static final Random seedRnd = new Random();
private String name = "<unknown>";
+
+ /** optionally filters the tests to be run by TEST_METHOD */
+ public static class LuceneTestCaseRunner extends BlockJUnit4ClassRunner {
+ public LuceneTestCaseRunner(Class<?> clazz) throws InitializationError {
+ super(clazz);
+ Filter f = new Filter() {
+
+ @Override
+ public String describe() { return "filters according to TEST_METHOD"; }
+
+ @Override
+ public boolean shouldRun(Description d) {
+ return TEST_METHOD == null || d.getMethodName().equals(TEST_METHOD);
+ }
+ };
+
+ try {
+ f.apply(this);
+ } catch (NoTestsRemainException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
}
Modified: lucene/dev/trunk/solr/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/build.xml?rev=983632&r1=983631&r2=983632&view=diff
==============================================================================
--- lucene/dev/trunk/solr/build.xml (original)
+++ lucene/dev/trunk/solr/build.xml Mon Aug 9 13:17:39 2010
@@ -445,6 +445,7 @@
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
+ <sysproperty key="testmethod" value="${testmethod}"/>
<jvmarg line="${dir.prop}"/>
<jvmarg line="${args}"/>
Modified: lucene/dev/trunk/solr/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/common-build.xml?rev=983632&r1=983631&r2=983632&view=diff
==============================================================================
--- lucene/dev/trunk/solr/common-build.xml (original)
+++ lucene/dev/trunk/solr/common-build.xml Mon Aug 9 13:17:39 2010
@@ -109,6 +109,7 @@
<property name="build.javadoc.solrj" value="${build.docs}/api-solrj"/>
<!-- JUnit properties -->
+ <property name="testmethod" value=""/>
<property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
<property name="junit.output.dir" location="${common-solr.dir}/${dest}/test-results"/>
<property name="junit.reports" location="${common-solr.dir}/${dest}/test-results/reports"/>
Modified: lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml?rev=983632&r1=983631&r2=983632&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml (original)
+++ lucene/dev/trunk/solr/contrib/dataimporthandler/build.xml Mon Aug 9 13:17:39 2010
@@ -157,6 +157,7 @@
>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="${tempDir}"/>
+ <sysproperty key="testmethod" value="${testmethod}"/>
<formatter type="brief" usefile="false" if="junit.details"/>
<classpath refid="test.classpath"/>
<formatter type="xml"/>
@@ -204,6 +205,7 @@
>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="${tempDir}"/>
+ <sysproperty key="testmethod" value="${testmethod}"/>
<formatter type="brief" usefile="false" if="junit.details"/>
<classpath refid="test.extras.classpath"/>
<assertions>
Modified: lucene/dev/trunk/solr/contrib/extraction/build.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/extraction/build.xml?rev=983632&r1=983631&r2=983632&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/extraction/build.xml (original)
+++ lucene/dev/trunk/solr/contrib/extraction/build.xml Mon Aug 9 13:17:39 2010
@@ -105,6 +105,7 @@
>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="${tempDir}"/>
+ <sysproperty key="testmethod" value="${testmethod}"/>
<formatter type="brief" usefile="false" if="junit.details"/>
<classpath refid="test.classpath"/>
<assertions>