mirror of https://github.com/apache/lucene.git
LUCENE-9522: Instructions for reproducing failing tests still mention ant (#1868)
This commit is contained in:
parent
978446e4fd
commit
f92e2656b5
|
@ -154,11 +154,17 @@ public final class RunListenerPrintReproduceInfo extends RunListener {
|
|||
}
|
||||
|
||||
final StringBuilder b = new StringBuilder();
|
||||
b.append("NOTE: reproduce with: ant test ");
|
||||
b.append("NOTE: reproduce with: gradlew test ");
|
||||
|
||||
// Test case, method, seed.
|
||||
addVmOpt(b, "testcase", RandomizedContext.current().getTargetClass().getSimpleName());
|
||||
addVmOpt(b, "tests.method", testName);
|
||||
// Figure out the test case name and method, if any.
|
||||
String testClass = RandomizedContext.current().getTargetClass().getSimpleName();
|
||||
b.append("--tests ");
|
||||
b.append(testClass);
|
||||
if (testName != null) {
|
||||
b.append(".").append(testName);
|
||||
}
|
||||
|
||||
// Pass the master seed.
|
||||
addVmOpt(b, "tests.seed", RandomizedContext.current().getRunnerSeedAsString());
|
||||
|
||||
// Test groups and multipliers.
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
*/
|
||||
package org.apache.lucene.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
|
@ -26,7 +25,6 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runner.JUnitCore;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
|
@ -46,16 +44,11 @@ public class TestReproduceMessage extends WithNestedTests {
|
|||
}
|
||||
|
||||
@Rule
|
||||
public TestRule rule = new TestRule() {
|
||||
public TestRule rule = (base, description) -> new Statement() {
|
||||
@Override
|
||||
public Statement apply(final Statement base, Description description) {
|
||||
return new Statement() {
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
triggerOn(SorePoint.RULE);
|
||||
base.evaluate();
|
||||
}
|
||||
};
|
||||
public void evaluate() throws Throwable {
|
||||
triggerOn(SorePoint.RULE);
|
||||
base.evaluate();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -178,46 +171,37 @@ public class TestReproduceMessage extends WithNestedTests {
|
|||
Assert.assertTrue(runAndReturnSyserr().contains("NOTE: reproduce with:"));
|
||||
}
|
||||
|
||||
static void checkTestName(String syserr, String expectedName) {
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertThat(syserr, Matchers.containsString(" --tests " + expectedName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureRule() throws Exception {
|
||||
type = SoreType.FAILURE;
|
||||
where = SorePoint.RULE;
|
||||
|
||||
final String syserr = runAndReturnSyserr();
|
||||
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtests.method=test"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
|
||||
checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureBefore() throws Exception {
|
||||
type = SoreType.FAILURE;
|
||||
where = SorePoint.BEFORE;
|
||||
final String syserr = runAndReturnSyserr();
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtests.method=test"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
|
||||
checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureTest() throws Exception {
|
||||
type = SoreType.FAILURE;
|
||||
where = SorePoint.TEST;
|
||||
final String syserr = runAndReturnSyserr();
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtests.method=test"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
|
||||
checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailureAfter() throws Exception {
|
||||
type = SoreType.FAILURE;
|
||||
where = SorePoint.AFTER;
|
||||
final String syserr = runAndReturnSyserr();
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtests.method=test"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
|
||||
checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".test");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -249,40 +233,28 @@ public class TestReproduceMessage extends WithNestedTests {
|
|||
public void testErrorRule() throws Exception {
|
||||
type = SoreType.ERROR;
|
||||
where = SorePoint.RULE;
|
||||
final String syserr = runAndReturnSyserr();
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtests.method=test"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
|
||||
checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorBefore() throws Exception {
|
||||
type = SoreType.ERROR;
|
||||
where = SorePoint.BEFORE;
|
||||
final String syserr = runAndReturnSyserr();
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtests.method=test"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
|
||||
checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorTest() throws Exception {
|
||||
type = SoreType.ERROR;
|
||||
where = SorePoint.TEST;
|
||||
final String syserr = runAndReturnSyserr();
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtests.method=test"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
|
||||
checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorAfter() throws Exception {
|
||||
type = SoreType.ERROR;
|
||||
where = SorePoint.AFTER;
|
||||
final String syserr = runAndReturnSyserr();
|
||||
Assert.assertTrue(syserr.contains("NOTE: reproduce with:"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtests.method=test"));
|
||||
Assert.assertTrue(Arrays.asList(syserr.split("\\s")).contains("-Dtestcase=" + Nested.class.getSimpleName()));
|
||||
checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".test");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -294,10 +266,6 @@ public class TestReproduceMessage extends WithNestedTests {
|
|||
|
||||
private String runAndReturnSyserr() {
|
||||
JUnitCore.runClasses(Nested.class);
|
||||
|
||||
String err = getSysErr();
|
||||
// super.prevSysErr.println("Type: " + type + ", point: " + where + " resulted in:\n" + err);
|
||||
// super.prevSysErr.println("---");
|
||||
return err;
|
||||
return getSysErr();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.lucene.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.JUnitCore;
|
||||
|
||||
|
@ -39,14 +38,12 @@ public class TestReproduceMessageWithRepeated extends WithNestedTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRepeatedMessage() throws Exception {
|
||||
String syserr = runAndReturnSyserr();
|
||||
Assert.assertTrue(syserr.contains(" -Dtests.method=testMe "));
|
||||
public void testRepeatedMessage() throws Exception {
|
||||
TestReproduceMessage.checkTestName(runAndReturnSyserr(), Nested.class.getSimpleName() + ".testMe");
|
||||
}
|
||||
|
||||
private String runAndReturnSyserr() {
|
||||
JUnitCore.runClasses(Nested.class);
|
||||
String err = getSysErr();
|
||||
return err;
|
||||
return getSysErr();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue