Skip to content

Commit

Permalink
v1.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
cael committed Sep 20, 2018
1 parent 84226c6 commit b6a5e3e
Show file tree
Hide file tree
Showing 42 changed files with 1,934 additions and 130 deletions.
25 changes: 21 additions & 4 deletions README.md
Expand Up @@ -139,7 +139,9 @@ You can configure your project in the root pom.xml, in the section \<plugins\>:

### PitMP properties

* targetModules: to run PIT only on specified modules
* targetModules: to run PIT only on specified modules, this
attribute filters directories where to run PIT, not classes
to be mutated
You can use the property "targetModules" in the pom.xml:
```
<targetModules>
Expand All @@ -152,7 +154,10 @@ You can configure your project in the root pom.xml, in the section \<plugins\>:
mvn "-DtargetModules=yourFirstModule,anotherModule" pitmp:run
```
Running PitMP from a module directory will NOT work.
* skippedModules: to run PIT only on specified modules

* skippedModules: to skip specified modules when running PIT, this
attribute filters directories where to run PIT, not classes
to be mutated
You can use the property "skippedModules" in the pom.xml:
```
<skippedModules>
Expand All @@ -165,6 +170,14 @@ You can configure your project in the root pom.xml, in the section \<plugins\>:
mvn "-DtargetModules=aModuleToSkip,anotherModuleToSkip" pitmp:run
```

* targetDependencies: take only into account classes of targetDependencies, i.e.
only code in targetDependencies will be mutated; it impacts PIT's targetClasses
Note that only targetDependencies shall contains only modules of the project

* ignoredDependencies: ignore classes of ignoredDependencies, i.e.
code in targetDependencies will not be mutated; it impacts PIT's targetClasses
If a module is both in targetDependencies and ignoredDependencies, it will be ignored.

* continueFromModule: to run PIT starting from a given project (because continuing an aborted execution with Maven -rf is not working)
```
<continueFromModule>aModule</continueFromModule>
Expand Down Expand Up @@ -220,16 +233,20 @@ If you want to check the number of Pseudo Tested Methods and/or Partially Tested
## Releases
For PIT release... | use PitMP release... | how to use PitMP
-------------------------- | -------------------- | ----------------
1.4.2 | 1.3.5 | Maven Central
1.4.2 | 1.3.5 | Maven Central
1.4.0 | 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.0 | Maven Central
1.3.2 | 1.1.6, 1.1.5 | Maven Central
1.3.1 | 1.1.4 | Maven Central
1.2.1, 1.2.2, 1.2.4, 1.2.5, 1.3.0 | not tested |
1.2.0, 1.2.3 | 1.0.1 | git clone & mvn install

* pitmp-maven-plugin-1.3.5
- Dependency on Descartes v1.2.4 (hotfix for a regression in 1.3.3)
- Dependency on Descartes v1.2.4
- Tested with PIT v1.4.2, Descartes v1.2.4, JUnit4 and JUnit5
- Adding properties targetDependencies, ignoredDependencies and continueFromModule
- Adding a module with no test in automated test suite
- Running automated tests with XML report option and adding reference files
(missing automated results checking)

* pitmp-maven-plugin-1.3.4
- Dependency on Descartes v1.2.4 (hotfix for a regression in 1.3.3)
Expand Down
Expand Up @@ -18,9 +18,6 @@ public boolean test(MavenProject project)
PmpProject theProject = PmpContext.getInstance().getCurrentProject();
// assert(theProject != null)

boolean hasTests = theProject.hasTestCompileSourceRoots().booleanValue();
boolean hasClasses = theProject.hasCompileSourceRoots().booleanValue();

return(hasTests || hasClasses);
return theProject.hasTestCompileSourceRoots().booleanValue();
}
}
70 changes: 37 additions & 33 deletions src/main/java/org/pitest/maven/PmpDescartesMojo.java
Expand Up @@ -15,37 +15,41 @@
@Mojo(name = "descartes", defaultPhase = LifecyclePhase.VERIFY, requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
public class PmpDescartesMojo extends PmpMojo {

/**
* Pseudo Tested threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "pseudoTestedThreshold")
private int pseudoTestedThreshold;

/**
* Partially Tested threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "partiallyTestedThreshold")
private int partiallyTestedThreshold;

// **********************************************************************
// ******** methods
@Override
public void updateTargetClasses() {
super.updateTargetClasses();
System.out
.println("MUTATION ENGINE >>> " + PmpContext.getInstance().getCurrentProject().getPmpMutationEngine());
PmpContext.getInstance().getCurrentProject().setPmpMutationEngine("descartes");
ReportOptions reportOptions = PmpContext.getInstance().getCurrentProject().getPitOptions();
Collection<String> outputFormats = null;
if (reportOptions != null) {
outputFormats = reportOptions.getOutputFormats();
} else {
reportOptions = new ReportOptions();
outputFormats = new ArrayList<String>();
}
outputFormats.add("METHODS");
reportOptions.addOutputFormats(outputFormats);
PmpContext.getInstance().getCurrentProject().setPitOptions(reportOptions);

}
/**
* Pseudo Tested threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "pseudoTestedThreshold")
private int pseudoTestedThreshold;

/**
* Partially Tested threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "partiallyTestedThreshold")
private int partiallyTestedThreshold;

// **********************************************************************
// ******** methods
@Override public void updateTargetClasses()
{
super.updateTargetClasses();
System.out.println("MUTATION ENGINE >>> " +
PmpContext.getInstance().getCurrentProject().getPmpMutationEngine());
PmpContext.getInstance().getCurrentProject().
setPmpMutationEngine("descartes");
ReportOptions reportOptions =
PmpContext.getInstance().getCurrentProject().getPitOptions();
Collection<String> outputFormats = null;

if (reportOptions != null)
{
outputFormats = reportOptions.getOutputFormats();
} else
{
reportOptions = new ReportOptions();
outputFormats = new ArrayList<String>();
}
outputFormats.add("METHODS");
reportOptions.addOutputFormats(outputFormats);
PmpContext.getInstance().getCurrentProject().setPitOptions(reportOptions);
}
}
171 changes: 124 additions & 47 deletions src/main/java/org/pitest/maven/PmpMojo.java
Expand Up @@ -38,7 +38,13 @@ public class PmpMojo extends AbstractPitMojo
@Parameter(property = "skippedModules")
protected ArrayList<String> skippedModules;

/** If specified, modules before this module will be skipped. */
@Parameter(property = "targetDependencies")
protected ArrayList<String> targetDependencies;

@Parameter(property = "ignoredDependencies")
protected ArrayList<String> ignoredDependencies;

// If specified, modules before this module will be skipped.
@Parameter(property = "continueFromModule")
protected String continueFromModule;

Expand All @@ -48,18 +54,18 @@ public class PmpMojo extends AbstractPitMojo
@Parameter(defaultValue = "false", property = "shouldDisplayOnly")
protected boolean _ShouldDisplayOnly;

/**
* Pseudo Tested threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "pseudoTestedThreshold")
private int pseudoTestedThreshold;

/**
* Partially Tested threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "partiallyTestedThreshold")
private int partiallyTestedThreshold;
/**
* Pseudo Tested threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "pseudoTestedThreshold")
private int pseudoTestedThreshold;

/**
* Partially Tested threshold at which to fail build
*/
@Parameter(defaultValue = "0", property = "partiallyTestedThreshold")
private int partiallyTestedThreshold;

// **********************************************************************
// public
// **********************************************************************
Expand Down Expand Up @@ -115,9 +121,9 @@ public void setSkippedModules(ArrayList<String> newClasses)
// **********
public boolean isInSkippedModules(MavenProject module)
{
return isInSkippedModules(module.getArtifactId());
return isInSkippedModules(module.getArtifactId());
}

public boolean isInSkippedModules(String name)
{
boolean result = false;
Expand All @@ -130,24 +136,90 @@ public boolean isInSkippedModules(String name)
return(result);
}

public void setContinueFromModule(String continueFromModule) {
this.continueFromModule = continueFromModule;
// **********************************************************************
public ArrayList<String> getTargetDependencies()
{
// cael: debug only
// if (targetDependencies == null)
// {
// System.out.println("######## !!!!!! targetDependencies == null");
// }
return(targetDependencies);
}

// **********
public void setTargetDependencies(ArrayList<String> moduleList)
{
targetDependencies = moduleList;
}

public String getContinueFromModule() {
return continueFromModule;
// **********
public boolean isInTargetDependencies(String name)
{
boolean result = false;

for (int i = 0; i < getTargetDependencies().size() && ! result; i++)
{
result = getTargetDependencies().get(i).equals(name);
}

return(result);
}

public boolean isContinueFromModuleSatisfied(MavenProject module) {
if (continueFromModule == null) {
// property is not specified
return true;
}
// **********************************************************************
public ArrayList<String> getIgnoredDependencies()
{
// cael: debug only
// if (ignoredDependencies == null)
// {
// System.out.println("######## !!!!!! ignoredDependencies == null");
// }
return(ignoredDependencies);
}

// note that the current module has already been added
return alreadyVisitedModules.contains(continueFromModule);
// **********
public void setIgnoredDependencies(ArrayList<String> moduleList)
{
ignoredDependencies = moduleList;
}

// **********
public boolean isInIgnoredDependencies(String name)
{
boolean result = false;

for (int i = 0; i < getIgnoredDependencies().size() && ! result; i++)
{
result = getIgnoredDependencies().get(i).equals(name);
}

return(result);
}

// **********************************************************************
public void setContinueFromModule(String continueFromModule)
{
this.continueFromModule = continueFromModule;
}

// **********
public String getContinueFromModule()
{
return continueFromModule;
}

// **********
public boolean isContinueFromModuleSatisfied(MavenProject module)
{
if (continueFromModule == null)
{
// property is not specified
return true;
}

// note that the current module has already been added
return alreadyVisitedModules.contains(continueFromModule);
}

// **********************************************************************
// ******** associations
Expand Down Expand Up @@ -203,25 +275,28 @@ public void updateTargetClasses()
for (int i = 0; i < moduleList.size(); i++)
{
MavenProject module = moduleList.get(i);

if (isInSkippedModules(module)) {
continue;
}

classList = PmpContext.getClasses(module);
if (! classList.isEmpty())

if ((getTargetDependencies().size() == 0 ||
isInTargetDependencies(module.getArtifactId())) &&
! isInIgnoredDependencies(module.getArtifactId()))
{
PmpContext.addNewStrings(targetClasses, classList);
classList = PmpContext.getClasses(module);
if (! classList.isEmpty())
{
PmpContext.addNewStrings(targetClasses, classList);
}
}
}
}

public void updateTargetTests() {
if (targetTests == null || targetTests.isEmpty()) {
targetTests = new ArrayList<>();
targetTests.addAll(PmpContext.getTestClasses(getProject()));
}
}

// public void updateTargetTests()
// {
// if (targetTests == null || targetTests.isEmpty())
// {
// targetTests = new ArrayList<>();
// targetTests.addAll(PmpContext.getTestClasses(getProject()));
// }
// }

// **********************************************************************
// protected
Expand All @@ -244,8 +319,8 @@ protected Optional<CombinedStatistics> analyse()
@Override
protected RunDecision shouldRun()
{
MethodThresholds.getInstance().setPartialyTestedThresold(partiallyTestedThreshold);
MethodThresholds.getInstance().setPseudoTestedThresold(pseudoTestedThreshold);
MethodThresholds.getInstance().setPartialyTestedThresold(partiallyTestedThreshold);
MethodThresholds.getInstance().setPseudoTestedThresold(pseudoTestedThreshold);

RunDecision theDecision;
PmpProject myPmpProject;
Expand All @@ -262,7 +337,7 @@ protected RunDecision shouldRun()
PmpContext.getInstance().setCurrentProject(myPmpProject);

updateTargetClasses();
updateTargetTests();
// updateTargetTests();

if (getProject().getPackaging().equals("pom") &&
myPmpProject.hasTestCompileSourceRoots() &&
Expand All @@ -285,9 +360,11 @@ protected RunDecision shouldRun()
theDecision.addReason(message);
}

if (!isContinueFromModuleSatisfied(getProject())) {
message = projectName + " is before " + continueFromModule + " from which the execution shall be continued";
theDecision.addReason(message);
if (! isContinueFromModuleSatisfied(getProject()))
{
message = projectName + " is before " + continueFromModule +
" from which the execution shall be continued";
theDecision.addReason(message);
}

if (shouldDisplayOnly())
Expand Down
4 changes: 2 additions & 2 deletions test_dir/dnoo/dnooHello/pom.xml
Expand Up @@ -5,9 +5,9 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>eu.stamp-project</groupId>
<groupId>eu.stamp-project.examples</groupId>
<artifactId>dnoo</artifactId>
<version>1.0.1</version>
<version>1.1.0</version>
</parent>

<artifactId>dnooHello</artifactId>
Expand Down

0 comments on commit b6a5e3e

Please sign in to comment.