private void processExamples(String group, List<Example> examples) {
    Evaluation evaluation = new Evaluation();
    if (examples.isEmpty()) return;

    final String prefix = "iter=0." + group;
    Execution.putOutput("group", group);
    LogInfo.begin_track_printAll("Processing %s: %s examples", prefix, examples.size());
    LogInfo.begin_track("Dumping metadata");
    dumpMetadata(group, examples);
    LogInfo.end_track();
    LogInfo.begin_track("Examples");

    for (int e = 0; e < examples.size(); e++) {
      Example ex = examples.get(e);
      LogInfo.begin_track_printAll("%s: example %s/%s: %s", prefix, e, examples.size(), ex.id);
      ex.log();
      Execution.putOutput("example", e);
      StopWatchSet.begin("Parser.parse");
      ParserState state = builder.parser.parse(params, ex, false);
      StopWatchSet.end();
      out.printf("########## Example %s ##########\n", ex.id);
      dumpExample(exampleToLispTree(state));
      LogInfo.logs("Current: %s", ex.evaluation.summary());
      evaluation.add(ex.evaluation);
      LogInfo.logs("Cumulative(%s): %s", prefix, evaluation.summary());
      LogInfo.end_track();
      ex.predDerivations.clear(); // To save memory
    }

    LogInfo.end_track();
    LogInfo.logs("Stats for %s: %s", prefix, evaluation.summary());
    evaluation.logStats(prefix);
    evaluation.putOutput(prefix);
    LogInfo.end_track();
  }
  Map<String, Set<String>> runExamples(File examplesDir, boolean verbose) {
    Map<String, Set<String>> map = new TreeMap<String, Set<String>>();
    for (Example e : getExamples(examplesDir)) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      e.run(pw, true, verbose);
      pw.close();
      String[] lines = sw.toString().split("\n");
      for (String line : lines) {
        if (!line.startsWith("compiler.")) continue;
        int colon = line.indexOf(":");
        if (colon == -1) continue;
        String key = line.substring(0, colon);
        StringBuilder sb = new StringBuilder();
        sb.append("# ");
        int i = 0;
        String[] descs = line.substring(colon + 1).split(", *");
        for (String desc : descs) {
          if (i > 0) sb.append(", ");
          sb.append(i++);
          sb.append(": ");
          sb.append(desc.trim());
        }
        Set<String> set = map.get(key);
        if (set == null) map.put(key, set = new TreeSet<String>());
        set.add(sb.toString());
      }
    }

    return map;
  }
 public List<BufferedImage> getExamples() {
   List<BufferedImage> list = new ArrayList<BufferedImage>();
   for (int i = 0; i < model.size(); i++) {
     Example example = (Example) model.get(i);
     list.add(example.getBufferedImage());
   }
   return list;
 }
  public static void main(String... args) throws Exception {
    jtreg = (System.getProperty("test.src") != null);
    File tmpDir;
    if (jtreg) {
      // use standard jtreg scratch directory: the current directory
      tmpDir = new File(System.getProperty("user.dir"));
    } else {
      tmpDir =
          new File(
              System.getProperty("java.io.tmpdir"),
              MessageInfo.class.getName()
                  + (new SimpleDateFormat("yyMMddHHmmss")).format(new Date()));
    }
    Example.setTempDir(tmpDir);
    Example.Compiler.factory = new ArgTypeCompilerFactory();

    MessageInfo mi = new MessageInfo();

    try {
      if (mi.run(args)) return;
    } finally {
      /* VERY IMPORTANT NOTE. In jtreg mode, tmpDir is set to the
       * jtreg scratch directory, which is the current directory.
       * In case someone is faking jtreg mode, make sure to only
       * clean tmpDir when it is reasonable to do so.
       */
      if (tmpDir.isDirectory() && tmpDir.getName().startsWith(MessageInfo.class.getName())) {
        if (clean(tmpDir)) tmpDir.delete();
      }
    }

    if (jtreg) throw new Exception(mi.errors + " errors occurred");
    else System.exit(1);
  }