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

The following examples show how to use fr.inria.lille.repair.common.config.NopolContext#setMaxTimeInMinutes() . 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: 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 2
Source File: Main.java    From nopol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Launch nopol on project
 * @param cpClassFolder : location of project's compiled java
 * @param cpTestFolder : location of project's compiled tests
 * @param srcClassFolder : location of project's java
 * @param srcTestFolder : location of project's tests
 * @param destSrcTestFolder : location for the kept tests
 * @param destCpTestFolder : location to compile the kept tests
 * @param dependencies : all dependencies for the project and evosuite tests
 * @param testClasses : test class used to generate patch (null for all tests)
 * @return  the list of patch found by nopol
 */
public static List<Patch> NopolPatchGeneration(String cpClassFolder,String  cpTestFolder, 
        String srcClassFolder, String srcTestFolder, String destSrcTestFolder, 
        String destCpTestFolder, String dependencies, String[] testClasses) {

    //sources contain main java and test java.
    String sources = srcClassFolder+File.pathSeparatorChar+srcTestFolder+File.pathSeparatorChar+destSrcTestFolder;
    String cp = cpClassFolder+File.pathSeparatorChar+cpTestFolder+File.pathSeparatorChar+destCpTestFolder+File.pathSeparatorChar+dependencies;

    //create sources array
    String[] sourcesArray = sources.split(File.pathSeparator);
    File[] sourceFiles = new File[sourcesArray.length];
    for(int i = 0; i<sourcesArray.length; i++){
        sourceFiles[i] = FileLibrary.openFrom(sourcesArray[i]);	
    }


    //create getClasspath
    //URL[] classPath = FileUtils.getURLs(sources.split(File.pathSeparator));
    URL[] classPath = JavaLibrary.classpathFrom(cp);

    logger.debug("Launch nopol with:");
    logger.debug("sources = "+sources);
    logger.debug("classpath = "+cp);
    logger.debug("testClasses = "+testClasses);

    NopolContext nopolContext = new NopolContext(sourceFiles, classPath, testClasses);
    nopolContext.setMaxTimeInMinutes(maxTime);
    nopolContext.setType(nopolType);

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

    return status.getPatches();
}