gnodet commented on code in PR #13233:
URL: https://github.com/apache/maven/pull/13233#discussion_r4069207590


##########
impl/maven-core/src/test/java/org/apache/maven/lifecycle/internal/concurrent/BuildPlanExecutorTest.java:
##########
@@ -156,6 +166,115 @@ void errorIsStillFatalWhenASecondFailureJoinsIt() throws 
Exception {
                         + session.getResult().getExceptions());
     }
 
+    /**
+     * When a phase is listed in {@code --skip-phases}, no mojo bound to that 
phase must appear in the
+     * concurrent build plan after the PLAN step executes. The existing mojos 
list on the BuildStep for
+     * that phase must remain empty.
+     */
+    @Test
+    void skippedPhasesMojoIsNotAddedToPlan() throws Exception {
+        MavenProject project = newProject();
+        MavenSession session = newSession(project);
+        session.getRequest().setSkippedPhases(List.of("validate"));
+
+        // Attach a plugin execution bound explicitly to "validate"
+        PluginDescriptor pluginDescriptor = new PluginDescriptor();
+        pluginDescriptor.setGroupId("org.apache.maven.plugins");
+        pluginDescriptor.setArtifactId("maven-skip-test-plugin");
+        pluginDescriptor.setVersion("1.0");
+
+        MojoDescriptor mojoDescriptor = new MojoDescriptor();
+        mojoDescriptor.setGoal("run");
+        mojoDescriptor.setPluginDescriptor(pluginDescriptor);
+
+        Plugin plugin = new Plugin();
+        plugin.setGroupId("org.apache.maven.plugins");
+        plugin.setArtifactId("maven-skip-test-plugin");
+        plugin.setVersion("1.0");
+        PluginExecution execution = new PluginExecution();
+        execution.setId("default-run");
+        execution.setPhase("validate");
+        execution.addGoal("run");
+        plugin.addExecution(execution);
+
+        Build build = new Build();
+        build.addPlugin(plugin);
+        project.setBuild(build);
+
+        MavenPluginManager pluginManager = mock(MavenPluginManager.class);
+        when(pluginManager.getMojoDescriptor(eq(plugin), eq("run"), any(), 
any()))
+                .thenReturn(mojoDescriptor);
+
+        ReactorContext reactorContext = newReactorContext(session);
+        newExecutorWithPluginManager(pluginManager, (BeforeProjectExecution) 
event -> {})
+                .execute(session, reactorContext, List.of(newTaskSegment()));
+        assertTrue(
+                session.getResult().getExceptions().isEmpty(),
+                "No exceptions expected when a phase is skipped: "

Review Comment:
   Fixed in 2ce1f45e9f: added `import static org.mockito.Mockito.never` and 
`verify(pluginManager, never()).getMojoDescriptor(any(), any(), any(), any())` 
after the assertTrue. Also promoted the qualified `org.mockito.Mockito.verify` 
in the sibling test to a static import for consistency.



-- 
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