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

The following examples show how to use fr.inria.lille.repair.common.config.NopolContext#setOnlyOneSynthesisResult() . 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: DynamothCodeGenesisTest.java    From nopol with GNU General Public License v2.0 6 votes vote down vote up
@Test
  public void test13() throws InterruptedException {
      Map<String, Object[]> oracle = new HashMap<>();
      oracle.put("test_1", new Object[]{true, true});
      oracle.put("test_2", new Object[]{false});
      oracle.put("test_3", new Object[]{false});

NopolContext nopolContext = TestUtility.configForExample("nopol",13);
      nopolContext.setOnlyOneSynthesisResult(false);

      DynamothCodeGenesis dynamothCodeGenesis = createSynthesizer(13, oracle, 4, nopolContext);
      System.out.println("basic: "+ dynamothCodeGenesis.getCollectedExpressions());
      //assertEquals(12,dynamothCodeGenesis.getCollectedExpressions().size());

      // the valid patches
      check(dynamothCodeGenesis.getValidExpressions(), "(list == null) || list.isEmpty()");
  }
 
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: DynamothCodeGenesisTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test12() throws InterruptedException {
    Map<String, Object[]> oracle = new HashMap<>();
    oracle.put("test_1", new Object[]{true});
    oracle.put("test_2", new Object[]{false});
    oracle.put("test_3", new Object[]{true});
    oracle.put("test_4", new Object[]{false});

    NopolContext nopolContext = TestUtility.configForExample("nopol",12);

    nopolContext.setOnlyOneSynthesisResult(false);
    
    DynamothCodeGenesis dynamothCodeGenesis = createSynthesizer(12, oracle, 5, nopolContext);
    System.out.println("basic: "+ dynamothCodeGenesis.getCollectedExpressions());
    assertEquals(13, dynamothCodeGenesis.getCollectedExpressions().size());
    
    check(dynamothCodeGenesis.getCollectedExpressions(), "list");
    
    // other constants of the program
    check(dynamothCodeGenesis.getCollectedExpressions(), "3");

    // other variables
    check(dynamothCodeGenesis.getCollectedExpressions(), "list2");
    
    // method calls
    check(dynamothCodeGenesis.getCollectedExpressions(), "this.foo((java.util.List) list)");
    check(dynamothCodeGenesis.getCollectedExpressions(), "this.foo((java.util.List) list2)");
    
    // the valid patches
    check(dynamothCodeGenesis.getValidExpressions(), "(list == null) || (list.size() == 0)");
    check(dynamothCodeGenesis.getValidExpressions(), "(list == null) || list.isEmpty()");
}
 
Example 4
Source File: NopolTest.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testDynamoth() {
	NopolContext nopolContext = TestUtility.configForExample(executionType, 2);
	nopolContext.setType(RepairType.CONDITIONAL);
	nopolContext.setSynthesis(NopolContext.NopolSynthesis.DYNAMOTH);
	nopolContext.setOnlyOneSynthesisResult(false);
	NoPol nopol;

	// contract: Dynamoth stops after the default max values of patches
	nopol = new NoPol(nopolContext);
	assertEquals(10, nopol.build().getPatches().size());
}
 
Example 5
Source File: DynamothCollectorFacade.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public DynamothCollector createCollector(ProjectRepairFacade facade, ModificationPoint mp,
		Map<String, Object[]> oracle, String[] testClasses) {

	SuspiciousModificationPoint smp = (SuspiciousModificationPoint) mp;

	String classPath = facade.getOutDirWithPrefix(ProgramVariant.DEFAULT_ORIGINAL_VARIANT) + File.pathSeparator
			+ facade.getProperties().getDependenciesString();
	URL[] urls = (FinderTestCases.classpathFrom(classPath));

	File[] sources = new File[facade.getProperties().getOriginalDirSrc().size()];
	int i = 0;
	for (String s : facade.getProperties().getOriginalDirSrc()) {
		sources[i++] = new File(s);
	}

	log.info("Astor-Dynamoth config: ");

	NopolContext nopolContext = new NopolContext(sources, urls, testClasses);
	nopolContext.setCollectOnlyUsedMethod(ConfigurationProperties.getPropertyBool("collectonlyusedmethod"));
	nopolContext.setDataCollectionTimeoutInSecondForSynthesis(5);
	nopolContext.setOnlyOneSynthesisResult(false);
	log.info("-sources: " + Arrays.toString(sources));
	log.info("-url: " + Arrays.toString(urls));
	log.info("-testClasses: " + Arrays.toString(testClasses));

	DynamothCollector dynamothCodeGenesis = new DynamothCollector(oracle, smp, sources, urls, testClasses,
			nopolContext);

	dynamothCodeGenesis.run(TimeUnit.MINUTES.toMillis(15));

	return dynamothCodeGenesis;
}
 
Example 6
Source File: StaSynthBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private NopolContext fakeContext() {
	NopolContext nopolContext = new NopolContext();
	// nopolContext.setCollectOnlyUsedMethod(ConfigurationProperties.getPropertyBool("collectonlyusedmethod"));
	nopolContext.setCollectOnlyUsedMethod(false);

	nopolContext.setDataCollectionTimeoutInSecondForSynthesis(5);
	nopolContext.setOnlyOneSynthesisResult(false);
	return nopolContext;
}