Copilot commented on code in PR #3657:
URL: https://github.com/apache/maven-surefire/pull/3657#discussion_r4730712254


##########
surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProviderTest.java:
##########
@@ -420,6 +420,46 @@ public void 
junit4OnlyProjectRunningClassesInParallelKeepsOneLaunch() throws Exc
                 executionListener.summaries.get(0).getTestsFoundCount());
     }
 
+    @Test
+    @ResourceLock(Resources.SYSTEM_PROPERTIES)
+    public void 
junit4OnlyProjectRunningClassesInParallelFromSystemPropertiesKeepsOneLaunch() 
throws Exception {
+        ProviderParameters parameters = providerParametersMock();
+        
when(parameters.getProviderProperties()).thenReturn(singletonMap(JUNIT4_ONLY_DETECTED,
 "true"));
+
+        
assertThat(launchesWithVintageParallelClassesSystemProperties(parameters))
+                .hasSize(1);
+    }
+
+    @Test
+    @ResourceLock(Resources.SYSTEM_PROPERTIES)
+    public void 
junit4OnlyProjectKeepsParallelDisabledInPomOverSystemProperties() throws 
Exception {
+        Map<String, String> properties = new HashMap<>();
+        properties.put(JUNIT4_ONLY_DETECTED, "true");
+        properties.put(CONFIGURATION_PARAMETERS, 
"junit.vintage.execution.parallel.enabled=false");
+        ProviderParameters parameters = providerParametersMock();
+        when(parameters.getProviderProperties()).thenReturn(properties);
+
+        
assertThat(launchesWithVintageParallelClassesSystemProperties(parameters))
+                .hasSize(2);
+    }
+
+    // system properties are read the same way as junit-platform.properties
+    private List<TestExecutionSummary> 
launchesWithVintageParallelClassesSystemProperties(ProviderParameters 
parameters)
+            throws Exception {
+        TestPlanSummaryListener executionListener = new 
TestPlanSummaryListener();
+        JUnitPlatformProvider provider =
+                new JUnitPlatformProvider(parameters, 
createLauncherSessionWithListeners(executionListener));
+        System.setProperty("junit.vintage.execution.parallel.enabled", "true");
+        System.setProperty("junit.vintage.execution.parallel.classes", "true");

Review Comment:
   These JVM-global property changes can leak into other test classes running 
concurrently (`pom.xml:94–96`), because `@ResourceLock` only excludes tests 
that acquire the same lock. Annotate `JUnitPlatformProviderTest` with 
`@Isolated` so other classes cannot observe this temporary configuration, as 
required by `AGENTS.md:182–184`.



##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java:
##########
@@ -1784,11 +1784,10 @@ void convertJunitCoreParameters() throws 
MojoFailureException, MojoExecutionExce
 
         if (!"none".equals(usedParallel)) {
             checkNonForkedThreads(parallel);
+            // only set when asked: a "false" here would hide 
junit-platform.properties and system properties
+            
getProperties().setProperty("junit.vintage.execution.parallel.enabled", "true");
         }

Review Comment:
   An explicit `<parallel>none</parallel>` now leaves Vintage parallelism 
enabled when `junit-platform.properties` or system properties enable it, 
contrary to the parameter contract at lines 712–714. Omit the flag only when 
`getParallel()` is null, and emit `false` for an explicit `none` so profiles 
can still disable parallel execution.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to