Skip to content

Commit

Permalink
Merge pull request #1252 from hcoles/feature/additional_features
Browse files Browse the repository at this point in the history
extra features param for maven
  • Loading branch information
hcoles committed Sep 19, 2023
2 parents 3638a83 + a171784 commit a2c7a89
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
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

0 comments on commit a2c7a89

Please sign in to comment.