You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2026/10/22 05:48:51 UTC

(maven-surefire) branch surefire-3.5.x updated: [BACKPORT 3.5.x] Fix ITs for Maven 3.10.0 (#3508, #3509) (#3540)

This is an automated email from the ASF dual-hosted git repository.

slawekjaranowski pushed a commit to branch surefire-3.5.x
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/surefire-3.5.x by this push:
     new 160142ceb [BACKPORT 3.5.x] Fix ITs for Maven 3.10.0 (#3508, #3509) (#3540)
160142ceb is described below

commit 160142cebf62aa36e99a1bb16a12bef68f53bdf3
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Thu Oct 22 07:48:46 2026 +0200

    [BACKPORT 3.5.x] Fix ITs for Maven 3.10.0 (#3508, #3509) (#3540)
    
    * Fix ITs for Maven 3.10.0 (#3508)
    
    (cherry picked from commit cfaab001b9747fe66819b78b38a4c193c63a30df)
    
    * Fix ForkCountIT failing on Windows with Maven 3.10.0 (#3509)
    
    Signed-off-by: Olivier Lamy <ol...@apache.org>
    (cherry picked from commit 80b1f787d8ba264d9393262418f9399b7db87c1e)
    
    ---------
    
    Signed-off-by: Olivier Lamy <ol...@apache.org>
    Co-authored-by: Olivier Lamy <ol...@apache.org>
---
 surefire-its/pom.xml                               |  1 +
 .../org/apache/maven/surefire/its/ForkCountIT.java | 54 +++++++++++++++-------
 .../maven/surefire/its/ForkCountTestNGIT.java      | 31 -------------
 .../Surefire1396CustomProviderClassPathIT.java     |  2 +
 .../its/jiras/Surefire141PluggableProvidersIT.java |  8 ++++
 .../surefire-570-multipleReportDirectories/pom.xml |  4 --
 6 files changed, 49 insertions(+), 51 deletions(-)

diff --git a/surefire-its/pom.xml b/surefire-its/pom.xml
index a4b1b80f2..25a3df0d2 100644
--- a/surefire-its/pom.xml
+++ b/surefire-its/pom.xml
@@ -222,6 +222,7 @@
               <systemPropertyVariables>
                 <surefire.version>${project.version}</surefire.version>
                 <maven.home>${maven.home}</maven.home>
+                <maven.repo.local>${settings.localRepository}</maven.repo.local>
                 <maven.settings.file>${project.build.directory}/private/settings.xml</maven.settings.file>
                 <maven.toolchains.file>${project.build.directory}/private/toolchains.xml</maven.toolchains.file>
                 <maven.test.tmpdir>${project.build.directory}</maven.test.tmpdir>
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java
index 6856a4071..341fe8d07 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountIT.java
@@ -28,18 +28,34 @@
 import org.apache.maven.surefire.its.fixture.TestFile;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.fail;
 
 /**
- * Test forkCount and reuseForks
+ * Checks forkCount and reuseForks with both JUnit 4 and TestNG.
  *
  * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
  */
+@RunWith(Parameterized.class)
 public class ForkCountIT extends SurefireJUnit4IntegrationTestCase {
 
+    // Both projects run from this class so the dump-pid plugin is only installed once.
+    // On Windows, installing it again fails if another build still has the jar open.
+    @Parameters(name = "{0}")
+    public static Iterable<Object[]> projects() {
+        return Arrays.asList(new Object[] {"fork-count"}, new Object[] {"fork-count-testng"});
+    }
+
+    @Parameter
+    @SuppressWarnings("checkstyle:visibilitymodifier")
+    public String project;
+
     private OutputValidator outputValidator;
 
     @BeforeClass
@@ -49,7 +65,7 @@ public static void installDumpPidPlugin() {
 
     @Test
     public void testForkNever() {
-        String[] pids = doTest(unpack(getProject()).setForkJvm().forkNever());
+        String[] pids = doTest(unpack(project, "-" + project).setForkJvm().forkNever());
         assertSamePids(pids);
         assertEndWith(pids, "_1_1", 3);
         assertEquals("my pid is equal to pid 1 of the test", getMainPID(), pids[0]);
@@ -58,8 +74,10 @@ public void testForkNever() {
     @Test
     public void testForkOncePerThreadSingleThread() {
         int threadCount = 1;
-        String[] pids = doTest(
-                unpack(getProject()).setForkJvm().forkPerThread(threadCount).threadCount(threadCount));
+        String[] pids = doTest(unpack(project, "-" + project)
+                .setForkJvm()
+                .forkPerThread(threadCount)
+                .threadCount(threadCount));
         assertSamePids(pids);
         assertEndWith(pids, "_1_1", 3);
         assertNotEquals("pid 1 is not the same as the main process' pid", pids[0], getMainPID());
@@ -68,7 +86,7 @@ public void testForkOncePerThreadSingleThread() {
     @Test
     public void testForkOncePerThreadTwoThreads() {
         int threadCount = 2;
-        String[] pids = doTest(unpack(getProject())
+        String[] pids = doTest(unpack(project, "-" + project)
                 .setForkJvm()
                 .forkPerThread(threadCount)
                 .threadCount(threadCount)
@@ -79,7 +97,8 @@ public void testForkOncePerThreadTwoThreads() {
 
     @Test
     public void testForkCountOneNoReuse() {
-        String[] pids = doTest(unpack(getProject()).setForkJvm().forkCount(1).reuseForks(false));
+        String[] pids =
+                doTest(unpack(project, "-" + project).setForkJvm().forkCount(1).reuseForks(false));
         assertDifferentPids(pids);
         assertEndWith(pids, "_1_1", 3);
         assertNotEquals("pid 1 is not the same as the main process' pid", pids[0], getMainPID());
@@ -87,7 +106,8 @@ public void testForkCountOneNoReuse() {
 
     @Test
     public void testForkCountOneReuse() {
-        String[] pids = doTest(unpack(getProject()).setForkJvm().forkCount(1).reuseForks(true));
+        String[] pids =
+                doTest(unpack(project, "-" + project).setForkJvm().forkCount(1).reuseForks(true));
         assertSamePids(pids);
         assertEndWith(pids, "_1_1", 3);
         assertNotEquals("pid 1 is not the same as the main process' pid", pids[0], getMainPID());
@@ -95,16 +115,22 @@ public void testForkCountOneReuse() {
 
     @Test
     public void testForkCountTwoNoReuse() {
-        String[] pids = doTest(
-                unpack(getProject()).setForkJvm().forkCount(2).reuseForks(false).addGoal("-DsleepLength=7200"));
+        String[] pids = doTest(unpack(project, "-" + project)
+                .setForkJvm()
+                .forkCount(2)
+                .reuseForks(false)
+                .addGoal("-DsleepLength=7200"));
         assertDifferentPids(pids);
         assertNotEquals("pid 1 is not the same as the main process' pid", pids[0], getMainPID());
     }
 
     @Test
     public void testForkCountTwoReuse() {
-        String[] pids = doTest(
-                unpack(getProject()).setForkJvm().forkCount(2).reuseForks(true).addGoal("-DsleepLength=7200"));
+        String[] pids = doTest(unpack(project, "-" + project)
+                .setForkJvm()
+                .forkCount(2)
+                .reuseForks(true)
+                .addGoal("-DsleepLength=7200"));
         assertDifferentPids(pids, 2);
         assertNotEquals("pid 1 is not the same as the main process' pid", pids[0], getMainPID());
     }
@@ -127,7 +153,7 @@ private void assertDifferentPids(String[] pids, int numOfDifferentPids) {
 
     @Test
     public void testForkOnce() {
-        String[] pids = doTest(unpack(getProject()).setForkJvm().forkOnce());
+        String[] pids = doTest(unpack(project, "-" + project).setForkJvm().forkOnce());
         assertSamePids(pids);
         assertNotEquals("pid 1 is not the same as the main process' pid", pids[0], getMainPID());
     }
@@ -170,8 +196,4 @@ private String[] doTest(SurefireLauncher forkLauncher) {
         }
         return pids;
     }
-
-    protected String getProject() {
-        return "fork-count";
-    }
 }
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountTestNGIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountTestNGIT.java
deleted file mode 100644
index 935a3462c..000000000
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/ForkCountTestNGIT.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-package org.apache.maven.surefire.its;
-
-/**
- * Test forkCount and reuseForks
- *
- * @author <a href="mailto:velo.br@gmail.com">Marvin Froeder</a>
- */
-public class ForkCountTestNGIT extends ForkCountIT {
-    @Override
-    protected String getProject() {
-        return "fork-count-testng";
-    }
-}
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java
index cd1f3bd33..1e2f0ed6b 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1396CustomProviderClassPathIT.java
@@ -38,6 +38,8 @@ public static void installProvider() {
     @Test
     public void pluggableProviderClasspathCorrect() {
         unpack("surefire-1396-pluggableproviders-classpath")
+                // properties in dependency POM are not interpolated by default - since Maven 3.10.0
+                .sysProp("maven.model.dependencyInterpolation.full", "true")
                 .setForkJvm()
                 .maven()
                 .showExceptionMessages()
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
index f8a1fa784..01222189c 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire141PluggableProvidersIT.java
@@ -44,6 +44,8 @@ public static void installProvider() {
     @Test
     public void pluggableProviderPresent() {
         unpack("surefire-141-pluggableproviders")
+                // properties in dependency POM are not interpolated by default - since Maven 3.10.0
+                .sysProp("maven.model.dependencyInterpolation.full", "true")
                 .setForkJvm()
                 .maven()
                 .showExceptionMessages()
@@ -60,6 +62,8 @@ public void invokeRuntimeException() {
 
         OutputValidator validator = unpack("surefire-141-pluggableproviders")
                 .setForkJvm()
+                // properties in dependency POM are not interpolated by default - since Maven 3.10.0
+                .sysProp("maven.model.dependencyInterpolation.full", "true")
                 .sysProp("invokeCrash", "runtimeException")
                 .maven()
                 .withFailure()
@@ -81,6 +85,8 @@ public void invokeReporterException() {
 
         OutputValidator validator = unpack("surefire-141-pluggableproviders")
                 .setForkJvm()
+                // properties in dependency POM are not interpolated by default - since Maven 3.10.0
+                .sysProp("maven.model.dependencyInterpolation.full", "true")
                 .sysProp("invokeCrash", "reporterException")
                 .maven()
                 .withFailure()
@@ -102,6 +108,8 @@ public void constructorRuntimeException() {
 
         OutputValidator validator = unpack("surefire-141-pluggableproviders")
                 .setForkJvm()
+                // properties in dependency POM are not interpolated by default - since Maven 3.10.0
+                .sysProp("maven.model.dependencyInterpolation.full", "true")
                 .sysProp("constructorCrash", "runtimeException")
                 .maven()
                 .withFailure()
diff --git a/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/pom.xml b/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/pom.xml
index 4bca6f450..9b42d247d 100644
--- a/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/pom.xml
+++ b/surefire-its/src/test/resources/surefire-570-multipleReportDirectories/pom.xml
@@ -77,10 +77,6 @@
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-surefire-report-plugin</artifactId>
           </plugin>
-          <plugin>
-            <groupId>org.apache.maven.plugins</groupId>
-            <artifactId>maven-site-plugin</artifactId>
-          </plugin>
         </plugins>
       </build>
     </profile>