You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2015/09/07 04:15:57 UTC
maven-surefire git commit: [SUREFIRE-580] resolved forkMode
limitation in IT, added fix and documentation
Repository: maven-surefire
Updated Branches:
refs/heads/master 8a865a901 -> d8cc6f551
[SUREFIRE-580] resolved forkMode limitation in IT, added fix and documentation
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/d8cc6f55
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/d8cc6f55
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/d8cc6f55
Branch: refs/heads/master
Commit: d8cc6f55163adc8062ab1b2c36349897a9e09b95
Parents: 8a865a9
Author: Tibor17 <ti...@lycos.com>
Authored: Mon Sep 7 04:15:36 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Mon Sep 7 04:15:36 2015 +0200
----------------------------------------------------------------------
.../plugin/failsafe/IntegrationTestMojo.java | 5 ++-
.../surefire/booterclient/ForkStarter.java | 3 +-
.../maven/plugin/surefire/SurefirePlugin.java | 5 ++-
.../site/apt/examples/skip-after-failure.apt.vm | 2 +
.../maven/surefire/its/AbstractFailFastIT.java | 5 ++-
.../maven/surefire/its/FailFastJUnitIT.java | 45 ++++++++++++--------
.../maven/surefire/its/FailFastTestNgIT.java | 29 ++++++++-----
.../src/test/resources/fail-fast-junit/pom.xml | 2 +-
.../src/test/java/pkg/CTest.java | 5 ++-
.../src/test/java/pkg/DTest.java | 5 ++-
.../src/test/java/pkg/ETest.java | 1 -
.../src/test/resources/fail-fast-testng/pom.xml | 2 +-
.../src/test/java/pkg/CTest.java | 5 ++-
.../src/test/java/pkg/DTest.java | 5 ++-
.../src/test/java/pkg/ETest.java | 1 -
15 files changed, 78 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index cbd66a3..b359048 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -305,7 +305,10 @@ public class IntegrationTestMojo
* Set to error/failure count in order to skip remaining tests.
* Due to race conditions in parallel/forked execution this may not be fully guaranteed.<br/>
* Enable with system property -Dfailsafe.skipAfterFailureCount=1 or any number greater than zero.
- * Defaults to "0".
+ * Defaults to "0".<br/>
+ * See the prerequisites and limitations in documentation:<br/>
+ * <a href="http://maven.apache.org/plugins/maven-failsafe-plugin/examples/skip-after-failure.html">
+ * http://maven.apache.org/plugins/maven-failsafe-plugin/examples/skip-after-failure.html</a>
*
* @since 2.19
*/
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
index 396e99f..5eafb4f 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
@@ -249,7 +249,8 @@ public class ForkStarter
testStreams.add( new TestProvidingInputStream( tests ) );
}
- final AtomicInteger notifyStreamsToSkipTestsJustNow = new AtomicInteger();
+ int failFastCount = providerConfiguration.getSkipAfterFailureCount();
+ final AtomicInteger notifyStreamsToSkipTestsJustNow = new AtomicInteger( failFastCount );
Collection<Future<RunResult>> results = new ArrayList<Future<RunResult>>( forkCount );
for ( final TestProvidingInputStream testProvidingInputStream : testStreams )
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index fb93a45..b26b493 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -282,7 +282,10 @@ public class SurefirePlugin
* Set to error/failure count in order to skip remaining tests.
* Due to race conditions in parallel/forked execution this may not be fully guaranteed.<br/>
* Enable with system property -Dsurefire.skipAfterFailureCount=1 or any number greater than zero.
- * Defaults to "0".
+ * Defaults to "0".<br/>
+ * See the prerequisites and limitations in documentation:<br/>
+ * <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/skip-after-failure.html">
+ * http://maven.apache.org/plugins/maven-surefire-plugin/examples/skip-after-failure.html</a>
*
* @since 2.19
*/
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm b/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm
index 31c5726..7fa2c8b 100644
--- a/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/examples/skip-after-failure.apt.vm
@@ -61,4 +61,6 @@ Limitations
Although this feature works in forking modes as well, the functionality
cannot be fully guaranteed (real first failure) in concurrent mode
due to race conditions.
+ The parameter <<<reuseForks>>> should be always set to <<<true>>> (which is
+ default value), otherwise this feature won't work properly in most cases.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
index 5b79a4d..2dfd1cc 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
@@ -87,11 +87,12 @@ public abstract class AbstractFailFastIT
return prepare( description, null, properties );
}
- protected static Map<String, String> props( int forkCount, int skipAfterFailureCount )
+ protected static Map<String, String> props( int forkCount, int skipAfterFailureCount, boolean reuseForks )
{
- Map<String, String> props = new HashMap<String, String>( 2 );
+ Map<String, String> props = new HashMap<String, String>( 3 );
props.put( "surefire.skipAfterFailureCount", "" + skipAfterFailureCount );
props.put( "forkCount", "" + forkCount );
+ props.put( "reuseForks", "" + reuseForks );
return props;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
index 3a85d5b..86df7fa 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
@@ -36,27 +36,36 @@ public class FailFastJUnitIT
@Parameters(name = "{0}")
public static Iterable<Object[]> data()
{
+ /**
+ * reuseForks=false is not used because of race conditions and unpredictable commands received by
+ * MasterProcessReader, this feature has significant limitation.
+ */
ArrayList<Object[]> args = new ArrayList<Object[]>();
// description
// profile
- // forkCount,
- // fail-fast-count
- // total
- // failures
- // errors
- // skipped
- args.add( new Object[] { "junit4-oneFork-ff1", "junit4", props( 1, 1 ), 5, 0, 1, 4 } );
- args.add( new Object[] { "junit47-oneFork-ff1", "junit47", props( 1, 1 ), 5, 0, 1, 4 } );
- args.add( new Object[] { "junit4-oneFork-ff2", "junit4", props( 1, 2 ), 5, 0, 2, 3 } );
- args.add( new Object[] { "junit47-oneFork-ff2", "junit47", props( 1, 2 ), 5, 0, 2, 3 } );
- args.add( new Object[] { "junit4-twoForks-ff1", "junit4", props( 2, 1 ), 5, 0, 1, 4 } );
- args.add( new Object[] { "junit47-twoForks-ff1", "junit47",props( 2, 1 ), 5, 0, 1, 4 } );
- args.add( new Object[] { "junit4-twoForks-ff2", "junit4", props( 2, 2 ), 5, 0, 2, 3 } );
- args.add( new Object[] { "junit47-twoForks-ff2", "junit47",props( 2, 2 ), 5, 0, 2, 3 } );
- args.add( new Object[] { "junit4-oneFork-ff3", "junit4", props( 1, 3 ), 5, 0, 2, 0 } );
- args.add( new Object[] { "junit47-oneFork-ff3", "junit47", props( 1, 3 ), 5, 0, 2, 0 } );
- args.add( new Object[] { "junit4-twoForks-ff3", "junit4", props( 2, 3 ), 5, 0, 2, 0 } );
- args.add( new Object[] { "junit47-twoForks-ff3", "junit47",props( 2, 3 ), 5, 0, 2, 0 } );
+ // forkCount,
+ // fail-fast-count,
+ // reuseForks
+ // total
+ // failures
+ // errors
+ // skipped
+ args.add( new Object[] { "junit4-oneFork-ff1", "junit4", props( 1, 1, true ), 5, 0, 1, 4 } );
+ args.add( new Object[] { "junit47-oneFork-ff1", "junit47", props( 1, 1, true ), 5, 0, 1, 4 } );
+ args.add( new Object[] { "junit4-oneFork-ff2", "junit4", props( 1, 2, true ), 5, 0, 2, 3 } );
+ args.add( new Object[] { "junit47-oneFork-ff2", "junit47", props( 1, 2, true ), 5, 0, 2, 3 } );
+ args.add( new Object[] { "junit4-twoForks-ff1", "junit4", props( 2, 1, true ), 5, 0, 2, 3 } );
+ args.add( new Object[] { "junit47-twoForks-ff1", "junit47",props( 2, 1, true ), 5, 0, 2, 3 } );
+ args.add( new Object[] { "junit4-twoForks-ff2", "junit4", props( 2, 2, true ), 5, 0, 2, 2 } );
+ args.add( new Object[] { "junit47-twoForks-ff2", "junit47",props( 2, 2, true ), 5, 0, 2, 2 } );
+ args.add( new Object[] { "junit4-oneFork-ff3", "junit4", props( 1, 3, true ), 5, 0, 2, 0 } );
+ args.add( new Object[] { "junit47-oneFork-ff3", "junit47", props( 1, 3, true ), 5, 0, 2, 0 } );
+ args.add( new Object[] { "junit4-twoForks-ff3", "junit4", props( 2, 3, true ), 5, 0, 2, 0 } );
+ args.add( new Object[] { "junit47-twoForks-ff3", "junit47",props( 2, 3, true ), 5, 0, 2, 0 } );
+ /*args.add( new Object[] { "junit4-twoForks-ff1x","junit4", props( 2, 1, false ), 5, 0, 2, 3 } );
+ args.add( new Object[] { "junit47-twoForks-ff1x","junit47",props( 2, 1, false ), 5, 0, 2, 3 } );
+ args.add( new Object[] { "junit4-twoForks-ff2x","junit4", props( 2, 2, false ), 5, 0, 2, 2 } );
+ args.add( new Object[] { "junit47-twoForks-ff2x","junit47",props( 2, 2, false ), 5, 0, 2, 2 } );*/
return args;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
index 1c2a3bd..40ebc9f 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
@@ -36,21 +36,28 @@ public class FailFastTestNgIT
@Parameters(name = "{0}")
public static Iterable<Object[]> data()
{
+ /**
+ * reuseForks=false is not used because of race conditions and unpredictable commands received by
+ * MasterProcessReader, this feature has significant limitation.
+ */
ArrayList<Object[]> args = new ArrayList<Object[]>();
// description
// profile
// forkCount,
- // fail-fast-count
- // total
- // failures
- // errors
- // skipped
- args.add( new Object[] { "testng-oneFork-ff1", null, props( 1, 1 ), 5, 1, 0, 4 } );
- args.add( new Object[] { "testng-oneFork-ff2", null, props( 1, 2 ), 5, 2, 0, 3 } );
- args.add( new Object[] { "testng-twoForks-ff1", null, props( 2, 1 ), 5, 1, 0, 4 } );
- args.add( new Object[] { "testng-twoForks-ff2", null, props( 2, 2 ), 5, 2, 0, 3 } );
- args.add( new Object[] { "testng-oneFork-ff3", null, props( 2, 3 ), 5, 2, 0, 0 } );
- args.add( new Object[] { "testng-twoForks-ff3", null, props( 2, 3 ), 5, 2, 0, 0 } );
+ // fail-fast-count,
+ // reuseForks
+ // total
+ // failures
+ // errors
+ // skipped
+ args.add( new Object[] { "testng-oneFork-ff1", null, props( 1, 1, true ), 5, 1, 0, 4 } );
+ args.add( new Object[] { "testng-oneFork-ff2", null, props( 1, 2, true ), 5, 2, 0, 3 } );
+ args.add( new Object[] { "testng-twoForks-ff1", null, props( 2, 1, true ), 5, 2, 0, 3 } );
+ args.add( new Object[] { "testng-twoForks-ff2", null, props( 2, 2, true ), 5, 2, 0, 2 } );
+ args.add( new Object[] { "testng-oneFork-ff3", null, props( 1, 3, true ), 5, 2, 0, 0 } );
+ args.add( new Object[] { "testng-twoForks-ff3", null, props( 2, 3, true ), 5, 2, 0, 0 } );
+ /*args.add( new Object[] { "testng-twoForks-ff1x", null, props( 2, 1, false ), 5, 2, 0, 3 } );
+ args.add( new Object[] { "testng-twoForks-ff2x", null, props( 2, 2, false ), 5, 2, 0, 2 } );*/
return args;
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml b/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml
index 6a6be11..14fcdfd 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml
@@ -61,7 +61,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<runOrder>alphabetical</runOrder>
- <reuseForks>true</reuseForks>
+ <forkMode>once</forkMode><!--override to default value in order to enable forkCount-->
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java
index b32ab2d..2cad77c 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/CTest.java
@@ -2,12 +2,15 @@ package pkg;
import org.junit.Test;
+import java.util.concurrent.TimeUnit;
+
public class CTest
{
@Test
public void test()
+ throws InterruptedException
{
-
+ TimeUnit.MILLISECONDS.sleep(500);
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java
index 0ed7e83..6fff98d 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/DTest.java
@@ -2,12 +2,15 @@ package pkg;
import org.junit.Test;
+import java.util.concurrent.TimeUnit;
+
public class DTest
{
@Test
public void test()
+ throws InterruptedException
{
-
+ TimeUnit.MILLISECONDS.sleep(500);
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ETest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ETest.java b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ETest.java
index 0e741ff..61c7516 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ETest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/src/test/java/pkg/ETest.java
@@ -7,7 +7,6 @@ public class ETest
@Test
public void test()
{
-
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml b/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml
index 4fb8385..4ad397f 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml
@@ -58,7 +58,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<runOrder>alphabetical</runOrder>
- <reuseForks>true</reuseForks>
+ <forkMode>once</forkMode><!--override to default value in order to enable forkCount-->
</configuration>
</plugin>
</plugins>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java
index 54652c1..41e1629 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/CTest.java
@@ -2,12 +2,15 @@ package pkg;
import org.testng.annotations.Test;
+import java.util.concurrent.TimeUnit;
+
public class CTest
{
@Test
public void test()
+ throws InterruptedException
{
-
+ TimeUnit.MILLISECONDS.sleep(500);
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java
index e094716..ca5292b 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/DTest.java
@@ -2,12 +2,15 @@ package pkg;
import org.testng.annotations.Test;
+import java.util.concurrent.TimeUnit;
+
public class DTest
{
@Test
public void test()
+ throws InterruptedException
{
-
+ TimeUnit.MILLISECONDS.sleep(500);
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/d8cc6f55/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ETest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ETest.java b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ETest.java
index 5c5bdac..ff71562 100644
--- a/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ETest.java
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/src/test/java/pkg/ETest.java
@@ -7,7 +7,6 @@ public class ETest
@Test
public void test()
{
-
}
}