Author: krosenvold Date: Sat Aug 11 16:52:39 2012 New Revision: 1371975 URL: http://svn.apache.org/viewvc?rev=1371975&view=rev Log: [SUREFIRE-901] Failsafe verify fails if no failsafe-summary.xml can be found
Fixed with IT Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/pom.xml maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/src/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/src/test/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/src/test/java/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/src/test/java/AClass.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1371975&r1=1371974&r2=1371975&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Sat Aug 11 16:52:39 2012 @@ -578,6 +578,7 @@ public abstract class AbstractSurefireMo throw new MojoFailureException( "No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)" ); } + handleSummary( Summary.notests() ); return; } logReportsDirectory(); @@ -1244,13 +1245,10 @@ public abstract class AbstractSurefireMo final Classpath bootClasspathConfiguration = getArtifactClasspath( shadeFire != null ? shadeFire : surefireBooterArtifact ); - ForkConfiguration fork = - new ForkConfiguration( bootClasspathConfiguration, tmpDir, getEffectiveDebugForkedProcess(), - getEffectiveJvm(), - getWorkingDirectory() != null ? getWorkingDirectory() : getBasedir(), getArgLine(), - getEnvironmentVariables(), getLog().isDebugEnabled(), getEffectiveForkCount() ); - - return fork; + return new ForkConfiguration( bootClasspathConfiguration, tmpDir, getEffectiveDebugForkedProcess(), + getEffectiveJvm(), + getWorkingDirectory() != null ? getWorkingDirectory() : getBasedir(), getArgLine(), + getEnvironmentVariables(), getLog().isDebugEnabled(), getEffectiveForkCount() ); } Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java?rev=1371975&r1=1371974&r2=1371975&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/Summary.java Sat Aug 11 16:52:39 2012 @@ -71,4 +71,9 @@ public class Summary { return runResult; } + + public static Summary notests(){ + return new Summary(); + } } + Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java?rev=1371975&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/FailsafeOutputValidator.java Sat Aug 11 16:52:39 2012 @@ -0,0 +1,46 @@ +package org.apache.maven.surefire.its.fixture; + +/* + * 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.it.VerificationException; +import org.apache.maven.it.Verifier; + +public class FailsafeOutputValidator extends OutputValidator +{ + public FailsafeOutputValidator( Verifier verifier ) + { + super( verifier ); + } + + public OutputValidator verifyErrorFree( int total ) + { + try + { + verifier.verifyErrorFreeLog(); + this.assertIntegrationTestSuiteResults( total, 0, 0, 0 ); + return this; + } + catch ( VerificationException e ) + { + throw new SurefireVerifierException( e ); + } + } + +} Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java?rev=1371975&r1=1371974&r2=1371975&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/OutputValidator.java Sat Aug 11 16:52:39 2012 @@ -197,4 +197,8 @@ public class OutputValidator return false; } + Verifier getVerifier() + { + return verifier; + } } Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java?rev=1371975&r1=1371974&r2=1371975&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java Sat Aug 11 16:52:39 2012 @@ -266,9 +266,10 @@ public class SurefireLauncher } - public OutputValidator executeVerify() + public FailsafeOutputValidator executeVerify() { - return execute( "verify" ); + OutputValidator verify = execute( "verify" ); + return new FailsafeOutputValidator( verify.getVerifier()); } public OutputValidator execute( String goal ) Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java?rev=1371975&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire901MIssingResultfileWhenNoTestsIT.java Sat Aug 11 16:52:39 2012 @@ -0,0 +1,40 @@ +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.SurefireIntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; + +import org.junit.Test; + +/** + * Failsafe should work with early return when no tests + * s + */ +public class Surefire901MIssingResultfileWhenNoTestsIT + extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void failsafeWithNoTests() + { + unpack( "failsafe-notests" ).executeVerify(); + } + +} Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/pom.xml?rev=1371975&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/pom.xml (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/pom.xml Sat Aug 11 16:52:39 2012 @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>localhost</groupId> + <artifactId>failsafe-notests</artifactId> + <version>1.0</version> + <name>failsafe-notests</name> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.2</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <version>${surefire.version}</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project> Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/src/test/java/AClass.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/src/test/java/AClass.java?rev=1371975&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/src/test/java/AClass.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-notests/src/test/java/AClass.java Sat Aug 11 16:52:39 2012 @@ -0,0 +1,25 @@ +/* + * 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 junit.framework.TestCase; + +public class AClass extends TestCase { + public void testSomething() { + assertTrue(false); + } +}