mirror of https://github.com/apache/lucene.git
LUCENE-3908: include test method even in a failure is caught in a non-test thread.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1304923 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dd41d8d3bb
commit
8e8b55d32c
|
@ -55,6 +55,7 @@ public class TestSeedFromUncaught extends WithNestedTests {
|
|||
Assert.assertEquals(1, result.getFailureCount());
|
||||
String consoleOut = super.getSysErr() + "\n\n" + super.getSysOut();
|
||||
Assert.assertTrue(consoleOut.contains("-Dtests.seed="));
|
||||
Assert.assertTrue(consoleOut.contains("-Dtestmethod=testFoo"));
|
||||
Assert.assertTrue(consoleOut.contains("foobar"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ public abstract class LuceneTestCase extends Assert {
|
|||
*/
|
||||
@Rule
|
||||
public final TestRule ruleChain = RuleChain
|
||||
.outerRule(new RememberThreadRule())
|
||||
.outerRule(new SaveThreadAndTestNameRule())
|
||||
.around(new UncaughtExceptionsRule(this))
|
||||
.around(new TestResultInterceptorRule())
|
||||
.around(new SystemPropertiesInvariantRule(ignoredInvariantProperties))
|
||||
|
@ -561,7 +561,6 @@ public abstract class LuceneTestCase extends Assert {
|
|||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
starting(description);
|
||||
try {
|
||||
base.evaluate();
|
||||
} catch (AssumptionViolatedException e) {
|
||||
|
@ -570,8 +569,6 @@ public abstract class LuceneTestCase extends Assert {
|
|||
} catch (Throwable t) {
|
||||
failed(t, description);
|
||||
throw t;
|
||||
} finally {
|
||||
ending(description);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -593,16 +590,6 @@ public abstract class LuceneTestCase extends Assert {
|
|||
reportAdditionalFailureInfo();
|
||||
assert !(e instanceof AssumptionViolatedException);
|
||||
}
|
||||
|
||||
private void starting(Description description) {
|
||||
// set current method name for logging
|
||||
LuceneTestCase.this.name = description.getMethodName();
|
||||
}
|
||||
|
||||
private void ending(Description description) {
|
||||
// clear the current method name.
|
||||
LuceneTestCase.this.name = null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -614,21 +601,23 @@ public abstract class LuceneTestCase extends Assert {
|
|||
/**
|
||||
* @see LuceneTestCase#testCaseThread
|
||||
*/
|
||||
private class RememberThreadRule implements TestRule {
|
||||
private class SaveThreadAndTestNameRule implements TestRule {
|
||||
private String previousName;
|
||||
|
||||
@Override
|
||||
public Statement apply(final Statement base, Description description) {
|
||||
public Statement apply(final Statement base, final Description description) {
|
||||
return new Statement() {
|
||||
public void evaluate() throws Throwable {
|
||||
try {
|
||||
Thread current = Thread.currentThread();
|
||||
previousName = current.getName();
|
||||
LuceneTestCase.this.testCaseThread = current;
|
||||
LuceneTestCase.this.name = description.getMethodName();
|
||||
base.evaluate();
|
||||
} finally {
|
||||
LuceneTestCase.this.testCaseThread.setName(previousName);
|
||||
LuceneTestCase.this.testCaseThread = null;
|
||||
LuceneTestCase.this.name = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1497,9 +1486,16 @@ public abstract class LuceneTestCase extends Assert {
|
|||
|
||||
// We get here from InterceptTestCaseEvents on the 'failed' event....
|
||||
public void reportAdditionalFailureInfo() {
|
||||
System.err.println("NOTE: reproduce with: ant test -Dtestcase=" + getClass().getSimpleName()
|
||||
+ " -Dtestmethod=" + getName() + " -Dtests.seed=" + new ThreeLongs(staticSeed, seed, LuceneTestCaseRunner.runnerSeed)
|
||||
+ reproduceWithExtraParams());
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("NOTE: reproduce with: ant test -Dtestcase=")
|
||||
.append(getClass().getSimpleName());
|
||||
if (getName() != null) {
|
||||
b.append(" -Dtestmethod=").append(getName());
|
||||
}
|
||||
b.append(" -Dtests.seed=")
|
||||
.append(new ThreeLongs(staticSeed, seed, LuceneTestCaseRunner.runnerSeed))
|
||||
.append(reproduceWithExtraParams());
|
||||
System.err.println(b.toString());
|
||||
}
|
||||
|
||||
// extra params that were overridden needed to reproduce the command
|
||||
|
|
Loading…
Reference in New Issue