Skip to content

Commit 8eda8a6

Browse files
committed
Update Surefire
1 parent c920a57 commit 8eda8a6

File tree

2 files changed

+223
-7
lines changed

2 files changed

+223
-7
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
<dependency>
143143
<groupId>org.apache.maven.surefire</groupId>
144144
<artifactId>maven-surefire-common</artifactId>
145-
<version>2.22.2</version>
145+
<version>3.1.2</version>
146146
<exclusions>
147147
<exclusion>
148148
<groupId>org.apache.maven</groupId>

src/main/java/net/ltgt/gwt/maven/TestMojo.java

Lines changed: 222 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
import org.apache.maven.plugins.annotations.Mojo;
2323
import org.apache.maven.plugins.annotations.Parameter;
2424
import org.apache.maven.plugins.annotations.ResolutionScope;
25-
import org.apache.maven.surefire.suite.RunResult;
25+
import org.apache.maven.surefire.api.suite.RunResult;
26+
import org.apache.maven.surefire.extensions.ForkNodeFactory;
2627

2728
/**
2829
* Runs the project's tests with the specific setup needed for {@code GWTTestCase} tests.
@@ -288,8 +289,8 @@ public String[] getAdditionalClasspathElements() {
288289
* Set this to "true" to cause a failure if the none of the tests specified in -Dtest=... are run. Defaults to
289290
* "true".
290291
*/
291-
@Parameter(property = "surefire.failIfNoSpecifiedTests")
292-
private Boolean failIfNoSpecifiedTests;
292+
@Parameter(property = "surefire.failIfNoSpecifiedTests", defaultValue = "true")
293+
private boolean failIfNoSpecifiedTests;
293294

294295
/**
295296
* Attach a debugger to the forked JVM. If set to "true", the process will suspend and wait for a debugger to attach
@@ -366,6 +367,33 @@ public String[] getAdditionalClasspathElements() {
366367
@Parameter
367368
private List<String> includes;
368369

370+
/**
371+
* A list of {@literal <exclude>} elements specifying the tests (by pattern) that should be excluded in testing.
372+
* When not specified and when the {@code test} parameter is not specified, the default excludes will be <br>
373+
* <pre><code>
374+
* {@literal <excludes>}
375+
* {@literal <exclude>}**{@literal /}*$*{@literal </exclude>}
376+
* {@literal </excludes>}
377+
* </code></pre>
378+
* (which excludes all inner classes).
379+
* <br>
380+
* This parameter is ignored if the TestNG {@code suiteXmlFiles} parameter is specified.
381+
* <br>
382+
* Each exclude item may also contain a comma-separated sub-list of items, which will be treated as multiple
383+
* {@literal <exclude>} entries.<br>
384+
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
385+
* <pre><code>
386+
* {@literal <exclude>}%regex[pkg.*Slow.*.class], Unstable*{@literal </exclude>}
387+
* </code></pre>
388+
* <br>
389+
* <b>Notice that</b> these values are relative to the directory containing generated test classes of the project
390+
* being tested. This directory is declared by the parameter {@code testClassesDirectory} which defaults
391+
* to the POM property <code>${project.build.testOutputDirectory}</code>, typically
392+
* <code>{@literal src/test/java}</code> unless overridden.
393+
*/
394+
@Parameter(property = "surefire.excludes")
395+
private List<String> excludes;
396+
369397
/**
370398
* (JUnit 4+ providers)
371399
* The number of times each failing test will be rerun. If set larger than 0, rerun failing tests immediately after
@@ -375,6 +403,13 @@ public String[] getAdditionalClasspathElements() {
375403
@Parameter(property = "surefire.rerunFailingTestsCount", defaultValue = "0")
376404
private int rerunFailingTestsCount;
377405

406+
/**
407+
* Set this to a value greater than 0 to fail the whole test set if the cumulative number of flakes reaches
408+
* this threshold. Set to 0 to allow an unlimited number of flakes.
409+
*/
410+
@Parameter(property = "surefire.failOnFlakeCount", defaultValue = "0")
411+
private int failOnFlakeCount;
412+
378413
/**
379414
* (TestNG) List of &lt;suiteXmlFile> elements specifying TestNG suite xml file locations. Note that
380415
* <code>suiteXmlFiles</code> is incompatible with several other parameters of this plugin, like
@@ -410,6 +445,20 @@ public String[] getAdditionalClasspathElements() {
410445
@Parameter(property = "surefire.runOrder", defaultValue = "filesystem")
411446
private String runOrder;
412447

448+
/**
449+
* Sets the random seed that will be used to order the tests if {@code surefire.runOrder} is set to {@code random}.
450+
* <br>
451+
* <br>
452+
* If no seeds are set and {@code surefire.runOrder} is set to {@code random}, then the seed used will be
453+
* outputted (search for "To reproduce ordering use flag -Dsurefire.runOrder.random.seed").
454+
* <br>
455+
* <br>
456+
* To deterministically reproduce any random test order that was run before, simply set the seed to
457+
* be the same value.
458+
*/
459+
@Parameter(property = "surefire.runOrder.random.seed")
460+
private Long runOrderRandomSeed;
461+
413462
/**
414463
* A file containing include patterns. Blank lines, or lines starting with # are ignored. If {@code includes} are
415464
* also specified, these patterns are appended. Example with path, simple and regex includes:<br/>
@@ -453,6 +502,85 @@ public String[] getAdditionalClasspathElements() {
453502
@Parameter(property = "surefire.shutdown", defaultValue = "testset")
454503
private String shutdown;
455504

505+
/**
506+
* This parameter configures the forked node. Currently, you can select the communication protocol, i.e. process
507+
* pipes or TCP/IP sockets.
508+
* <br>
509+
* See the documentation for more details:<br>
510+
* <a href="https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html">
511+
* https://maven.apache.org/plugins/maven-surefire-plugin/examples/process-communication.html</a>
512+
*/
513+
@Parameter(property = "surefire.forkNode")
514+
private ForkNodeFactory forkNode;
515+
516+
/**
517+
* You can selectively exclude individual environment variables by enumerating their keys.
518+
* <br>
519+
* The environment is a system-dependent mapping from keys to values which is inherited from the Maven process
520+
* to the forked Surefire processes. The keys must literally (case sensitive) match in order to exclude
521+
* their environment variable.
522+
* <br>
523+
* Example to exclude three environment variables:
524+
* <br>
525+
* <i>mvn test -Dsurefire.excludedEnvironmentVariables=ACME1,ACME2,ACME3</i>
526+
*/
527+
@Parameter(property = "surefire.excludedEnvironmentVariables")
528+
private String[] excludedEnvironmentVariables;
529+
530+
/**
531+
* The process checkers are disabled by default.
532+
* You can enable them namely by setting {@code ping} and {@code native} or {@code all} in this parameter.
533+
* <br>
534+
* The checker is useful in situations when you kill the build on a CI system and you want the Surefire forked JVM
535+
* to kill the tests asap and free all handlers on the file system been previously used by the JVM and by the tests.
536+
*
537+
* <br>
538+
*
539+
* The {@code ping} should be safely used together with ZGC or Shenandoah Garbage Collector.
540+
* Due to the {@code ping} relies on timing of the PING (triggered every 30 seconds), slow GCs may pause
541+
* the timers and pretend that the parent process of the forked JVM does not exist.
542+
*
543+
* <br>
544+
*
545+
* The {@code native} is very fast checker.
546+
* It is useful mechanism on Unix based systems, Linux distributions and Alpine/BusyBox Linux.
547+
* See the JIRA <a href="https://issues.apache.org/jira/browse/SUREFIRE-1631">SUREFIRE-1631</a> for Windows issues.
548+
*
549+
* <br>
550+
*
551+
* Another useful configuration parameter is {@code forkedProcessTimeoutInSeconds}.
552+
* <br>
553+
* See the Frequently Asked Questions page with more details:<br>
554+
* <a href="http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm">
555+
* http://maven.apache.org/surefire/maven-surefire-plugin/faq.html#kill-jvm</a>
556+
* <br>
557+
* <a href="http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm">
558+
* http://maven.apache.org/surefire/maven-failsafe-plugin/faq.html#kill-jvm</a>
559+
*
560+
* <br>
561+
*
562+
* Example of use:
563+
* <br>
564+
* <i>mvn test -Dsurefire.enableProcessChecker=all</i>
565+
*/
566+
@Parameter(property = "surefire.enableProcessChecker")
567+
private String enableProcessChecker;
568+
569+
@Parameter(property = "surefire.systemPropertiesFile")
570+
private File systemPropertiesFile;
571+
572+
/**
573+
* Provide the ID/s of an JUnit engine to be included in the test run.
574+
*/
575+
@Parameter(property = "surefire.includeJUnit5Engines")
576+
private String[] includeJUnit5Engines;
577+
578+
/**
579+
* Provide the ID/s of an JUnit engine to be excluded in the test run.
580+
*/
581+
@Parameter(property = "surefire.excludeJUnit5Engines")
582+
private String[] excludeJUnit5Engines;
583+
456584
/**
457585
* The character encoding scheme to be applied while generating test report
458586
* files (see target/surefire-reports/yourTestName.txt).
@@ -468,6 +596,16 @@ public int getRerunFailingTestsCount() {
468596
return rerunFailingTestsCount;
469597
}
470598

599+
@Override
600+
public int getFailOnFlakeCount() {
601+
return failOnFlakeCount;
602+
}
603+
604+
@Override
605+
public void setFailOnFlakeCount(int failOnFlakeCount) {
606+
this.failOnFlakeCount = failOnFlakeCount;
607+
}
608+
471609
@Override
472610
protected void handleSummary(RunResult summary, Exception firstForkException)
473611
throws MojoExecutionException, MojoFailureException {
@@ -509,6 +647,16 @@ public void setIncludes(List<String> includes) {
509647
this.includes = includes;
510648
}
511649

650+
@Override
651+
public List<String> getExcludes() {
652+
return excludes;
653+
}
654+
655+
@Override
656+
public void setExcludes(List<String> excludes) {
657+
this.excludes = excludes;
658+
}
659+
512660
@Override
513661
protected String getReportSchemaLocation() {
514662
return "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd";
@@ -575,12 +723,12 @@ public void setTestClassesDirectory(File testClassesDirectory) {
575723
}
576724

577725
@Override
578-
public File getClassesDirectory() {
726+
public File getMainBuildPath() {
579727
return classesDirectory;
580728
}
581729

582730
@Override
583-
public void setClassesDirectory(File classesDirectory) {
731+
public void setMainBuildPath(File classesDirectory) {
584732
this.classesDirectory = classesDirectory;
585733
}
586734

@@ -614,6 +762,53 @@ public String getShutdown() {
614762
return shutdown;
615763
}
616764

765+
@Override
766+
public String[] getExcludedEnvironmentVariables() {
767+
return excludedEnvironmentVariables;
768+
}
769+
770+
@Override
771+
protected String getEnableProcessChecker() {
772+
return enableProcessChecker;
773+
}
774+
775+
@Override
776+
protected ForkNodeFactory getForkNode() {
777+
return forkNode;
778+
}
779+
780+
@Override
781+
public File getSystemPropertiesFile() {
782+
return systemPropertiesFile;
783+
}
784+
785+
@Override
786+
public void setSystemPropertiesFile(File systemPropertiesFile) {
787+
this.systemPropertiesFile = systemPropertiesFile;
788+
}
789+
790+
@Override
791+
public String[] getIncludeJUnit5Engines() {
792+
return includeJUnit5Engines;
793+
}
794+
795+
@Override
796+
public void setIncludeJUnit5Engines(String[] includeJUnit5Engines) {
797+
this.includeJUnit5Engines = includeJUnit5Engines;
798+
}
799+
800+
801+
@Override
802+
public String[] getExcludeJUnit5Engines() {
803+
return excludeJUnit5Engines;
804+
}
805+
806+
807+
@Override
808+
public void setExcludeJUnit5Engines(String[] excludeJUnit5Engines) {
809+
this.excludeJUnit5Engines = excludeJUnit5Engines;
810+
}
811+
617812
@Override
618813
public boolean isPrintSummary() {
619814
return printSummary;
@@ -697,7 +892,7 @@ public void setUseManifestOnlyJar(boolean useManifestOnlyJar) {
697892
}
698893

699894
@Override
700-
public Boolean getFailIfNoSpecifiedTests() {
895+
public boolean getFailIfNoSpecifiedTests() {
701896
return failIfNoSpecifiedTests;
702897
}
703898

@@ -756,6 +951,16 @@ public void setRunOrder(String runOrder) {
756951
this.runOrder = runOrder;
757952
}
758953

954+
@Override
955+
public Long getRunOrderRandomSeed() {
956+
return runOrderRandomSeed;
957+
}
958+
959+
@Override
960+
public void setRunOrderRandomSeed(Long runOrderRandomSeed) {
961+
this.runOrderRandomSeed = runOrderRandomSeed;
962+
}
963+
759964
@Override
760965
public File getIncludesFile() {
761966
return includesFile;
@@ -766,6 +971,17 @@ public File getExcludesFile() {
766971
return excludesFile;
767972
}
768973

974+
@Override
975+
protected boolean useModulePath() {
976+
// GWTTestCase must not use the module path
977+
return false;
978+
}
979+
980+
@Override
981+
protected void setUseModulePath(boolean useModulePath) {
982+
throw new UnsupportedOperationException("useModulePath is read-only");
983+
}
984+
769985
@Override
770986
protected List<File> suiteXmlFiles() {
771987
return hasSuiteXmlFiles() ? Arrays.asList( suiteXmlFiles ) : Collections.<File>emptyList();

0 commit comments

Comments
 (0)