mirror of https://github.com/apache/maven.git
[MNG-5760] Added several more test cases for the --resume feature
Enable test for --resume feature Verifying that resuming the build works when the resume.properties file does not have excludedProjects to skip in the next build. Enabled back temporarily ignored test. Added a test case for the --resume feature to skip failed modules after the first multi module project failed. Maven invocations without project shouldn't fail Ensure empty folder is there
This commit is contained in:
parent
f1ab8c4264
commit
beee89ebf0
|
@ -107,6 +107,7 @@ public class IntegrationTestSuite
|
|||
// -------------------------------------------------------------------------------------------------------------
|
||||
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137
|
||||
|
||||
suite.addTestSuite( MavenITmng5760ResumeFeatureTest.class );
|
||||
suite.addTestSuite( MavenITmng6656BuildConsumer.class );
|
||||
suite.addTestSuite( MavenITmng6562WarnDefaultBindings.class );
|
||||
suite.addTestSuite( MavenITmng5868NoDuplicateAttachedArtifacts.class );
|
||||
|
|
|
@ -40,11 +40,18 @@ import java.util.List;
|
|||
* @author Martin Kanters
|
||||
*/
|
||||
public class MavenITmng5760ResumeFeatureTest extends AbstractMavenIntegrationTestCase {
|
||||
private final File testDir;
|
||||
private final File parentDependentTestDir;
|
||||
private final File parentIndependentTestDir;
|
||||
private final File noProjectTestDir;
|
||||
|
||||
public MavenITmng5760ResumeFeatureTest() throws IOException {
|
||||
super( "[3.7.0,)" );
|
||||
this.testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5760-resume-feature" );
|
||||
this.parentDependentTestDir = ResourceExtractor.simpleExtractResources( getClass(),
|
||||
"/mng-5760-resume-feature/parent-dependent" );
|
||||
this.parentIndependentTestDir = ResourceExtractor.simpleExtractResources( getClass(),
|
||||
"/mng-5760-resume-feature/parent-independent" );
|
||||
this.noProjectTestDir = ResourceExtractor.simpleExtractResources( getClass(),
|
||||
"/mng-5760-resume-feature/no-project" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +59,7 @@ public class MavenITmng5760ResumeFeatureTest extends AbstractMavenIntegrationTes
|
|||
*/
|
||||
public void testShouldSuggestToResumeWithoutArgs() throws Exception
|
||||
{
|
||||
final Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
final Verifier verifier = newVerifier( parentDependentTestDir.getAbsolutePath() );
|
||||
verifier.addCliOption( "-Dmodule-b.fail=true" );
|
||||
|
||||
try
|
||||
|
@ -69,11 +76,19 @@ public class MavenITmng5760ResumeFeatureTest extends AbstractMavenIntegrationTes
|
|||
{
|
||||
verifier.resetStreams();
|
||||
}
|
||||
|
||||
// New build with -r should resume the build from module-b, skipping module-a since it has succeeded already.
|
||||
verifier.getCliOptions().clear();
|
||||
verifier.addCliOption( "-r" );
|
||||
verifier.executeGoal( "test" );
|
||||
verifyTextNotInLog( verifier, "Building module-a 1.0" );
|
||||
verifier.verifyTextInLog( "Building module-b 1.0" );
|
||||
verifier.verifyTextInLog( "Building module-c 1.0" );
|
||||
}
|
||||
|
||||
public void testShouldSkipSuccessfulProjects() throws Exception
|
||||
{
|
||||
final Verifier verifier = newVerifier( testDir.getAbsolutePath() );
|
||||
final Verifier verifier = newVerifier( parentDependentTestDir.getAbsolutePath() );
|
||||
verifier.addCliOption( "-Dmodule-a.fail=true" );
|
||||
verifier.addCliOption( "--fail-at-end");
|
||||
|
||||
|
@ -109,6 +124,56 @@ public class MavenITmng5760ResumeFeatureTest extends AbstractMavenIntegrationTes
|
|||
}
|
||||
}
|
||||
|
||||
public void testShouldSkipSuccessfulModulesWhenTheFirstModuleFailed() throws Exception
|
||||
{
|
||||
// In this multi-module project, the submodules are not dependent on the parent.
|
||||
// This results in the parent to be built last, and module-a to be built first.
|
||||
// This enables us to let the first module in the reactor (module-a) fail.
|
||||
final Verifier verifier = newVerifier( parentIndependentTestDir.getAbsolutePath() );
|
||||
verifier.addCliOption( "-Dmodule-a.fail=true" );
|
||||
verifier.addCliOption( "--fail-at-end");
|
||||
|
||||
try
|
||||
{
|
||||
verifier.executeGoal( "test" );
|
||||
fail( "Expected this invocation to fail" );
|
||||
}
|
||||
catch ( final VerificationException ve )
|
||||
{
|
||||
verifier.verifyTextInLog( "mvn <args> -r" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
verifier.resetStreams();
|
||||
}
|
||||
|
||||
verifier.getCliOptions().clear();
|
||||
verifier.addCliOption( "-r" );
|
||||
verifier.executeGoal( "test" );
|
||||
verifier.verifyTextInLog( "Building module-a 1.0" );
|
||||
verifyTextNotInLog( verifier, "Building module-b 1.0" );
|
||||
}
|
||||
|
||||
public void testShouldNotCrashWithoutProject() throws Exception
|
||||
{
|
||||
// There is no Maven project available in the test directory.
|
||||
// As reported in JIRA this would previously break with a NullPointerException.
|
||||
// (see https://issues.apache.org/jira/browse/MNG-5760?focusedCommentId=17143795&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17143795)
|
||||
final Verifier verifier = newVerifier( noProjectTestDir.getAbsolutePath() );
|
||||
try
|
||||
{
|
||||
verifier.executeGoal( "resources:resources" );
|
||||
}
|
||||
catch ( final VerificationException ve )
|
||||
{
|
||||
verifier.verifyTextInLog( "Goal requires a project to execute but there is no POM in this directory" );
|
||||
}
|
||||
finally
|
||||
{
|
||||
verifier.resetStreams();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an exception if the text <strong>is</strong> present in the log.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?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/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng5760.parentindependent</groupId>
|
||||
<artifactId>module-a</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,36 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
/*
|
||||
* 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.junit.Test;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class TestCase
|
||||
{
|
||||
@Test
|
||||
public void testCase()
|
||||
{
|
||||
if ( Boolean.getBoolean("module-a.fail") )
|
||||
{
|
||||
fail("Deliberately fail test case in module A");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?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/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng5760.parentindependent</groupId>
|
||||
<artifactId>module-b</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,36 @@
|
|||
package org.apache.maven.it;
|
||||
|
||||
/*
|
||||
* 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.junit.Test;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class TestCase
|
||||
{
|
||||
@Test
|
||||
public void testCase()
|
||||
{
|
||||
if ( Boolean.getBoolean("module-b.fail") )
|
||||
{
|
||||
fail("Deliberately fail test case in module B");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<?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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.its.mng5760.parentindependent</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Maven Integration Test :: MNG-5760</name>
|
||||
<description>
|
||||
Tests for the --resume flag.
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>module-a</module>
|
||||
<module>module-b</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
Loading…
Reference in New Issue