Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
monperrus committed Aug 7, 2024
2 parents 2240802 + 29b952e commit 5ba45a0
Show file tree
Hide file tree
Showing 33 changed files with 427 additions and 263 deletions.
28 changes: 6 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<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">
<project xmlns="https://maven.apache.org/POM/4.0.0"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.inria.sacha.automaticRepair</groupId>
<artifactId>astor</artifactId>
Expand Down Expand Up @@ -48,7 +48,7 @@
<dependency>
<groupId>com.github.spoonlabs</groupId>
<artifactId>flacoco</artifactId>
<version>1.0.5</version>
<version>1.0.6</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -166,26 +166,16 @@
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots />
</repository>
<repository>
<id>inria</id>
<url>http://spoon.gforge.inria.fr/repositories/releases/</url>
</repository>
<repository>
<id>spoon-snapshot</id>
<name>maven repository for spoon snapshots</name>
<url>https://repository.ow2.org/nexus/content/repositories/snapshots/</url>
<snapshots />
</repository>
<repository>
<id>EvoSuite</id>
<name>EvoSuite Repository</name>
<url>http://www.evosuite.org/m2</url>
<url>https://www.evosuite.org/m2</url>
</repository>

<repository>
<id>sachaproject.gforge.inria.fr-release</id>
<name>Maven Repository for Spoon Release</name>
<url>http://sachaproject.gforge.inria.fr/repositories/releases/</url>
<url>https://sachaproject.gforge.inria.fr/repositories/releases/</url>
<snapshots />
</repository>

Expand All @@ -195,12 +185,6 @@
<url>https://tdurieux.github.io/maven-repository/snapshots/</url>
</repository>

<repository>
<id>maven.inria.fr-snapshot</id>
<name>Maven Repository for Spoon Artifac Snapshot</name>
<url>http://maven.inria.fr/artifactory/spoon-public-snapshot/</url>
<snapshots />
</repository>
</repositories>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ public TestCaseVariantValidationResult runTestFromEvoSuite(ProgramVariant curren
// Set up dirs
String classpathForCompile = "";
classpathForCompile = projectFacade.getProperties().getDependenciesString() + File.pathSeparator
+ projectFacade.getOutDirWithPrefix(currentVariant.currentMutatorIdentifier()) + File.pathSeparator//
+ new File(projectFacade.getOutDirWithPrefix(currentVariant.currentMutatorIdentifier()))
.getAbsolutePath()
+ File.pathSeparator//
+ new File(ConfigurationProperties.getProperty("evosuitejar")).getAbsolutePath() + File.pathSeparator
+ projectFacade.getOutDirWithPrefix(currentVariant.DEFAULT_ORIGINAL_VARIANT);
+ new File(projectFacade.getOutDirWithPrefix(currentVariant.DEFAULT_ORIGINAL_VARIANT))
.getAbsolutePath();

String outPutTest = projectFacade.getOutDirWithPrefix("/evosuite/evosuite-tests/" + sufix);

Expand Down Expand Up @@ -129,8 +132,8 @@ public TestCaseVariantValidationResult runTestFromEvoSuite(ProgramVariant curren
List<String> pathTestGenerated = new ArrayList<String>();

log.debug("Generating test for the first time");
boolean executed = fev.runEvosuite(currentVariant, classesToGenerateTests, projectFacade, testEScodepath,
runOverOriginal);
boolean executed = fev.runEvosuite(currentVariant, classesToGenerateTests, projectFacade,
esPath.getAbsolutePath(), runOverOriginal);

// we collect the files generated

Expand All @@ -145,7 +148,7 @@ public TestCaseVariantValidationResult runTestFromEvoSuite(ProgramVariant curren
// Collect test generated from files generated by ES
for (String f : pathTestGenerated) {
String qualifiedTestName = f.replace(".java", "").replace(esPath.toString(), "")
.replace("/evosuite-tests/", "").replace(File.separator, ".");
.replace(File.separator,".").replace(".evosuite-tests.", "");
if (!qualifiedTestName.endsWith(EvoSuiteFacade.EVOSUITE_scaffolding_SUFFIX) && classesToGenerateTests
.contains(qualifiedTestName.replace(EvoSuiteFacade.EVOSUITE_SUFFIX, ""))) {
testGenerated.add(qualifiedTestName);
Expand All @@ -165,18 +168,21 @@ public TestCaseVariantValidationResult runTestFromEvoSuite(ProgramVariant curren

// WE COMPILE EVO TEST
log.info("Classpath " + classpathForCompile);

String envOS = System.getProperty("os.name");
String javaPath = ConfigurationProperties.getProperty("jvm4evosuitetestexecution");
List<String> command = new ArrayList<String>();
command.add(javaPath + File.separator + "javac");
if (!envOS.contains("Windows"))
command.add(javaPath + File.separator + "javac");
else
command.add("\"" + javaPath + File.separator + "javac" + "\"");
command.add("-classpath");
command.add(classpathForCompile);
command.add("-d");

//// Save compiled
File fout = new File(outPutTest);
fout.mkdirs();
command.add(outPutTest);
command.add(fout.getAbsolutePath());

// Adding the files
for (String testPath : pathTestGenerated) {
Expand All @@ -189,8 +195,8 @@ public TestCaseVariantValidationResult runTestFromEvoSuite(ProgramVariant curren
log.debug("Any test to generate, all test cases were generated before: " + testAlreadyGenerated);
}

String classpathForRunTest = classpathForCompile + (File.pathSeparator) + outPutTest + File.pathSeparator
+ System.getProperty("java.class.path");
String classpathForRunTest = classpathForCompile + (File.pathSeparator) + new File(outPutTest).getAbsolutePath()
+ File.pathSeparator + System.getProperty("java.class.path");
log.info("Process classpath " + classpathForRunTest);

ProcessEvoSuiteValidator evoProcess = new ProcessEvoSuiteValidator();
Expand Down Expand Up @@ -231,4 +237,4 @@ public TestCasesProgramValidationResult executeRegressionTesting(URL[] processCl
}
}

}
}
24 changes: 18 additions & 6 deletions src/main/java/fr/inria/astor/core/setup/ProjectRepairFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,36 @@ public void copyOriginalSourceCode(String pathOriginalCode, String currentMutato
*/
public void cleanMutationResultDirectories(String currentMutatorIdentifier) throws IOException {

removeDir(getProperties().getWorkingDirForSource() + File.separator + currentMutatorIdentifier);
removeDir(getProperties().getWorkingDirForBytecode() + File.separator + currentMutatorIdentifier);
removeDir(getProperties().getWorkingDirForSource() + File.separator + currentMutatorIdentifier, false);
removeDir(getProperties().getWorkingDirForBytecode() + File.separator + currentMutatorIdentifier, false);
}

/**
* Remove source dir for a given mutation
*
* @throws IOException
*/
public void cleanMutationResultSourceDirectory(String currentMutatorIdentifier) throws IOException {

removeDir(getProperties().getWorkingDirForSource() + File.separator + currentMutatorIdentifier, false);
}

public void cleanMutationResultDirectories() throws IOException {

removeDir(getProperties().getWorkingDirForSource());
removeDir(getProperties().getWorkingDirForBytecode());
removeDir(getProperties().getWorkingDirForSource(), true);
removeDir(getProperties().getWorkingDirForBytecode(), true);
}

private void removeDir(String dir) throws IOException {
private void removeDir(String dir, boolean isFolderToBeRecreated) throws IOException {
File dirin = new File(dir);
try {
FileUtils.deleteDirectory(dirin);
} catch (Exception ex) {
logger.error("ex: " + ex.getMessage());
}
dirin.mkdir();
if (isFolderToBeRecreated) {
dirin.mkdir();
}
}

public boolean copyOriginalBin(List<String> inDirs, String mutatorIdentifier) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ public ExecutionResult atEnd() {
fw.close();
}
}
if (!ConfigurationProperties.getPropertyBool("saveall")) {
projectFacade.cleanMutationResultDirectories(ProgramVariant.DEFAULT_ORIGINAL_VARIANT);
projectFacade.cleanMutationResultDirectories(ProgramVariant.DEFAULT_ORIGINAL_VARIANT + PatchDiffCalculator.DIFF_SUFFIX);
}
} catch (Exception e1) {
e1.printStackTrace();
}
Expand Down Expand Up @@ -563,6 +567,9 @@ public boolean processCreatedVariant(ProgramVariant programVariant, int generati
saveVariant(programVariant);

return true;
} else if (!ConfigurationProperties.getPropertyBool("saveall")) {
projectFacade.cleanMutationResultDirectories(
ConfigurationProperties.getProperty("pvariantfoldername") + programVariant.getId());
}
} else {
log.debug("-The child does NOT compile: " + programVariant.getId() + ", errors: "
Expand Down
Loading

0 comments on commit 5ba45a0

Please sign in to comment.