Skip to content

Commit

Permalink
refactoring Move src/evaluation to src/test. (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
surli authored and monperrus committed Feb 28, 2017
1 parent a6ee234 commit 26b593b
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public String[] projectTestClasses() {
return nopolContext.getProjectTests();
}

public NopolContext getNopolContext() {
return nopolContext;
}

public void repair() {
MonitoringTestExecutor testExecutor = newTestExecutor();
LoopTestResult testResult = newTestResult(testExecutor);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.inria.lille.repair;

import fr.inria.lille.commons.synthesis.smt.solver.SolverFactory;
import fr.inria.lille.repair.common.config.Config;
import fr.inria.lille.repair.common.config.NopolContext;
import fr.inria.lille.repair.common.patch.Patch;
import fr.inria.lille.repair.common.synth.StatementType;
import fr.inria.lille.repair.nopol.NoPol;
Expand All @@ -11,7 +11,6 @@
import xxl.java.library.JavaLibrary;

import java.io.File;
import java.io.IOException;
import java.util.List;

import static fr.inria.lille.commons.synthesis.smt.solver.Z3SolverFactory.isMac;
Expand All @@ -29,7 +28,7 @@ public AbstractRealBugsEvaluation(String executionType) {

@Test
public void CM1() {
Config config = new Config();
NopolContext config = new NopolContext();
StatementType statementType = StatementType.CONDITIONAL;
String projectName = "cm1";
List<Patch> patches = setupAndRun(
Expand Down Expand Up @@ -62,7 +61,7 @@ public void CM1() {
public void CM2() {
StatementType statementType = StatementType.PRECONDITION;
String projectName = "cm2";
Config config = new Config();
NopolContext config = new NopolContext();

List<Patch> patches = setupAndRun(
projectName,
Expand Down Expand Up @@ -97,7 +96,7 @@ public void CM2() {
public void CM3() {
String projectName = "cm3";
StatementType statementType = StatementType.PRECONDITION;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand Down Expand Up @@ -127,7 +126,7 @@ public void CM3() {
public void CM4() {
String projectName = "cm4";
StatementType statementType = StatementType.CONDITIONAL;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand Down Expand Up @@ -156,7 +155,7 @@ public void CM4() {
public void CM5() {
String projectName = "cm5";
StatementType statementType = StatementType.CONDITIONAL;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand Down Expand Up @@ -190,7 +189,7 @@ public void CM5() {

@Test
public void CM6() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(5);
String projectName = "cm6";
StatementType statementType = StatementType.PRECONDITION;
Expand Down Expand Up @@ -221,7 +220,7 @@ public void CM6() {
public void CM7() {
String projectName = "cm7";
StatementType statementType = StatementType.CONDITIONAL;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand All @@ -246,7 +245,7 @@ public void CM7() {
@Test
@Ignore
public void CM8() {
Config config = new Config();
NopolContext config = new NopolContext();
StatementType statementType = StatementType.CONDITIONAL;
String projectName = "cm8";
List<Patch> patches = setupAndRun(
Expand Down Expand Up @@ -275,7 +274,7 @@ public void CM8() {
public void CM9() {
String projectName = "cm9";
StatementType statementType = StatementType.CONDITIONAL;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand All @@ -302,7 +301,7 @@ public void CM9() {
public void CM10() {
String projectName = "cm10";
StatementType statementType = StatementType.PRECONDITION;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand All @@ -326,11 +325,11 @@ public void CM10() {

@Test
public void CL1() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(4);
String projectName = "cl1";
StatementType statementType = StatementType.CONDITIONAL;
config.setSolver(Config.NopolSolver.Z3);
config.setSolver(NopolContext.NopolSolver.Z3);
config.setSolverPath("lib/z3/z3_for_linux");

List<Patch> patches = setupAndRun(
Expand Down Expand Up @@ -359,7 +358,7 @@ public void CL1() {

@Test
public void CL2() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(4);
String projectName = "cl2";
StatementType statementType = StatementType.CONDITIONAL;
Expand Down Expand Up @@ -391,7 +390,7 @@ public void CL2() {

@Test
public void CL3() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(4);
String projectName = "cl3";
StatementType statementType = StatementType.CONDITIONAL;
Expand Down Expand Up @@ -421,7 +420,7 @@ public void CL3() {

@Test
public void CL4() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(4);
String projectName = "cl4";
StatementType statementType = StatementType.CONDITIONAL;
Expand Down Expand Up @@ -451,7 +450,7 @@ public void CL4() {

@Test
public void CL5() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(6);
String projectName = "cl5";
StatementType statementType = StatementType.CONDITIONAL;
Expand Down Expand Up @@ -482,7 +481,7 @@ public void CL5() {
public void CL6() {
String projectName = "cl6";
StatementType statementType = StatementType.CONDITIONAL;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand All @@ -509,7 +508,7 @@ public void CL6() {
public void PM1() {
String projectName = "pm1";
StatementType statementType = StatementType.PRECONDITION;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand Down Expand Up @@ -539,7 +538,7 @@ public void PM1() {
public void PM2() {
String projectName = "pm2";
StatementType statementType = StatementType.PRECONDITION;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand All @@ -562,7 +561,7 @@ public void PM2() {
}
@Test
public void PL1() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(4);
String projectName = "pl1";
StatementType statementType = StatementType.PRECONDITION;
Expand Down Expand Up @@ -596,7 +595,7 @@ public void PL1() {

@Test
public void PL2() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(4);
String projectName = "pl2";
StatementType statementType = StatementType.PRECONDITION;
Expand All @@ -623,7 +622,7 @@ public void PL2() {
@Test
@Ignore
public void PL3() {
Config config = new Config();
NopolContext config = new NopolContext();
config.setComplianceLevel(4);
String projectName = "pl3";
StatementType statementType = StatementType.PRECONDITION;
Expand Down Expand Up @@ -651,7 +650,7 @@ public void PL3() {
public void PL4() {
String projectName = "pl4";
StatementType statementType = StatementType.PRECONDITION;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand Down Expand Up @@ -682,8 +681,8 @@ public void PL4() {
public void AM1() {
String projectName = "am1";
StatementType statementType = StatementType.DOUBLE_LITERAL;
Config config = new Config();
config.setSolver(Config.NopolSolver.Z3);
NopolContext config = new NopolContext();
config.setSolver(NopolContext.NopolSolver.Z3);
config.setSolverPath("lib/z3/z3_for_linux");

List<Patch> patches = setupAndRun(
Expand All @@ -709,7 +708,7 @@ public void AM1() {
public void AM2() {
String projectName = "am2";
StatementType statementType = StatementType.DOUBLE_LITERAL;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand All @@ -733,7 +732,7 @@ public void AM2() {
public void AM3() {
String projectName = "am3";
StatementType statementType = StatementType.DOUBLE_LITERAL;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand All @@ -757,7 +756,7 @@ public void AM3() {
public void AM4() {
String projectName = "am4";
StatementType statementType = StatementType.DOUBLE_LITERAL;
Config config = new Config();
NopolContext config = new NopolContext();
List<Patch> patches = setupAndRun(
projectName,
statementType,
Expand All @@ -776,7 +775,7 @@ public void AM4() {
clean(srcFolder); // TODO
}

private List<Patch> setupAndRun(String projectName, StatementType statementType, String[] tests, Config config, String... dependencies) {
private List<Patch> setupAndRun(String projectName, StatementType statementType, String[] tests, NopolContext nopolContext, String... dependencies) {
String rootFolder = realBugPath + projectName + "/";
String srcFolder = rootFolder + "src";
String binFolder = rootFolder + "target/classes/" + File.pathSeparatorChar + rootFolder + "target/test-classes/";
Expand All @@ -788,35 +787,27 @@ private List<Patch> setupAndRun(String projectName, StatementType statementType,
classpath += File.pathSeparatorChar;
}
}
try {
config.setProjectSourcePath(new String[]{new File(srcFolder).getCanonicalPath()});
} catch (IOException e) {
throw new RuntimeException(e);
}
config.setSolverPath("lib/z3/z3_for_" + (isMac() ? "mac" : "linux"));
config.setSolver(Config.NopolSolver.Z3);
config.setLocalizer(Config.NopolLocalizer.GZOLTAR);
config.setProjectTests(tests);
config.setType(statementType);
SolverFactory.setSolver(config.getSolver(), config.getSolverPath());
nopolContext.setProjectSourcePath(new File[]{new File(srcFolder)});

nopolContext.setSolverPath("lib/z3/z3_for_" + (isMac() ? "mac" : "linux"));
nopolContext.setSolver(NopolContext.NopolSolver.Z3);
nopolContext.setLocalizer(NopolContext.NopolLocalizer.GZOLTAR);
nopolContext.setProjectTests(tests);
nopolContext.setType(statementType);
nopolContext.setProjectClasspath(JavaLibrary.classpathFrom(classpath));
SolverFactory.setSolver(nopolContext.getSolver(), nopolContext.getSolverPath());
switch (this.executionType) {
case "symbolic":
config.setOracle(Config.NopolOracle.SYMBOLIC);
nopolContext.setOracle(NopolContext.NopolOracle.SYMBOLIC);
break;
case "nopol":
config.setOracle(Config.NopolOracle.ANGELIC);
nopolContext.setOracle(NopolContext.NopolOracle.ANGELIC);
break;
default:
throw new RuntimeException("Execution type not found");
}

ProjectReference project = new ProjectReference(
srcFolder,
JavaLibrary.classpathFrom(classpath),
null
);

return new NoPol(project, config).build();
return new NoPol(nopolContext).build().getPatches();
}


Expand Down

0 comments on commit 26b593b

Please sign in to comment.