You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2020/04/17 17:29:28 UTC

[GitHub] [maven] MartinKanters commented on a change in pull request #338: [MNG-6863] - Fixing that --also-make is being ignored when calling --resume-from

MartinKanters commented on a change in pull request #338: [MNG-6863] - Fixing that --also-make is being ignored when calling --resume-from
URL: https://github.com/apache/maven/pull/338#discussion_r410367520
 
 

 ##########
 File path: maven-core/src/test/java/org/apache/maven/graph/DefaultGraphBuilderTest.java
 ##########
 @@ -0,0 +1,290 @@
+package org.apache.maven.graph;
+
+/*
+ * 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 com.google.common.collect.ImmutableMap;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.execution.ProjectDependencyGraph;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.building.Result;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingRequest;
+import org.apache.maven.project.ProjectBuildingResult;
+import org.codehaus.plexus.util.StringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static java.util.Arrays.asList;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.singletonList;
+import static junit.framework.TestCase.assertEquals;
+import static org.apache.maven.execution.MavenExecutionRequest.*;
+import static org.apache.maven.execution.MavenExecutionRequest.REACTOR_MAKE_UPSTREAM;
+import static org.apache.maven.graph.DefaultGraphBuilderTest.ScenarioBuilder.scenario;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+@RunWith( Parameterized.class )
+public class DefaultGraphBuilderTest
+{
+    private static final String INDEPENDENT_MODULE = "module-independent";
+    private static final String MODULE_A = "module-a";
+    private static final String MODULE_B = "module-b"; // depends on module-a
+    private static final String MODULE_C = "module-c"; // depends on module-b
+
+    @InjectMocks
+    private DefaultGraphBuilder graphBuilder;
+
+    @Mock
+    private ProjectBuilder projectBuilder;
+
+    @Mock
+    private MavenSession session;
+
+    @Mock
+    private MavenExecutionRequest mavenExecutionRequest;
+
+    private Map<String, MavenProject> artifactIdProjectMap;
+
+    // Parameters for the test
+    private final String parameterDescription;
+    private final List<String> parameterSelectedProjects;
+    private final List<String> parameterExcludedProjects;
+    private final String parameterResumeFrom;
+    private final String parameterMakeBehavior;
+    private final List<String> parameterExpectedResult;
+
+    @Parameters(name = "{index}. {0}")
+    public static Collection<Object[]> parameters()
+    {
+        return asList(
+                scenario( "Full reactor" )
+                        .expectResult( asList( INDEPENDENT_MODULE, MODULE_A, MODULE_B, MODULE_C ) ),
+                scenario( "Selected project" )
+                        .selectedProjects( singletonList( MODULE_B ) )
+                        .expectResult( singletonList( MODULE_B ) ),
+                scenario( "Excluded project" )
+                        .excludedProjects( singletonList( MODULE_B ) )
+                        .expectResult( asList( INDEPENDENT_MODULE, MODULE_A, MODULE_C ) ),
+                scenario( "Resuming from project" )
+                        .resumeFrom( MODULE_B )
+                        .expectResult( asList( MODULE_B, MODULE_C ) ),
+                scenario( "Selected project with also make dependencies" )
+                        .selectedProjects( singletonList( MODULE_C ) )
+                        .makeBehavior( REACTOR_MAKE_UPSTREAM )
+                        .expectResult( asList( MODULE_A, MODULE_B, MODULE_C ) ),
+                scenario( "Selected project with also make dependents" )
+                        .selectedProjects( singletonList( MODULE_B ) )
+                        .makeBehavior( REACTOR_MAKE_DOWNSTREAM )
+                        .expectResult( asList( MODULE_B, MODULE_C ) ),
+                scenario( "Resuming from project with also make dependencies" )
+                        .makeBehavior( REACTOR_MAKE_UPSTREAM )
+                        .resumeFrom( MODULE_C )
+                        .expectResult( asList( MODULE_A, MODULE_B, MODULE_C ) ),
+                scenario( "Selected project with resume from an also make dependency (MNG-4960 IT#1)" )
+                        .selectedProjects( singletonList( MODULE_C ) )
 
 Review comment:
   Yes, I agree it's a weird scenario, but we have an integration test which verifies exactly this. (MNG-4960)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services