LUCENE-9522: Instructions for reproducing failing tests still mention ant (#1868)

This commit is contained in:
Dawid Weiss 2020-09-14 13:29:32 +02:00 committed by GitHub
parent 978446e4fd
commit f92e2656b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 61 deletions

View File

@ -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.

View File

@ -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();
}
}

View File

@ -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();
}
}