mirror of https://github.com/apache/lucene.git
SOLR-2002: add support for -Dtestmethod=xxx when running tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@983632 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9d71710beb
commit
40a3eb4fd3
|
@ -53,6 +53,7 @@
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<!-- default arguments to pass to JVM executing tests -->
|
<!-- default arguments to pass to JVM executing tests -->
|
||||||
|
<property name="testmethod" value=""/>
|
||||||
<property name="args" value=""/>
|
<property name="args" value=""/>
|
||||||
<property name="threadsPerProcessor" value="1" />
|
<property name="threadsPerProcessor" value="1" />
|
||||||
<property name="random.multiplier" value="1" />
|
<property name="random.multiplier" value="1" />
|
||||||
|
@ -450,6 +451,8 @@
|
||||||
|
|
||||||
<sysproperty key="lucene.version" value="${dev.version}"/>
|
<sysproperty key="lucene.version" value="${dev.version}"/>
|
||||||
|
|
||||||
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
|
|
||||||
<formatter type="xml"/>
|
<formatter type="xml"/>
|
||||||
<formatter classname="${junit.details.formatter}" usefile="false"/>
|
<formatter classname="${junit.details.formatter}" usefile="false"/>
|
||||||
<batchtest fork="yes" todir="@{junit.output.dir}" if="runall">
|
<batchtest fork="yes" todir="@{junit.output.dir}" if="runall">
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Collections;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestResult;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.index.ConcurrentMergeScheduler;
|
import org.apache.lucene.index.ConcurrentMergeScheduler;
|
||||||
|
@ -324,6 +325,14 @@ public abstract class LuceneTestCase extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(TestResult result) {
|
||||||
|
if (LuceneTestCaseJ4.TEST_METHOD == null ||
|
||||||
|
getName().equals(LuceneTestCaseJ4.TEST_METHOD))
|
||||||
|
super.run(result);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runBare() throws Throwable {
|
public void runBare() throws Throwable {
|
||||||
//long t0 = System.currentTimeMillis();
|
//long t0 = System.currentTimeMillis();
|
||||||
|
|
|
@ -44,7 +44,13 @@ import org.junit.BeforeClass;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TestWatchman;
|
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.FrameworkMethod;
|
||||||
|
import org.junit.runners.model.InitializationError;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
@ -101,6 +107,7 @@ import static org.junit.Assert.fail;
|
||||||
// every test. But the functionality we used to
|
// every test. But the functionality we used to
|
||||||
// get from that override is provided by InterceptTestCaseEvents
|
// get from that override is provided by InterceptTestCaseEvents
|
||||||
//@RunWith(RunBareWrapper.class)
|
//@RunWith(RunBareWrapper.class)
|
||||||
|
@RunWith(LuceneTestCaseJ4.LuceneTestCaseRunner.class)
|
||||||
public class LuceneTestCaseJ4 {
|
public class LuceneTestCaseJ4 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,9 +121,16 @@ public class LuceneTestCaseJ4 {
|
||||||
*/
|
*/
|
||||||
public static final Version TEST_VERSION_CURRENT = Version.LUCENE_40;
|
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 */
|
/** Create indexes in this directory, optimally use a subdir, named after the test */
|
||||||
public static final File TEMP_DIR;
|
public static final File TEMP_DIR;
|
||||||
static {
|
static {
|
||||||
|
String method = System.getProperty("testmethod", "").trim();
|
||||||
|
TEST_METHOD = method.length() == 0 ? null : method;
|
||||||
String s = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
|
String s = System.getProperty("tempDir", System.getProperty("java.io.tmpdir"));
|
||||||
if (s == null)
|
if (s == null)
|
||||||
throw new RuntimeException("To run tests, you need to define system property 'tempDir' or 'java.io.tmpdir'.");
|
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 static final Random seedRnd = new Random();
|
||||||
|
|
||||||
private String name = "<unknown>";
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,6 +445,7 @@
|
||||||
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
||||||
<sysproperty key="jetty.insecurerandom" value="1"/>
|
<sysproperty key="jetty.insecurerandom" value="1"/>
|
||||||
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
|
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
|
||||||
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
<jvmarg line="${dir.prop}"/>
|
<jvmarg line="${dir.prop}"/>
|
||||||
<jvmarg line="${args}"/>
|
<jvmarg line="${args}"/>
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@
|
||||||
<property name="build.javadoc.solrj" value="${build.docs}/api-solrj"/>
|
<property name="build.javadoc.solrj" value="${build.docs}/api-solrj"/>
|
||||||
|
|
||||||
<!-- JUnit properties -->
|
<!-- JUnit properties -->
|
||||||
|
<property name="testmethod" value=""/>
|
||||||
<property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
|
<property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
|
||||||
<property name="junit.output.dir" location="${common-solr.dir}/${dest}/test-results"/>
|
<property name="junit.output.dir" location="${common-solr.dir}/${dest}/test-results"/>
|
||||||
<property name="junit.reports" location="${common-solr.dir}/${dest}/test-results/reports"/>
|
<property name="junit.reports" location="${common-solr.dir}/${dest}/test-results/reports"/>
|
||||||
|
|
|
@ -157,6 +157,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="jetty.insecurerandom" value="1"/>
|
<sysproperty key="jetty.insecurerandom" value="1"/>
|
||||||
<sysproperty key="tempDir" file="${tempDir}"/>
|
<sysproperty key="tempDir" file="${tempDir}"/>
|
||||||
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
<formatter type="brief" usefile="false" if="junit.details"/>
|
<formatter type="brief" usefile="false" if="junit.details"/>
|
||||||
<classpath refid="test.classpath"/>
|
<classpath refid="test.classpath"/>
|
||||||
<formatter type="xml"/>
|
<formatter type="xml"/>
|
||||||
|
@ -204,6 +205,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="jetty.insecurerandom" value="1"/>
|
<sysproperty key="jetty.insecurerandom" value="1"/>
|
||||||
<sysproperty key="tempDir" file="${tempDir}"/>
|
<sysproperty key="tempDir" file="${tempDir}"/>
|
||||||
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
<formatter type="brief" usefile="false" if="junit.details"/>
|
<formatter type="brief" usefile="false" if="junit.details"/>
|
||||||
<classpath refid="test.extras.classpath"/>
|
<classpath refid="test.extras.classpath"/>
|
||||||
<assertions>
|
<assertions>
|
||||||
|
|
|
@ -105,6 +105,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="jetty.insecurerandom" value="1"/>
|
<sysproperty key="jetty.insecurerandom" value="1"/>
|
||||||
<sysproperty key="tempDir" file="${tempDir}"/>
|
<sysproperty key="tempDir" file="${tempDir}"/>
|
||||||
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
<formatter type="brief" usefile="false" if="junit.details"/>
|
<formatter type="brief" usefile="false" if="junit.details"/>
|
||||||
<classpath refid="test.classpath"/>
|
<classpath refid="test.classpath"/>
|
||||||
<assertions>
|
<assertions>
|
||||||
|
|
Loading…
Reference in New Issue