You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/06/20 11:52:57 UTC
[maven-integration-testing] branch master updated: [MNG-5760] Add
`-r/--resume` to automatically resume from the last failure point
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git
The following commit(s) were added to refs/heads/master by this push:
new 094373d [MNG-5760] Add `-r/--resume` to automatically resume from the last failure point
094373d is described below
commit 094373ddb6c47c8eeba1005bc11d70dcaeeb9330
Author: rfscholte <rf...@apache.org>
AuthorDate: Sat Jun 20 13:52:39 2020 +0200
[MNG-5760] Add `-r/--resume` to automatically resume from the last failure point
Author: Maarten Mulders <ma...@infosupport.com>
---
.../maven/it/MavenITmng5760ResumeFeatureTest.java | 132 +++++++++++++++++++++
.../mng-5760-resume-feature/module-a/pom.xml | 36 ++++++
.../test/java/org/apache/maven/it/TestCase.java | 36 ++++++
.../mng-5760-resume-feature/module-b/pom.xml | 36 ++++++
.../test/java/org/apache/maven/it/TestCase.java | 36 ++++++
.../mng-5760-resume-feature/module-c/pom.xml | 43 +++++++
.../test/java/org/apache/maven/it/TestCase.java | 36 ++++++
.../test/resources/mng-5760-resume-feature/pom.xml | 59 +++++++++
8 files changed, 414 insertions(+)
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5760ResumeFeatureTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5760ResumeFeatureTest.java
new file mode 100644
index 0000000..aa001a0
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5760ResumeFeatureTest.java
@@ -0,0 +1,132 @@
+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.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * This is a collection of test cases for <a href="https://issues.apache.org/jira/browse/MNG-5760">MNG-5760</a>,
+ * <code>--resume</code> / <code>-r</code> in case of build failures.
+ *
+ * The test uses a multi-module project with three modules:
+ * <ul>
+ * <li>module-a</li>
+ * <li>module-b</li>
+ * <li>module-c</li> (depends on module-b)
+ * </ul>
+ *
+ * @author Maarten Mulders
+ * @author Martin Kanters
+ */
+public class MavenITmng5760ResumeFeatureTest extends AbstractMavenIntegrationTestCase {
+ private final File testDir;
+
+ public MavenITmng5760ResumeFeatureTest() throws IOException {
+ super( "[3.7.0,)" );
+ this.testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5760-resume-feature" );
+ }
+
+ /**
+ * Tests that the hint at the end of a failed build mentions <code>--resume</code> instead of <code>--resume-from</code>.
+ */
+ public void testShouldSuggestToResumeWithoutArgs() throws Exception
+ {
+ final Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+ verifier.addCliOption( "-Dmodule-b.fail=true" );
+
+ try
+ {
+ verifier.executeGoal( "test" );
+ fail( "Expected this invocation to fail" );
+ }
+ catch ( final VerificationException ve )
+ {
+ verifier.verifyTextInLog( "mvn <args> -r" );
+ verifyTextNotInLog( verifier, "mvn <args> -rf :module-b" );
+ }
+ finally
+ {
+ verifier.resetStreams();
+ }
+ }
+
+ public void testShouldSkipSuccessfulProjects() throws Exception
+ {
+ final Verifier verifier = newVerifier( testDir.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 )
+ {
+ // Expected to fail.
+ }
+ finally
+ {
+ verifier.resetStreams();
+ }
+
+ verifier.getCliOptions().clear();
+
+ // Let module-b and module-c fail, if they would have been built...
+ verifier.addCliOption( "-Dmodule-b.fail=true" );
+ verifier.addCliOption( "-Dmodule-c.fail=true" );
+ // ... but adding -r should exclude those two from the build because the previous Maven invocation
+ // marked them as successfully built.
+ verifier.addCliOption( "-r" );
+ try
+ {
+ verifier.executeGoal( "test" );
+ }
+ finally
+ {
+ verifier.resetStreams();
+ }
+ }
+
+ /**
+ * Throws an exception if the text <strong>is</strong> present in the log.
+ *
+ * @param verifier the verifier to use
+ * @param text the text to assert present
+ * @throws VerificationException if text is not found in log
+ */
+ private void verifyTextNotInLog( Verifier verifier, String text )
+ throws VerificationException
+ {
+ List<String> lines = verifier.loadFile( verifier.getBasedir(), verifier.getLogFileName(), false );
+
+ for ( String line : lines )
+ {
+ if ( Verifier.stripAnsi( line ).contains( text ) )
+ {
+ throw new VerificationException( "Text found in log: " + text );
+ }
+ }
+ }
+}
diff --git a/core-it-suite/src/test/resources/mng-5760-resume-feature/module-a/pom.xml b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-a/pom.xml
new file mode 100644
index 0000000..2fc5193
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-a/pom.xml
@@ -0,0 +1,36 @@
+<?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>
+
+ <artifactId>module-a</artifactId>
+
+ <parent>
+ <groupId>org.apache.maven.its.mng5760</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0</version>
+ </parent>
+
+</project>
diff --git a/core-it-suite/src/test/resources/mng-5760-resume-feature/module-a/src/test/java/org/apache/maven/it/TestCase.java b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-a/src/test/java/org/apache/maven/it/TestCase.java
new file mode 100644
index 0000000..503ccc6
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-a/src/test/java/org/apache/maven/it/TestCase.java
@@ -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");
+ }
+ }
+}
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/mng-5760-resume-feature/module-b/pom.xml b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-b/pom.xml
new file mode 100644
index 0000000..d415157
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-b/pom.xml
@@ -0,0 +1,36 @@
+<?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>
+
+ <artifactId>module-b</artifactId>
+
+ <parent>
+ <groupId>org.apache.maven.its.mng5760</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0</version>
+ </parent>
+
+</project>
diff --git a/core-it-suite/src/test/resources/mng-5760-resume-feature/module-b/src/test/java/org/apache/maven/it/TestCase.java b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-b/src/test/java/org/apache/maven/it/TestCase.java
new file mode 100644
index 0000000..a624bcf
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-b/src/test/java/org/apache/maven/it/TestCase.java
@@ -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");
+ }
+ }
+}
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/mng-5760-resume-feature/module-c/pom.xml b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-c/pom.xml
new file mode 100644
index 0000000..708e1a4
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-c/pom.xml
@@ -0,0 +1,43 @@
+<?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>
+
+ <artifactId>module-c</artifactId>
+
+ <parent>
+ <groupId>org.apache.maven.its.mng5760</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.its.mng5760</groupId>
+ <artifactId>module-b</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/core-it-suite/src/test/resources/mng-5760-resume-feature/module-c/src/test/java/org/apache/maven/it/TestCase.java b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-c/src/test/java/org/apache/maven/it/TestCase.java
new file mode 100644
index 0000000..1cb0415
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5760-resume-feature/module-c/src/test/java/org/apache/maven/it/TestCase.java
@@ -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-c.fail") )
+ {
+ fail("Deliberately fail test case in module C");
+ }
+ }
+}
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/mng-5760-resume-feature/pom.xml b/core-it-suite/src/test/resources/mng-5760-resume-feature/pom.xml
new file mode 100644
index 0000000..ca797e0
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-5760-resume-feature/pom.xml
@@ -0,0 +1,59 @@
+<?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</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>
+ <module>module-c</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>