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; }
private NopolContext fakeContext() { NopolContext nopolContext = new NopolContext(); // nopolContext.setCollectOnlyUsedMethod(ConfigurationProperties.getPropertyBool("collectonlyusedmethod")); nopolContext.setCollectOnlyUsedMethod(false); nopolContext.setDataCollectionTimeoutInSecondForSynthesis(5); nopolContext.setOnlyOneSynthesisResult(false); return nopolContext; }
this.nopolContext = new NopolContext(sourceFiles, classpath, jsapConfig.getStringArray("test")); nopolContext.setType(strToStatementType(jsapConfig.getString("type"))); nopolContext.setMode(strToMode(jsapConfig.getString("mode"))); nopolContext.setSynthesis(strToSynthesis(jsapConfig.getString("synthesis"))); nopolContext.setOracle(strToOracle(jsapConfig.getString("oracle"))); nopolContext.setSolver(strToSolver(jsapConfig.getString("solver"))); if (jsapConfig.getString("solverPath") != null) { nopolContext.setSolverPath(jsapConfig.getString("solverPath")); SolverFactory.setSolver(nopolContext.getSolver(), nopolContext.getSolverPath()); nopolContext.setComplianceLevel(jsapConfig.getInt("complianceLevel", nopolContext.getComplianceLevel())); nopolContext.setMaxTimeInMinutes(jsapConfig.getInt("maxTime", nopolContext.getMaxTimeInMinutes())); nopolContext.setMaxTimeEachTypeOfFixInMinutes(jsapConfig.getLong("maxTimeType",nopolContext.getMaxTimeEachTypeOfFixInMinutes())); nopolContext.setLocalizer(strToLocalizer(jsapConfig.getString("faultLocalization"))); nopolContext.setOutputFolder(jsapConfig.getString("outputFolder")); nopolContext.setJson(jsapConfig.getBoolean("outputJson", false)); return true;
+ " (should timeout in " + timeout + " minutes)"); NopolContext nopolContext = new NopolContext(sources, classPath.toArray(new URL[classPath.size()]), testClass.toArray(new String[0]), testsToIgnore); nopolContext.setComplianceLevel(8); nopolContext.setTimeoutTestExecution(300); nopolContext.setMaxTimeEachTypeOfFixInMinutes(15); nopolContext.setMaxTimeInMinutes(timeout); nopolContext.setLocalizer(NopolContext.NopolLocalizer.COCOSPOON); nopolContext.setSolverPath(this.getConfig().getZ3solverPath()); nopolContext.setSynthesis(NopolContext.NopolSynthesis.DYNAMOTH); nopolContext.setType(RepairType.COND_THEN_PRE); nopolContext.setOnlyOneSynthesisResult(false); nopolContext.setOutputFolder(patchDir.getAbsolutePath()); nopolContext.setRootProject(new File(repoLocalPath).toPath()); SolverFactory.setSolver(nopolContext.getSolver(), nopolContext.getSolverPath()); NopolResult result = nopolExecution.get(nopolContext.getMaxTimeInMinutes(), TimeUnit.MINUTES); this.addStepError("Timeout: execution time > " + nopolContext.getMaxTimeInMinutes() + " " + TimeUnit.MINUTES); nopolExecution.cancel(true); executor.shutdownNow();
logger.debug("testClasses = "+testClasses); NopolContext nopolContext = new NopolContext(sourceFiles, classPath, testClasses); nopolContext.setMaxTimeInMinutes(maxTime); nopolContext.setType(nopolType);
nopolContext.setRootProject(currentDir.getCanonicalFile().toPath().toAbsolutePath()); if (nopolContext.getSynthesis() == NopolContext.NopolSynthesis.DYNAMOTH) { URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader(); try { switch (nopolContext.getMode()) { case REPAIR: switch (nopolContext.getType()) { case LOOP: Infinitel infinitel = new Infinitel(nopolContext); try { executor.shutdown(); result = nopolExecution.get(nopolContext.getMaxTimeInMinutes(), TimeUnit.MINUTES); } catch (TimeoutException exception) { LoggerFactory.getLogger(Main.class).error("Timeout: execution time > " + nopolContext.getMaxTimeInMinutes() + " " + TimeUnit.MINUTES, exception);
public static void main(String[] args) { if (2 != args.length) { printUsage(); return; } File sourceFolder = new File(args[0]); checkArgument(sourceFolder.exists(), "%s: does not exist.", sourceFolder); checkArgument(sourceFolder.isDirectory(), "%s: is not a directory.", sourceFolder); System.setProperty("java.class.path", System.getProperty("java.class.path") + File.pathSeparatorChar + args[1]); String[] paths = args[1].split(Character .toString(File.pathSeparatorChar)); URL[] classpath = IfMetric.createUrls(paths); new IfMetric(new NopolContext(new File[]{ sourceFolder }, classpath, null)).run(); }
@Override public void execute() throws MojoExecutionException, MojoFailureException { final List<String> failingTestCases = getFailingTests(); final List<URL> dependencies = getClasspath(); final List<File> sourceFolders = getSourceFolders(); System.out.println(failingTestCases.size() + " detected failing test classes. (" + StringUtils.join(failingTestCases,":") + ")"); final List<URL> nopolClasspath = getNopolClasspath(); final String systemClasspath = System.getProperty("java.class.path"); String strClasspath = getStringClasspathFromList(nopolClasspath, systemClasspath); try { setGzoltarDebug(true); System.setProperty("java.class.path", strClasspath); NopolContext nopolContext = createNopolContext(failingTestCases, dependencies, sourceFolders); try { File currentDir = new File(".").getCanonicalFile(); nopolContext.setRootProject(currentDir.toPath().toAbsolutePath()); } catch (IOException e) { getLog().error("Error while setting the root project path, the created patches might have absolute paths."); } final NoPol nopol = new NoPol(nopolContext); this.result = nopol.build(); printResults(result); } finally { System.setProperty("java.class.path", systemClasspath); } }
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; }
public static void main(String[] args) { File sourceFile = FileLibrary.openFrom(args[0]); URL[] classpath = JavaLibrary.classpathFrom(args[1]); new InfinitelDiagnostician(new NopolContext(new File[]{sourceFile}, classpath, null)).diagnose(); System.out.println("Diagnostics ended"); }
public static void run(File[] sourceFile, URL[] classpath) { Infinitel infiniteLoopFixer = new Infinitel(new NopolContext(sourceFile, classpath, null)); try { infiniteLoopFixer.repair(); } catch (Exception e) { e.printStackTrace(); logError(infiniteLoopFixer.logger(), "Repair failed"); } }