langtools/test/tools/javac/nativeHeaders/NativeHeaderTest.java
changeset 27319 030080f03e4f
parent 17546 06bbe5f5a2b8
child 30730 d3ce7619db2c
equal deleted inserted replaced
27318:4660a5da7d90 27319:030080f03e4f
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   191 
   191 
   192     /** Combo test to run all test cases in all modes. */
   192     /** Combo test to run all test cases in all modes. */
   193     void run() throws Exception {
   193     void run() throws Exception {
   194         javac = JavacTool.create();
   194         javac = JavacTool.create();
   195         fm = javac.getStandardFileManager(null, null, null);
   195         fm = javac.getStandardFileManager(null, null, null);
   196 
   196         try {
   197         for (RunKind rk: RunKind.values()) {
   197             for (RunKind rk: RunKind.values()) {
   198             for (GenKind gk: GenKind.values()) {
   198                 for (GenKind gk: GenKind.values()) {
   199                 for (Method m: getClass().getDeclaredMethods()) {
   199                     for (Method m: getClass().getDeclaredMethods()) {
   200                     Annotation a = m.getAnnotation(Test.class);
   200                         Annotation a = m.getAnnotation(Test.class);
   201                     if (a != null) {
   201                         if (a != null) {
   202                         init(rk, gk, m.getName());
   202                             init(rk, gk, m.getName());
   203                         try {
   203                             try {
   204                             m.invoke(this, new Object[] { rk, gk });
   204                                 m.invoke(this, new Object[] { rk, gk });
   205                         } catch (InvocationTargetException e) {
   205                             } catch (InvocationTargetException e) {
   206                             Throwable cause = e.getCause();
   206                                 Throwable cause = e.getCause();
   207                             throw (cause instanceof Exception) ? ((Exception) cause) : e;
   207                                 throw (cause instanceof Exception) ? ((Exception) cause) : e;
       
   208                             }
       
   209                             System.err.println();
   208                         }
   210                         }
   209                         System.err.println();
       
   210                     }
   211                     }
   211                 }
   212                 }
   212             }
   213             }
       
   214             System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
       
   215             if (errorCount > 0)
       
   216                 throw new Exception(errorCount + " errors found");
       
   217         } finally {
       
   218             fm.close();
   213         }
   219         }
   214         System.err.println(testCount + " tests" + ((errorCount == 0) ? "" : ", " + errorCount + " errors"));
       
   215         if (errorCount > 0)
       
   216             throw new Exception(errorCount + " errors found");
       
   217     }
   220     }
   218 
   221 
   219     /**
   222     /**
   220      * Init directories for a test case.
   223      * Init directories for a test case.
   221      */
   224      */