mirror of https://github.com/apache/lucene.git
LUCENE-2768: add support to LuceneTestCase for @Nightly annotated tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1036088 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
09a526f57b
commit
e60764241b
|
@ -72,6 +72,7 @@
|
||||||
<property name="tests.seed" value="random" />
|
<property name="tests.seed" value="random" />
|
||||||
<property name="tests.userdir" value="."/>
|
<property name="tests.userdir" value="."/>
|
||||||
<property name="tests.loggingfile" value="/dev/null"/>
|
<property name="tests.loggingfile" value="/dev/null"/>
|
||||||
|
<property name="tests.nightly" value="false" />
|
||||||
|
|
||||||
<property name="javac.deprecation" value="off"/>
|
<property name="javac.deprecation" value="off"/>
|
||||||
<property name="javac.debug" value="on"/>
|
<property name="javac.debug" value="on"/>
|
||||||
|
@ -462,7 +463,9 @@
|
||||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||||
<!-- logging config file -->
|
<!-- logging config file -->
|
||||||
<sysproperty key="java.util.logging.config.file" value="${tests.loggingfile}"/>
|
<sysproperty key="java.util.logging.config.file" value="${tests.loggingfile}"/>
|
||||||
|
<!-- set whether or not nightly tests should run -->
|
||||||
|
<sysproperty key="tests.nightly" value="${tests.nightly}"/>
|
||||||
|
|
||||||
<!-- TODO: create propertyset for test properties, so each project can have its own set -->
|
<!-- TODO: create propertyset for test properties, so each project can have its own set -->
|
||||||
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
||||||
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
|
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
|
||||||
|
|
|
@ -63,6 +63,10 @@ import org.junit.runners.model.InitializationError;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
@ -152,6 +156,8 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
static final int TEST_ITER = Integer.parseInt(System.getProperty("tests.iter", "1"));
|
static final int TEST_ITER = Integer.parseInt(System.getProperty("tests.iter", "1"));
|
||||||
/** Get the random seed for tests */
|
/** Get the random seed for tests */
|
||||||
static final String TEST_SEED = System.getProperty("tests.seed", "random");
|
static final String TEST_SEED = System.getProperty("tests.seed", "random");
|
||||||
|
/** whether or not nightly tests should run */
|
||||||
|
static final boolean TEST_NIGHTLY = Boolean.parseBoolean(System.getProperty("tests.nightly", "false"));
|
||||||
|
|
||||||
private static final Pattern codecWithParam = Pattern.compile("(.*)\\(\\s*(\\d+)\\s*\\)");
|
private static final Pattern codecWithParam = Pattern.compile("(.*)\\(\\s*(\\d+)\\s*\\)");
|
||||||
|
|
||||||
|
@ -843,6 +849,14 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
|
|
||||||
private String name = "<unknown>";
|
private String name = "<unknown>";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation for tests that should only be run during nightly builds.
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Inherited
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface Nightly {}
|
||||||
|
|
||||||
/** optionally filters the tests to be run by TEST_METHOD */
|
/** optionally filters the tests to be run by TEST_METHOD */
|
||||||
public static class LuceneTestCaseRunner extends BlockJUnit4ClassRunner {
|
public static class LuceneTestCaseRunner extends BlockJUnit4ClassRunner {
|
||||||
private List<FrameworkMethod> testMethods;
|
private List<FrameworkMethod> testMethods;
|
||||||
|
@ -856,7 +870,7 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
for (Method m : getTestClass().getJavaClass().getMethods()) {
|
for (Method m : getTestClass().getJavaClass().getMethods()) {
|
||||||
// check if the current test's class has methods annotated with @Ignore
|
// check if the current test's class has methods annotated with @Ignore
|
||||||
final Ignore ignored = m.getAnnotation(Ignore.class);
|
final Ignore ignored = m.getAnnotation(Ignore.class);
|
||||||
if (ignored != null) {
|
if (ignored != null && !m.getName().equals("alwaysIgnoredTestMethod")) {
|
||||||
System.err.println("NOTE: Ignoring test method '" + m.getName() + "': " + ignored.value());
|
System.err.println("NOTE: Ignoring test method '" + m.getName() + "': " + ignored.value());
|
||||||
}
|
}
|
||||||
// add methods starting with "test"
|
// add methods starting with "test"
|
||||||
|
@ -872,6 +886,34 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
testMethods.add(new FrameworkMethod(m));
|
testMethods.add(new FrameworkMethod(m));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (testMethods.isEmpty()) {
|
||||||
|
throw new RuntimeException("No runnable methods!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TEST_NIGHTLY == false) {
|
||||||
|
if (getTestClass().getJavaClass().isAnnotationPresent(Nightly.class)) {
|
||||||
|
/* the test class is annotated with nightly, remove all methods */
|
||||||
|
String className = getTestClass().getJavaClass().getSimpleName();
|
||||||
|
System.err.println("NOTE: Ignoring nightly-only test class '" + className + "'");
|
||||||
|
testMethods.clear();
|
||||||
|
} else {
|
||||||
|
/* remove all nightly-only methods */
|
||||||
|
for (int i = 0; i < testMethods.size(); i++) {
|
||||||
|
final FrameworkMethod m = testMethods.get(i);
|
||||||
|
if (m.getAnnotation(Nightly.class) != null) {
|
||||||
|
System.err.println("NOTE: Ignoring nightly-only test method '" + m.getName() + "'");
|
||||||
|
testMethods.remove(i--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* dodge a possible "no-runnable methods" exception by adding a fake ignored test */
|
||||||
|
if (testMethods.isEmpty()) {
|
||||||
|
try {
|
||||||
|
testMethods.add(new FrameworkMethod(LuceneTestCase.class.getMethod("alwaysIgnoredTestMethod")));
|
||||||
|
} catch (Exception e) { throw new RuntimeException(e); }
|
||||||
|
}
|
||||||
|
}
|
||||||
return testMethods;
|
return testMethods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,4 +943,7 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore("just a hack")
|
||||||
|
public final void alwaysIgnoredTestMethod() {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -436,6 +436,8 @@
|
||||||
<sysproperty key="jetty.testMode" value="1"/>
|
<sysproperty key="jetty.testMode" value="1"/>
|
||||||
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
|
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
|
||||||
<sysproperty key="testmethod" value="${testmethod}"/>
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
|
<!-- set whether or not nightly tests should run -->
|
||||||
|
<sysproperty key="tests.nightly" value="${tests.nightly}"/>
|
||||||
<!-- TODO: why is this unconditionally set to "" above? disable for now
|
<!-- TODO: why is this unconditionally set to "" above? disable for now
|
||||||
<jvmarg line="${dir.prop}"/>
|
<jvmarg line="${dir.prop}"/>
|
||||||
-->
|
-->
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
<property name="tests.timezone" value="random" />
|
<property name="tests.timezone" value="random" />
|
||||||
<property name="tests.iter" value="1" />
|
<property name="tests.iter" value="1" />
|
||||||
<property name="tests.seed" value="random" />
|
<property name="tests.seed" value="random" />
|
||||||
|
<property name="tests.nightly" value="false" />
|
||||||
|
|
||||||
<condition property="dir.prop" value="-Dsolr.directoryFactory=solr.StandardDirectoryFactory">
|
<condition property="dir.prop" value="-Dsolr.directoryFactory=solr.StandardDirectoryFactory">
|
||||||
<isset property="use.fsdir"/>
|
<isset property="use.fsdir"/>
|
||||||
|
|
|
@ -148,6 +148,8 @@
|
||||||
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
||||||
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
||||||
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
||||||
|
<!-- set whether or not nightly tests should run -->
|
||||||
|
<sysproperty key="tests.nightly" value="${tests.nightly}"/>
|
||||||
<sysproperty key="jetty.testMode" value="1"/>
|
<sysproperty key="jetty.testMode" value="1"/>
|
||||||
<sysproperty key="tempDir" file="${junit.output.dir}"/>
|
<sysproperty key="tempDir" file="${junit.output.dir}"/>
|
||||||
<sysproperty key="testmethod" value="${testmethod}"/>
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
|
|
|
@ -116,6 +116,8 @@
|
||||||
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
||||||
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
||||||
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
||||||
|
<!-- set whether or not nightly tests should run -->
|
||||||
|
<sysproperty key="tests.nightly" value="${tests.nightly}"/>
|
||||||
<sysproperty key="jetty.testMode" value="1"/>
|
<sysproperty key="jetty.testMode" value="1"/>
|
||||||
<sysproperty key="tempDir" file="${junit.output.dir}"/>
|
<sysproperty key="tempDir" file="${junit.output.dir}"/>
|
||||||
<sysproperty key="testmethod" value="${testmethod}"/>
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
|
|
|
@ -168,6 +168,8 @@
|
||||||
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
||||||
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
||||||
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
||||||
|
<!-- set whether or not nightly tests should run -->
|
||||||
|
<sysproperty key="tests.nightly" value="${tests.nightly}"/>
|
||||||
<sysproperty key="jetty.testMode" value="1"/>
|
<sysproperty key="jetty.testMode" value="1"/>
|
||||||
<sysproperty key="tempDir" file="${tempDir}"/>
|
<sysproperty key="tempDir" file="${tempDir}"/>
|
||||||
<sysproperty key="testmethod" value="${testmethod}"/>
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
|
@ -226,6 +228,8 @@
|
||||||
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
||||||
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
||||||
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
||||||
|
<!-- set whether or not nightly tests should run -->
|
||||||
|
<sysproperty key="tests.nightly" value="${tests.nightly}"/>
|
||||||
<sysproperty key="jetty.testMode" value="1"/>
|
<sysproperty key="jetty.testMode" value="1"/>
|
||||||
<sysproperty key="tempDir" file="${tempDir}"/>
|
<sysproperty key="tempDir" file="${tempDir}"/>
|
||||||
<sysproperty key="testmethod" value="${testmethod}"/>
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
|
|
|
@ -117,6 +117,8 @@
|
||||||
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
||||||
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
<sysproperty key="tests.iter" value="${tests.iter}"/>
|
||||||
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
<sysproperty key="tests.seed" value="${tests.seed}"/>
|
||||||
|
<!-- set whether or not nightly tests should run -->
|
||||||
|
<sysproperty key="tests.nightly" value="${tests.nightly}"/>
|
||||||
<sysproperty key="jetty.testMode" value="1"/>
|
<sysproperty key="jetty.testMode" value="1"/>
|
||||||
<sysproperty key="tempDir" file="${tempDir}"/>
|
<sysproperty key="tempDir" file="${tempDir}"/>
|
||||||
<sysproperty key="testmethod" value="${testmethod}"/>
|
<sysproperty key="testmethod" value="${testmethod}"/>
|
||||||
|
|
Loading…
Reference in New Issue