Exemplo n.º 1
0
  public List<Patch> build(String[] testClasses) {
    gZoltar = GZoltarSuspiciousProgramStatements.create(this.classpath, testClasses);
    Collection<Statement> statements = gZoltar.sortBySuspiciousness(testClasses);
    if (statements.isEmpty()) {
      throw new RuntimeException("No suspicious statements found.");
    }

    Map<SourceLocation, List<TestResult>> testListPerStatement = getTestListPerStatement();

    if (Config.INSTANCE.getOracle() == Config.NopolOracle.SYMBOLIC) {
      try {
        this.classpath = addJPFLibraryToCassPath(classpath);
        SpoonedProject jpfSpoon = new SpoonedProject(this.sourceFiles, classpath);
        String mainClass = "nopol.repair.NopolTestRunner";
        TestExecutorProcessor.createMainTestClass(jpfSpoon, mainClass);
        jpfSpoon.process(new AssertReplacer());

        final File outputSourceFile = new File("src-gen");
        final File outputCompiledFile = new File("target-gen");
        // generate the output file
        jpfSpoon.generateOutputFile(outputSourceFile);
        jpfSpoon.generateOutputCompiledFile(outputCompiledFile);
      } catch (IOException e) {
        throw new RuntimeException("Unable to write transformed test", e);
      }
    }

    return solveWithMultipleBuild(statements, testListPerStatement);
  }
Exemplo n.º 2
0
  @Override
  public Collection<Specification<T>> buildFor(
      final URL[] classpath, final String[] testClasses, final Collection<TestCase> failures) {
    final LoggingInstrumenter<T> logging = createLoggingInstrumenter();
    SpoonedClass fork = cleanSpoon.forked(sourceLocation.getContainingClassName());
    final ClassLoader unitTestClassLoader = fork.processedAndDumpedToClassLoader(logging);

    final SpecificationTestCasesListener<T> listener =
        run(classpath, failures, unitTestClassLoader);

    if (this.find) {
      logging.disable();
      TestSuiteExecution.runCasesIn(testClasses, unitTestClassLoader, listener);
    }
    return listener.specifications();
  }
Exemplo n.º 3
0
 private Collection<TestCase> failingTests(String[] testClasses) {
   TestCasesListener listener = new TestCasesListener();
   TestSuiteExecution.runCasesIn(testClasses, spooner.dumpedToClassLoader(), listener);
   return listener.failedTests();
 }