Skip to content
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

extra features param for maven #1252

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions pitest-maven/src/main/java/org/pitest/maven/AbstractPitMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ public class AbstractPitMojo extends AbstractMojo {
private ArrayList<String> mutators;

/**
* Mutation operators to apply
* Features to activate/deactivate
*/
@Parameter(property = "features")
private ArrayList<String> features;

/**
* Additional features activate/deactivate, use to
* avoid overwriting features set in the build script when
* specifying features from the command line
*/
@Parameter(property = "extraFeatures")
private ArrayList<String> extraFeatures;


/**
* Weighting to allow for timeouts
Expand Down Expand Up @@ -739,7 +747,9 @@ public ArrayList<String> getExcludedRunners() {
}

public ArrayList<String> getFeatures() {
return withoutNulls(features);
ArrayList<String> consolidated = emptyWithoutNulls(features);
consolidated.addAll(emptyWithoutNulls(extraFeatures));
return consolidated;
}

public boolean isUseClasspathJar() {
Expand Down Expand Up @@ -778,6 +788,14 @@ public List<String> getReasons() {
}
}

private <X> ArrayList<X> emptyWithoutNulls(List<X> originalList) {
if (originalList == null) {
return new ArrayList<>();
}

return withoutNulls(originalList);
}

private <X> ArrayList<X> withoutNulls(List<X> originalList) {
if (originalList == null) {
return null;
Expand Down
17 changes: 17 additions & 0 deletions pitest-maven/src/test/java/org/pitest/maven/PitMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,23 @@ public void testEmptyFeatureIsIgnored() throws Exception {
mojo.getFeatures());
}

public void testCombinesFeaturesAndExtraFeatures() throws Exception {

AbstractPitMojo mojo = createPITMojo(createPomWithConfiguration("\n"
+ " <features>\n"
+ " <feature>FEATURE</feature>\n"
+ " </features>\n"
+ " <extraFeatures>\n"
+ " <feature>ALSO_A_FEATURE</feature>\n"
+ " <feature>MORE</feature>\n"
+ " </extraFeatures>\n"
));

assertEquals(
asList("FEATURE", "ALSO_A_FEATURE", "MORE"),
mojo.getFeatures());
}

private void setupCoverage(long mutationScore, int lines, int linesCovered)
throws MojoExecutionException {
Iterable<Score> scores = Collections.<Score>emptyList();
Expand Down