示例#1
0
  /** Combo test to run all test cases in all modes. */
  void run() throws Exception {
    javac = JavacTool.create();
    fm = javac.getStandardFileManager(null, null, null);

    for (RunKind rk : RunKind.values()) {
      for (GenKind gk : GenKind.values()) {
        for (Method m : getClass().getDeclaredMethods()) {
          Annotation a = m.getAnnotation(Test.class);
          if (a != null) {
            init(rk, gk, m.getName());
            try {
              m.invoke(this, new Object[] {rk, gk});
            } catch (InvocationTargetException e) {
              Throwable cause = e.getCause();
              throw (cause instanceof Exception) ? ((Exception) cause) : e;
            }
            System.err.println();
          }
        }
      }
    }
    System.err.println(
        testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
    if (errorCount > 0) throw new Exception(errorCount + " errors found");
  }
示例#2
0
  /** Init directories for a test case. */
  void init(RunKind rk, GenKind gk, String name) throws IOException {
    System.err.println("Test " + rk + " " + gk + " " + name);
    testCount++;

    testDir =
        new File(rk.toString().toLowerCase() + "_" + gk.toString().toLowerCase() + "-" + name);
    srcDir = new File(testDir, "src");
    srcDir.mkdirs();
    classesDir = new File(testDir, "classes");
    classesDir.mkdirs();
    headersDir = new File(testDir, "headers");
    headersDir.mkdirs();
  }