This is an automated email from the ASF dual-hosted git repository.
martinkanters 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 4db5702 [MNG-7051] Optionally skip non-existing profiles and break on
missing required profiles.
4db5702 is described below
commit 4db57020f28776e83674e6b7cf505b003dee0e7d
Author: Maarten Mulders <[email protected]>
AuthorDate: Wed Dec 9 11:49:52 2020 +0100
[MNG-7051] Optionally skip non-existing profiles and break on missing
required profiles.
---
.../org/apache/maven/it/IntegrationTestSuite.java | 1 +
.../MavenITmng2309ProfileInjectionOrderTest.java | 18 ++-
...MavenITmng3641ProfileActivationWarningTest.java | 2 +-
.../maven/it/MavenITmng3732ActiveProfilesTest.java | 9 +-
...ng4106InterpolationUsesDominantProfileTest.java | 9 +-
...avenITmng7051OptionalProfileActivationTest.java | 128 +++++++++++++++++++++
.../mng-7051-optional-profile-activation/pom.xml | 37 ++++++
7 files changed, 196 insertions(+), 8 deletions(-)
diff --git
a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
index 027587f..337e1a9 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
@@ -106,6 +106,7 @@ public class IntegrationTestSuite
// Tests that don't run stable and need to be fixed
//
-------------------------------------------------------------------------------------------------------------
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); --
MNG-3137
+ suite.addTestSuite( MavenITmng7051OptionalProfileActivationTest.class
);
suite.addTestSuite( MavenITmng6957BuildConsumer.class );
suite.addTestSuite(
MavenITmng7045DropUselessAndOutdatedCdiApiTest.class );
suite.addTestSuite(
MavenITmng6566ExecuteAnnotationShouldNotReExecuteGoalsTest.class );
diff --git
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2309ProfileInjectionOrderTest.java
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2309ProfileInjectionOrderTest.java
index 2f46491..7666aa4 100644
---
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2309ProfileInjectionOrderTest.java
+++
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2309ProfileInjectionOrderTest.java
@@ -22,7 +22,6 @@ package org.apache.maven.it;
import java.io.File;
import java.util.Properties;
-import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
/**
@@ -52,10 +51,19 @@ public class MavenITmng2309ProfileInjectionOrderTest
verifier.setAutoclean( false );
verifier.addCliOption( "--settings" );
verifier.addCliOption( "settings.xml" );
- verifier.addCliOption( "-P"
- + "pom-a,pom-b,pom-e,pom-c,pom-d"
- + ",profiles-a,profiles-b,profiles-e,profiles-c,profiles-d"
- + ",settings-a,settings-b,settings-e,settings-c,settings-d" );
+ if ( matchesVersionRange( "[4.0.0-alpha-1,)" ) )
+ {
+ verifier.addCliOption( "-P"
+ + "pom-a,pom-b,pom-e,pom-c,pom-d"
+ +
",settings-a,settings-b,settings-e,settings-c,settings-d" );
+ }
+ else
+ {
+ verifier.addCliOption( "-P"
+ + "pom-a,pom-b,pom-e,pom-c,pom-d"
+ + ",profiles-a,profiles-b,profiles-e,profiles-c,profiles-d"
+ +
",settings-a,settings-b,settings-e,settings-c,settings-d" );
+ }
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
diff --git
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
index 11fc0ef..778c662 100644
---
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
+++
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3641ProfileActivationWarningTest.java
@@ -35,7 +35,7 @@ public class MavenITmng3641ProfileActivationWarningTest
public MavenITmng3641ProfileActivationWarningTest()
{
- super( "[2.0.11,2.1.0-M1),[2.1.0,)" ); // only test in 2.0.11+, 2.1.0+
+ super( "[2.0.11,2.1.0-M1),[2.1.0,4.0.0-alpha-1)" ); // only test in
2.0.11+, 2.1.0+
}
public void testitMNG3641()
diff --git
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java
index bdf95f6..b47f300 100644
---
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java
+++
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3732ActiveProfilesTest.java
@@ -56,7 +56,14 @@ public class MavenITmng3732ActiveProfilesTest
verifier.deleteDirectory( "target" );
verifier.addCliOption( "--settings" );
verifier.addCliOption( "settings.xml" );
- verifier.addCliOption( "-Ppom,profiles,settings" );
+ if ( matchesVersionRange( "[4.0.0-alpha-1,)" ) )
+ {
+ verifier.addCliOption( "-Ppom,settings" );
+ }
+ else
+ {
+ verifier.addCliOption( "-Ppom,profiles,settings" );
+ }
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
diff --git
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4106InterpolationUsesDominantProfileTest.java
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4106InterpolationUsesDominantProfileTest.java
index 83f45ba..28a4afe 100644
---
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4106InterpolationUsesDominantProfileTest.java
+++
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4106InterpolationUsesDominantProfileTest.java
@@ -54,7 +54,14 @@ public class
MavenITmng4106InterpolationUsesDominantProfileTest
verifier.setAutoclean( false );
verifier.addCliOption( "--settings" );
verifier.addCliOption( "settings.xml" );
- verifier.addCliOption(
"-Ppom-a,pom-b,profiles-a,profiles-b,settings-a,settings-b" );
+ if ( matchesVersionRange( "[4.0.0-alpha-1,)" ) )
+ {
+ verifier.addCliOption( "-Ppom-a,pom-b,settings-a,settings-b" );
+ }
+ else
+ {
+ verifier.addCliOption(
"-Ppom-a,pom-b,profiles-a,profiles-b,settings-a,settings-b" );
+ }
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
diff --git
a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7051OptionalProfileActivationTest.java
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7051OptionalProfileActivationTest.java
new file mode 100644
index 0000000..6682ada
--- /dev/null
+++
b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7051OptionalProfileActivationTest.java
@@ -0,0 +1,128 @@
+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;
+
+public class MavenITmng7051OptionalProfileActivationTest
+ extends AbstractMavenIntegrationTestCase
+{
+ private static final String PROJECT_PATH =
"/mng-7051-optional-profile-activation";
+
+ public MavenITmng7051OptionalProfileActivationTest()
+ {
+ super( "[4.0.0-alpha-1,)" );
+ }
+
+ /**
+ * This test verifies that activating a non-existing profile breaks the
build.
+ */
+ public void testActivatingNonExistingProfileBreaks() throws IOException,
VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources(
getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "non-existing-profile" );
+ verifier.setLogFileName( "test-breaking.txt" );
+
+ try
+ {
+ verifier.executeGoal( "validate" );
+ fail( "Activated a non-existing profile without ? prefix should
break the build, but it didn't." );
+ }
+ catch ( VerificationException ve )
+ {
+ // Inspect the reason why the build broke.
+ verifier.verifyTextInLog( "[ERROR] The requested profiles
[non-existing-profile] could not be activated or deactivated because they do
not exist." );
+ }
+ }
+
+ /**
+ * This test verifies that activating a non-existing profile does not
break the build when it is prefixed with <strong>?</strong>.
+ */
+ public void testActivatingNonExistingProfileWithQuestionMarkDoesNotBreak()
throws IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources(
getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "?non-existing-profile" );
+ verifier.setLogFileName( "test-non-breaking.txt" );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog( "[WARNING] The requested optional profiles
[non-existing-profile] could not be activated or deactivated because they do
not exist." );
+ }
+
+ /**
+ * This test verifies that activating both an existing and a non-existing
profile does not break the build when it the latter is prefixed with
<strong>?</strong>.
+ */
+ public void testActivatingExistingAndNonExistingProfiles() throws
IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources(
getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "?non-existing-profile,existing" );
+ verifier.setLogFileName( "test-non-breaking-mixed.txt" );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog( "[WARNING] The requested optional profiles
[non-existing-profile] could not be activated or deactivated because they do
not exist." );
+ }
+
+ /**
+ * This test verifies that deactivating a non-existing profile does not
break the build when it is prefixed with <strong>?</strong>.
+ */
+ public void
testDeactivatingNonExistingProfileWithQuestionMarkDoesNotBreak() throws
IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources(
getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "!?non-existing-profile" );
+ verifier.setLogFileName( "test-deactivating-non-breaking.txt" );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog( "[WARNING] The requested optional profiles
[non-existing-profile] could not be activated or deactivated because they do
not exist." );
+ }
+
+ /**
+ * This test verifies that deactivating both an existing and a
non-existing profile does not break the build when it the latter is prefixed
with <strong>?</strong>.
+ */
+ public void testDeactivatingExistingAndNonExistingProfiles() throws
IOException, VerificationException
+ {
+ final File projectDir = ResourceExtractor.simpleExtractResources(
getClass(), PROJECT_PATH );
+ final Verifier verifier = newVerifier( projectDir.getAbsolutePath() );
+
+ verifier.addCliOption( "-P" );
+ verifier.addCliOption( "!?non-existing-profile,!existing" );
+ verifier.setLogFileName( "test-deactivating-non-breaking-mixed.txt" );
+
+ verifier.executeGoal( "validate" );
+ verifier.verifyErrorFreeLog();
+ verifier.verifyTextInLog( "[WARNING] The requested optional profiles
[non-existing-profile] could not be activated or deactivated because they do
not exist." );
+ }
+}
diff --git
a/core-it-suite/src/test/resources/mng-7051-optional-profile-activation/pom.xml
b/core-it-suite/src/test/resources/mng-7051-optional-profile-activation/pom.xml
new file mode 100644
index 0000000..0963c0b
--- /dev/null
+++
b/core-it-suite/src/test/resources/mng-7051-optional-profile-activation/pom.xml
@@ -0,0 +1,37 @@
+<?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>org.apache.maven.its.mng7051</groupId>
+ <artifactId>profile-selection</artifactId>
+ <version>1.0</version>
+
+ <profiles>
+ <profile>
+ <id>existing</id>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file