test/tools/javac/lib/CompileFail.java

changeset 1097
497571d34112
parent 1064
c0d5f93af048
child 2525
2eb010b6cb22
equal deleted inserted replaced
1096:b0d5f00e69f7 1097:497571d34112
21 * questions. 21 * questions.
22 */ 22 */
23 23
24 import java.io.*; 24 import java.io.*;
25 import java.util.*; 25 import java.util.*;
26 import com.sun.tools.javac.main.Main;
26 27
27 /* 28 /*
28 * Utility class to emulate jtreg @compile/fail, but also checking the specific 29 * Utility class to emulate jtreg @compile/fail, but also checking the specific
29 * exit code, given as the first arg. 30 * exit code, given as the first arg.
30 */ 31 */
56 throw new Error("unexpected exit code: " + rc 57 throw new Error("unexpected exit code: " + rc
57 + ", expected: " + expected_rc); 58 + ", expected: " + expected_rc);
58 } 59 }
59 60
60 static int getReturnCode(String name) { 61 static int getReturnCode(String name) {
61 switch (name) { 62 return Main.Result.valueOf(name).exitCode;
62 case "OK":
63 return EXIT_OK;
64
65 case "ERROR":
66 return EXIT_ERROR;
67
68 case "CMDERR":
69 return EXIT_CMDERR;
70
71 case "SYSERR":
72 return EXIT_SYSERR;
73
74 case "ABNORMAL":
75 return EXIT_ABNORMAL;
76
77 default:
78 throw new IllegalArgumentException(name);
79 }
80 } 63 }
81 64
82 // The following is cut-n-paste from com.sun.tools.javac.main.Main
83 static final int
84 EXIT_OK = 0, // Compilation completed with no errors.
85 EXIT_ERROR = 1, // Completed but reported errors.
86 EXIT_CMDERR = 2, // Bad command-line arguments
87 EXIT_SYSERR = 3, // System error or resource exhaustion.
88 EXIT_ABNORMAL = 4; // Compiler terminated abnormally
89 } 65 }

mercurial