예제 #1
0
  public TestRun run() {
    StringWriter output = new StringWriter();
    DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();

    if (debug) {
      System.out.printf(
          "TestInput.run:%n  options: %s%n  processors: %s%n  files: %s%n",
          this.options, this.processors, this.files);
    }

    JavaCompiler.CompilationTask task =
        compiler.getTask(
            output, fileManager, diagnostics, this.options, this.processors, this.files);

    /*
     * In Eclipse, std out and std err for multiple tests appear as one
     * long stream. When selecting a specific failed test, one sees the
     * expected/unexpected messages, but not the std out/err messages from
     * that particular test. Can we improve this somehow?
     */
    Boolean result = task.call();

    return new TestRun(result, output.toString(), diagnostics.getDiagnostics());
  }