Java Code Examples for fr.inria.lille.repair.common.config.NopolContext#setLocalizer()

The following examples show how to use fr.inria.lille.repair.common.config.NopolContext#setLocalizer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtility.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
public static List<Patch> patchFor(String executionType, NopolContext nopolContext) {
	nopolContext.setLocalizer(nopolContext.getLocalizer());

	List<Patch> patches;
	switch (executionType) {
		case "symbolic":
			nopolContext.setOracle(NopolContext.NopolOracle.SYMBOLIC);
			break;
		case "nopol":
			nopolContext.setOracle(NopolContext.NopolOracle.ANGELIC);
			break;
		default:
			throw new RuntimeException("Execution type not found");
	}

	NoPol nopol = new NoPol(nopolContext);
	NopolResult status = nopol.build();

	for (int i = 0; i < nopolContext.getProjectSources().length; i++) {
		File file = nopolContext.getProjectSources()[i];
		clean(file.getParent());
	}
	return status.getPatches();
}
 
Example 2
Source File: NopolMojo.java    From repairnator with MIT License 5 votes vote down vote up
private NopolContext createNopolContext(List<String> failingTestCases,
          List<URL> dependencies, List<File> sourceFolders) {
      NopolContext nopolContext = new NopolContext(sourceFolders.toArray(new File[0]), dependencies.toArray(new URL[0]), failingTestCases.toArray(new String[0]), Collections.<String>emptyList());
      nopolContext.setComplianceLevel(getComplianceLevel());
      nopolContext.setTimeoutTestExecution(300);
      nopolContext.setMaxTimeEachTypeOfFixInMinutes(15);
      nopolContext.setMaxTimeInMinutes(maxTime);
      nopolContext.setLocalizer(this.resolveLocalizer());
      nopolContext.setSynthesis(this.resolveSynthesis());
      nopolContext.setType(this.resolveType());
      nopolContext.setOnlyOneSynthesisResult(true);
      nopolContext.setJson(true);
      if (!outputDirectory.exists()) {
	outputDirectory.mkdirs();
}
      nopolContext.setOutputFolder(outputDirectory.getAbsolutePath());

      NopolContext.NopolSolver solver = this.resolveSolver();
      nopolContext.setSolver(solver);

      if (nopolContext.getSynthesis() == NopolContext.NopolSynthesis.SMT) {
          if (solver == NopolContext.NopolSolver.Z3) {
              String z3Path = this.loadZ3AndGivePath();
              SolverFactory.setSolver(solver, z3Path);
              nopolContext.setSolverPath(z3Path);
          } else {
              SolverFactory.setSolver(solver, null);
          }
      }
      return nopolContext;
  }
 
Example 3
Source File: DumbLocalizerTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testDumbLocalizerWithPatch() {
	NopolContext nopolContext = TestUtility.configForExample("nopol", 2);
	nopolContext.setLocalizer(NopolContext.NopolLocalizer.DUMB);
	nopolContext.setType(RepairType.CONDITIONAL);
	SolverFactory.setSolver("z3", TestUtility.solverPath);
	NoPol nopol = new NoPol(nopolContext);
	NopolResult result = nopol.build();
	assertEquals(1, result.getPatches().size());
}
 
Example 4
Source File: DumbLocalizerTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testDumbLocalizerWithPatch3() {
	NopolContext nopolContext = TestUtility.configForExample("nopol", 3);
	nopolContext.setLocalizer(NopolContext.NopolLocalizer.DUMB);
	nopolContext.setType(RepairType.CONDITIONAL);
	SolverFactory.setSolver("z3", TestUtility.solverPath);
	NoPol nopol = new NoPol(nopolContext);
	NopolResult result = nopol.build();
	assertEquals(1, result.getPatches().size());
}
 
Example 5
Source File: Defects4jEvaluationTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test(timeout = FIVE_MINUTES_TIMEOUT)
public void test_Chart3() throws Exception {
	if (!testShouldBeRun()) { return; }
	NopolContext nopolContext = nopolConfigFor("Chart3", "");
	nopolContext.setLocalizer(NopolContext.NopolLocalizer.COCOSPOON);

	// we take only the failing test case
	nopolContext.setProjectTests(new String[]{"org.jfree.data.time.junit.TimeSeriesTests#testCreateCopy3"});

	NopolResult result = new NoPol(nopolContext).build();
	assertEquals(1, result.getPatches().size());
}
 
Example 6
Source File: AbstractRealBugsEvaluation.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
private List<Patch> setupAndRun(String projectName, RepairType repairType, 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/";
    String libFolder = realBugPath + "../data/lib/";
    String classpath = binFolder + File.pathSeparatorChar;
    for (int i = 0; i < dependencies.length; i++) {
        classpath += libFolder + dependencies[i];
        if (i < dependencies.length - 1) {
            classpath += File.pathSeparatorChar;
        }
    }
    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(repairType);
    nopolContext.setProjectClasspath(JavaLibrary.classpathFrom(classpath));
    SolverFactory.setSolver(nopolContext.getSolver(), nopolContext.getSolverPath());
    switch (this.executionType) {
        case "symbolic":
            nopolContext.setOracle(NopolContext.NopolOracle.SYMBOLIC);
            break;
        case "nopol":
            nopolContext.setOracle(NopolContext.NopolOracle.ANGELIC);
            break;
        default:
            throw new RuntimeException("Execution type not found");
    }

    return new NoPol(nopolContext).build().getPatches();
}