Repository navigation
Fix #13230: add --skip-phases and --skip-tests CLI options; fix lifecycle DAG #13233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
832dba2
Fix #13230: add --skip-phases and --skip-tests CLI options; fix lifec…
gnodet e2de348
test: add CommonsCliMavenOptionsTest and IT for --skip-phases / --ski…
gnodet ea92e83
test: add ITs for install→after(VERIFY) DAG change
gnodet 8c5cf89
fix: expand --skip-phases to include sub-phases in the lifecycle DAG
gnodet 46b7d89
fix: correct installWithSkipVerifySkipsVerifyMojos to skip test,verif…
gnodet 72b8d24
fix: expand skipped phases in sequential builder; fix typo in IT
gnodet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
...aven-cli/src/test/java/org/apache/maven/cling/invoker/mvn/CommonsCliMavenOptionsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| /* | ||
| * 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.cling.invoker.mvn; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| import org.apache.commons.cli.ParseException; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
|
||
| /** | ||
| * Unit tests for {@link CommonsCliMavenOptions} covering the {@code --skip-phases} and | ||
| * {@code --skip-tests} options introduced in MNG-13230. | ||
| */ | ||
| class CommonsCliMavenOptionsTest { | ||
|
|
||
| // ------------------------------------------------------------------------- | ||
| // --skip-phases | ||
| // ------------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| void skippedPhasesNotPresentByDefault() throws ParseException { | ||
| CommonsCliMavenOptions options = CommonsCliMavenOptions.parse("test", new String[] {"verify"}); | ||
| assertEquals(Optional.empty(), options.skippedPhases()); | ||
| } | ||
|
|
||
| @Test | ||
| void skippedPhasesSingleValue() throws ParseException { | ||
| // Use = form so Commons CLI does not consume the goal "verify" as a phase value. | ||
| CommonsCliMavenOptions options = | ||
| CommonsCliMavenOptions.parse("test", new String[] {"--skip-phases=test", "verify"}); | ||
| assertEquals(Optional.of(List.of("test")), options.skippedPhases()); | ||
| } | ||
|
|
||
| @Test | ||
| void skippedPhasesMultipleValuesCommaSeparated() throws ParseException { | ||
| CommonsCliMavenOptions options = | ||
| CommonsCliMavenOptions.parse("test", new String[] {"--skip-phases=test,integration-test", "verify"}); | ||
| assertEquals(Optional.of(List.of("test", "integration-test")), options.skippedPhases()); | ||
| } | ||
|
|
||
| /** | ||
| * Whitespace around comma-separated values must be stripped so that | ||
| * {@code --skip-phases "test, integration-test"} works like | ||
| * {@code --skip-phases "test,integration-test"}. | ||
| * <p> | ||
| * Commons CLI splits on the {@code valueSeparator(',')} and returns individual tokens; | ||
| * the implementation must strip leading/trailing whitespace from each token. | ||
| */ | ||
| @Test | ||
| void skippedPhasesStripsWhitespace() throws ParseException { | ||
| CommonsCliMavenOptions options = | ||
| CommonsCliMavenOptions.parse("test", new String[] {"--skip-phases=test, integration-test", "verify"}); | ||
| assertEquals(Optional.of(List.of("test", "integration-test")), options.skippedPhases()); | ||
| } | ||
|
|
||
| @Test | ||
| void skippedPhasesShortOption() throws ParseException { | ||
| // Short option with hasArgs(): -sp consumes the next token as its value. | ||
| // No positional goal follows, so the value is unambiguously "test". | ||
| CommonsCliMavenOptions options = CommonsCliMavenOptions.parse("test", new String[] {"-sp", "test"}); | ||
| assertEquals(Optional.of(List.of("test")), options.skippedPhases()); | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------- | ||
| // --skip-tests | ||
| // ------------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| void skipTestsNotPresentByDefault() throws ParseException { | ||
| CommonsCliMavenOptions options = CommonsCliMavenOptions.parse("test", new String[] {"verify"}); | ||
| assertEquals(Optional.empty(), options.skipTests()); | ||
| } | ||
|
|
||
| @Test | ||
| void skipTestsLongOption() throws ParseException { | ||
| CommonsCliMavenOptions options = CommonsCliMavenOptions.parse("test", new String[] {"--skip-tests", "verify"}); | ||
| assertEquals(Optional.of(Boolean.TRUE), options.skipTests()); | ||
| } | ||
|
|
||
| @Test | ||
| void skipTestsShortOption() throws ParseException { | ||
| CommonsCliMavenOptions options = CommonsCliMavenOptions.parse("test", new String[] {"-st", "verify"}); | ||
| assertEquals(Optional.of(Boolean.TRUE), options.skipTests()); | ||
| } | ||
|
|
||
| // ------------------------------------------------------------------------- | ||
| // --skip-phases and --skip-tests can be combined | ||
| // ------------------------------------------------------------------------- | ||
|
|
||
| @Test | ||
| void skipPhasesAndSkipTestsCanCoexist() throws ParseException { | ||
| CommonsCliMavenOptions options = | ||
| CommonsCliMavenOptions.parse("test", new String[] {"--skip-phases=verify", "--skip-tests", "install"}); | ||
| assertEquals(Optional.of(List.of("verify")), options.skippedPhases()); | ||
| assertEquals(Optional.of(Boolean.TRUE), options.skipTests()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.