You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/11/14 22:10:55 UTC
git commit: [SUREFIRE-920] -Dmaven.test.failure.ignore=true isn't
honored
Updated Branches:
refs/heads/master 72776ba1e -> 0b27dc20a
[SUREFIRE-920] -Dmaven.test.failure.ignore=true isn't honored
Fixed with IT
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/0b27dc20
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/0b27dc20
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/0b27dc20
Branch: refs/heads/master
Commit: 0b27dc20abd2058644eaffe205ec23db73381875
Parents: 72776ba
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Wed Nov 14 22:10:38 2012 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Wed Nov 14 22:10:38 2012 +0100
----------------------------------------------------------------------
.../maven/plugin/surefire/SurefireHelper.java | 4 +-
.../plugin/surefire/booterclient/ForkStarter.java | 2 +-
.../surefire/booterclient/output/ForkClient.java | 4 +-
.../Surefire920TestFailureIgnoreWithTimeoutIT.java | 45 ++++++++++++
.../src/test/java/forktimeout/BaseForkTimeout.java | 53 +++++++++++++++
5 files changed, 103 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0b27dc20/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
index c431f0c..4b2b853 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
@@ -45,8 +45,9 @@ public final class SurefireHelper
throws MojoFailureException, MojoExecutionException
{
+ boolean timeoutOrOtherFailure = result.isFailureOrTimeout();
- if ( result.getCompletedCount() == 0 )
+ if ( !timeoutOrOtherFailure && result.getCompletedCount() == 0 )
{
if ( ( reportParameters.getFailIfNoTests() == null ) || !reportParameters.getFailIfNoTests() )
{
@@ -56,7 +57,6 @@ public final class SurefireHelper
"No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" );
}
- boolean timeoutOrOtherFailure = result.isFailureOrTimeout();
if ( !timeoutOrOtherFailure && result.isErrorFree() )
{
return;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0b27dc20/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 37600cc..7a7b4bc 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
@@ -299,7 +299,7 @@ public class ForkStarter
finally
{
threadedStreamConsumer.close();
- forkClient.close();
+ forkClient.close(runResult == RunResult.Timeout);
if ( runResult == null )
{
runResult = globalRunStatistics.getRunResult();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0b27dc20/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
index 6b99083..7559954 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
@@ -248,9 +248,9 @@ public class ForkClient
return (ConsoleLogger) getOrCreateReporter( channelNumber );
}
- public void close()
+ public void close(boolean hadTimeout)
{
- if ( !saidGoodBye )
+ if ( !saidGoodBye && !hadTimeout)
{
throw new RuntimeException(
"The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?" );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0b27dc20/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java
new file mode 100755
index 0000000..2b9d661
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire920TestFailureIgnoreWithTimeoutIT.java
@@ -0,0 +1,45 @@
+package org.apache.maven.surefire.its.jiras;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+
+import org.junit.Test;
+
+public class Surefire920TestFailureIgnoreWithTimeoutIT
+ extends SurefireJUnit4IntegrationTestCase
+{
+ @Test
+ public void timeoutInForkWithBuildFail()
+ {
+ OutputValidator validator = unpack( "fork-timeout" ).addD( "junit.parallel", "none" ).executeTestWithFailure();
+ validator.verifyTextInLog( "There was a timeout or other error in the fork" );
+ }
+
+ @Test
+ public void timeoutInForkWithNoBuildFail()
+ {
+ OutputValidator validator =
+ unpack( "fork-timeout" ).addD( "junit.parallel", "none" ).addD( "maven.test.failure.ignore",
+ "true" ).executeTest();
+ validator.verifyTextInLog( "[ERROR] There was a timeout or other error in the fork" );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/0b27dc20/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java b/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java
new file mode 100644
index 0000000..a2dc6cb
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/fork-timeout/src/test/java/forktimeout/BaseForkTimeout.java
@@ -0,0 +1,53 @@
+package forktimeout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+public abstract class BaseForkTimeout
+{
+ protected void dumpStuff( String prefix )
+ {
+ reallySleep( 990 );
+ for ( int i = 0; i < 200; i++ )
+ {
+ System.out.println( prefix + " with lots of output " + i );
+ System.err.println( prefix + "e with lots of output " + i );
+ }
+ System.out.println( prefix + "last line" );
+ System.err.println( prefix + "e last line" );
+ }
+
+ private void reallySleep( long timeout )
+ {
+ long endAt = System.currentTimeMillis() + timeout;
+ try
+ {
+ Thread.sleep( timeout );
+ while ( System.currentTimeMillis() < endAt )
+ {
+ Thread.yield();
+ Thread.sleep( 5 );
+ }
+ }
+ catch ( InterruptedException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+}