-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support to run dspot as maven plugin (#247)
* create module dspot * change pom.xml * update travis CI * update CI configuration * refactor groupid * add maven mojo plugin * add maven mojo plugin * test * fix problem with filter parameter * fix problem about parameters * #245 Refactoring of InputConfiguration Class for maven plugin usage * ignored failed tets * merged with dspot master * remove failed test * fix inputConfiguration problems
- Loading branch information
1 parent
fecab4d
commit 8c8a154
Showing
7 changed files
with
410 additions
and
139 deletions.
There are no files selected for viewing
This file contains 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,66 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>fr.inria.stamp</groupId> | ||
<artifactId>dspot-parent</artifactId> | ||
<version>1.0.4-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>dspot-maven</artifactId> | ||
<packaging>maven-plugin</packaging> | ||
<name>Maven DSpot Plugin</name> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-plugin-plugin</artifactId> | ||
<version>3.5</version> | ||
<executions> | ||
<execution> | ||
<id>default-descriptor</id> | ||
<phase>process-classes</phase> | ||
</execution> | ||
<execution> | ||
<id>help-goal</id> | ||
<goals> | ||
<goal>helpmojo</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>fr.inria.stamp</groupId> | ||
<artifactId>dspot</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven</groupId> | ||
<artifactId>maven-plugin-api</artifactId> | ||
<version>3.5.2</version> | ||
</dependency> | ||
|
||
<!-- dependencies to annotations --> | ||
<dependency> | ||
<groupId>org.apache.maven.plugin-tools</groupId> | ||
<artifactId>maven-plugin-annotations</artifactId> | ||
<version>3.4</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
167 changes: 167 additions & 0 deletions
167
dspot-maven/src/main/java/fr/inria/diversify/dspot/maven/DSpotMojo.java
This file contains 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,167 @@ | ||
package fr.inria.diversify.dspot.maven; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.apache.maven.plugin.AbstractMojo; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.plugins.annotations.LifecyclePhase; | ||
import org.apache.maven.plugins.annotations.Mojo; | ||
import org.apache.maven.plugins.annotations.Parameter; | ||
import org.apache.maven.plugins.annotations.ResolutionScope; | ||
|
||
import fr.inria.diversify.utils.sosiefier.InputConfiguration; | ||
import fr.inria.stamp.Configuration; | ||
import fr.inria.stamp.JSAPOptions; | ||
import fr.inria.stamp.JSAPOptions.SelectorEnum; | ||
import fr.inria.stamp.Main; | ||
|
||
@Mojo(name = "mutationCoverage", defaultPhase = LifecyclePhase.VERIFY, requiresDependencyResolution = ResolutionScope.TEST) | ||
public class DSpotMojo extends AbstractMojo { | ||
|
||
// Command Line parameters -> fr.inria.stamp.Configuration | ||
|
||
private static final String BUILDER = "Maven"; | ||
|
||
@Parameter(defaultValue = "MethodAdd", property = "amplifiers") | ||
private List<String> amplifiers; | ||
|
||
@Parameter(defaultValue = "3", property = "iteration") | ||
private Integer iteration; | ||
|
||
@Parameter(defaultValue = "PitMutantScoreSelector", property = "test-criterion") | ||
private String testCriterion; | ||
|
||
@Parameter(defaultValue = "all", property = "test") | ||
private List<String> namesOfTestCases; | ||
|
||
@Parameter(defaultValue = "${project.build.directory}/dspot-report", property = "output-path") | ||
private String outputPath; | ||
|
||
@Parameter(defaultValue = "23", property = "randomSeed") | ||
private Long randomSeed; | ||
|
||
@Parameter(defaultValue = "10000", property = "timeOut") | ||
private Integer timeOutInMs; | ||
|
||
@Parameter(defaultValue = "PitMutantScoreSelector", property = "selector") | ||
private String selector; | ||
|
||
// Properties file parameters -> fr.inria.diversify.runner.InputConfiguration | ||
|
||
@Parameter(defaultValue = "${project.basedir}", property = "project") | ||
private File project; | ||
|
||
@Parameter(defaultValue = "${project.build.sourceDirectory}", property = "src") | ||
private File srcDir; | ||
|
||
@Parameter(defaultValue = "${project.build.testSourceDirectory}", property = "test") | ||
private File testDir; | ||
|
||
@Parameter(defaultValue = "${project.build.outputDirectory}", property = "classes") | ||
private File classesDir; | ||
|
||
@Parameter(defaultValue = "${project.build.testOutputDirectory}", property = "testClasses") | ||
private File testClassesDir; | ||
|
||
@Parameter(defaultValue = "${project.build.directory}/tempDir", property = "tempDir") | ||
private File tempDir; | ||
|
||
// TODO: Command line option | ||
@Parameter(defaultValue = "example.*", property = "filter") | ||
private String filter; | ||
|
||
@Parameter(defaultValue = "${env.M2_HOME}", property = "mavenHome") | ||
private File mavenHome; | ||
|
||
public void execute() throws MojoExecutionException, MojoFailureException { | ||
|
||
Configuration configuration = new Configuration( | ||
// path to file | ||
null, | ||
// Amplifiers | ||
JSAPOptions.buildAmplifiersFromString(getAmplifiers().toArray(new String[0])), | ||
// Iteration | ||
getIteration(), | ||
// testClases | ||
getNamesOfTestCases(), getOutputPath().toString(), SelectorEnum.valueOf(getSelector()).buildSelector(), | ||
getNamesOfTestCases(), getRandomSeed().longValue(), getTimeOutInMs().intValue(), BUILDER, | ||
getMavenHome().getAbsolutePath(), 10); | ||
|
||
InputConfiguration inputConfiguration; | ||
try { | ||
inputConfiguration = new InputConfiguration(getProject(), getSrcDir(), getTestDir(), getClassesDir(), | ||
getTestClassesDir(), getTempDir(), getFilter(), getMavenHome()); | ||
Main.run(configuration, inputConfiguration); | ||
} catch (Exception e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public List<String> getAmplifiers() { | ||
return amplifiers; | ||
} | ||
|
||
public Integer getIteration() { | ||
return iteration; | ||
} | ||
|
||
public String getTestCriterion() { | ||
return testCriterion; | ||
} | ||
|
||
public List<String> getNamesOfTestCases() { | ||
return namesOfTestCases; | ||
} | ||
|
||
public String getOutputPath() { | ||
return outputPath; | ||
} | ||
|
||
public Long getRandomSeed() { | ||
return randomSeed; | ||
} | ||
|
||
public Integer getTimeOutInMs() { | ||
return timeOutInMs; | ||
} | ||
|
||
public File getProject() { | ||
return project; | ||
} | ||
|
||
public File getSrcDir() { | ||
return srcDir; | ||
} | ||
|
||
public File getTestDir() { | ||
return testDir; | ||
} | ||
|
||
public String getFilter() { | ||
return filter; | ||
} | ||
|
||
public File getMavenHome() { | ||
return mavenHome; | ||
} | ||
|
||
public File getClassesDir() { | ||
return classesDir; | ||
} | ||
|
||
public File getTestClassesDir() { | ||
return testClassesDir; | ||
} | ||
|
||
public File getTempDir() { | ||
return tempDir; | ||
} | ||
|
||
public String getSelector() { | ||
return selector; | ||
} | ||
|
||
} |
This file contains 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.