Lines 10-26
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.compiler.regression; |
11 |
package org.eclipse.jdt.core.tests.compiler.regression; |
12 |
|
12 |
|
|
|
13 |
import java.io.File; |
14 |
import java.io.FileNotFoundException; |
15 |
import java.io.FileOutputStream; |
16 |
import java.io.PrintWriter; |
13 |
import junit.framework.Test; |
17 |
import junit.framework.Test; |
|
|
18 |
import junit.framework.TestSuite; |
14 |
|
19 |
|
|
|
20 |
import org.eclipse.jdt.core.tests.util.Util; |
15 |
import org.eclipse.jdt.internal.compiler.batch.Main; |
21 |
import org.eclipse.jdt.internal.compiler.batch.Main; |
16 |
|
22 |
|
17 |
public class BatchCompilerTest extends AbstractRegressionTest { |
23 |
public class BatchCompilerTest extends AbstractRegressionTest { |
|
|
24 |
public static final String OUTPUT_DIR_PLACEHOLDER = "---OUTPUT_DIR_PLACEHOLDER---"; |
25 |
|
18 |
public BatchCompilerTest(String name) { |
26 |
public BatchCompilerTest(String name) { |
19 |
super(name); |
27 |
super(name); |
20 |
} |
28 |
} |
21 |
public static Test suite() { |
29 |
public static Test suite() { |
|
|
30 |
if (false) { |
31 |
TestSuite suite = new TestSuite(); |
32 |
suite.addTest(new BatchCompilerTest("test009")); |
33 |
return suite; |
34 |
} |
22 |
return setupSuite(testClass()); |
35 |
return setupSuite(testClass()); |
|
|
36 |
// TODO find a way to reduce the number of command line tests to one per |
37 |
// test run (aka do not add 1.3, 1.4, 1.5 supplementary level) |
23 |
} |
38 |
} |
|
|
39 |
|
40 |
/** |
41 |
* Run a compilation test that is expected to complete successfully and |
42 |
* compare the outputs to expected ones. |
43 |
* |
44 |
* @param testFiles |
45 |
* the source files, given as a suite of file name, file content; |
46 |
* file names are relative to the output directory |
47 |
* @param commandLine |
48 |
* the command line to pass to |
49 |
* {@link Main#compile(String) Main#compile} |
50 |
* @param expectedSuccessOutOutputString |
51 |
* the expected contents of the standard output stream; pass null |
52 |
* to bypass the comparison |
53 |
* @param expectedSuccessErrOutputString |
54 |
* the expected contents of the standard error output stream; |
55 |
* pass null to bypass the comparison |
56 |
* @param shouldFlushOutputDirectory |
57 |
* pass true to get the output directory flushed before the test |
58 |
* runs |
59 |
*/ |
60 |
protected void runConformTest(String[] testFiles, String commandLine, |
61 |
String expectedSuccessOutOutputString, |
62 |
String expectedSuccessErrOutputString, |
63 |
boolean shouldFlushOutputDirectory) { |
64 |
File outputDirectory = new File(OUTPUT_DIR); |
65 |
if (shouldFlushOutputDirectory) |
66 |
Util.flushDirectoryContent(outputDirectory); |
67 |
try { |
68 |
if (!outputDirectory.isDirectory()) { |
69 |
outputDirectory.mkdirs(); |
70 |
} |
71 |
PrintWriter sourceFileWriter; |
72 |
for (int i = 0; i < testFiles.length; i += 2) { |
73 |
sourceFileWriter = new PrintWriter(new FileOutputStream( |
74 |
OUTPUT_DIR + File.separator + testFiles[i])); |
75 |
sourceFileWriter.write(testFiles[i + 1]); |
76 |
sourceFileWriter.close(); |
77 |
} |
78 |
} catch (FileNotFoundException e) { |
79 |
e.printStackTrace(); |
80 |
throw new RuntimeException(e); |
81 |
} |
82 |
String printerWritersNameRoot = OUTPUT_DIR + File.separator |
83 |
+ testName(); |
84 |
String outFileName = printerWritersNameRoot + "out.txt", errFileName = printerWritersNameRoot + "err.txt"; //$NON-NLS-1$ //$NON-NLS-2$ |
85 |
Main batchCompiler; |
86 |
try { |
87 |
batchCompiler = new Main(new PrintWriter(new FileOutputStream( |
88 |
outFileName)), new PrintWriter(new FileOutputStream( |
89 |
errFileName)), false); |
90 |
} catch (FileNotFoundException e) { |
91 |
System.out.println(getClass().getName() + '#' + getName()); |
92 |
e.printStackTrace(); |
93 |
throw new RuntimeException(e); |
94 |
} |
95 |
boolean compileOK; |
96 |
try { |
97 |
compileOK = batchCompiler.compile(Main.tokenize(commandLine)); |
98 |
} catch (RuntimeException e) { |
99 |
compileOK = false; |
100 |
System.out.println(getClass().getName() + '#' + getName()); |
101 |
e.printStackTrace(); |
102 |
throw e; |
103 |
} |
104 |
String outOutputString = Util.fileContent(outFileName), errOutputString = Util |
105 |
.fileContent(errFileName); |
106 |
boolean compareOK = false; |
107 |
if (compileOK) { |
108 |
compareOK = |
109 |
normalizedComparison(expectedSuccessOutOutputString, |
110 |
expectedSuccessOutOutputString) |
111 |
&& normalizedComparison(expectedSuccessErrOutputString, |
112 |
expectedSuccessErrOutputString); |
113 |
} |
114 |
if (!compileOK || !compareOK) { |
115 |
System.out.println(getClass().getName() + '#' + getName()); |
116 |
for (int i = 0; i < testFiles.length; i += 2) { |
117 |
System.out.print(testFiles[i]); |
118 |
System.out.println(" ["); //$NON-NLS-1$ |
119 |
System.out.println(testFiles[i + 1]); |
120 |
System.out.println("]"); //$NON-NLS-1$ |
121 |
} |
122 |
} |
123 |
if (!compileOK) |
124 |
System.out.println(errOutputString); |
125 |
if (compileOK && !compareOK) { |
126 |
System.out.println("--[START OUT]--\n" |
127 |
+ "------------- Expected: -------------\n" |
128 |
+ expectedSuccessOutOutputString |
129 |
+ "------------- but was: -------------\n" |
130 |
+ Util.displayString(outOutputString) |
131 |
+ "\n---[END OUT]---\n--[START ERR]--\n" |
132 |
+ "------------- Expected: -------------\n" |
133 |
+ expectedSuccessErrOutputString |
134 |
+ "------------- but was: -------------\n" |
135 |
+ Util.displayString(errOutputString) |
136 |
+ "\n---[END ERR]--\n"); |
137 |
} |
138 |
assertTrue("Unexpected problems: " + errOutputString, compileOK); |
139 |
assertTrue("Unexpected output for invocation with arguments [" |
140 |
+ commandLine + "]:\n" + "--[START]--\n" + outOutputString |
141 |
+ errOutputString + "---[END]---\n", compareOK); |
142 |
} |
143 |
|
144 |
/** |
145 |
* Run a compilation test that is expected to fail and compare the outputs |
146 |
* to expected ones. |
147 |
* |
148 |
* @param testFiles |
149 |
* the source files, given as a suite of file name, file content; |
150 |
* file names are relative to the output directory |
151 |
* @param commandLine |
152 |
* the command line to pass to |
153 |
* {@link Main#compile(String) Main#compile} |
154 |
* @param expectedSuccessOutOutputString |
155 |
* the expected contents of the standard output stream; pass null |
156 |
* to bypass the comparison |
157 |
* @param expectedSuccessErrOutputString |
158 |
* the expected contents of the standard error output stream; |
159 |
* pass null to bypass the comparison |
160 |
* @param shouldFlushOutputDirectory |
161 |
* pass true to get the output directory flushed before the test |
162 |
* runs |
163 |
*/ |
164 |
protected void runNegativeTest(String[] testFiles, String commandLine, |
165 |
String expectedSuccessOutOutputString, |
166 |
String expectedSuccessErrOutputString, |
167 |
boolean shouldFlushOutputDirectory) { |
168 |
File outputDirectory = new File(OUTPUT_DIR); |
169 |
if (shouldFlushOutputDirectory) |
170 |
Util.flushDirectoryContent(outputDirectory); |
171 |
try { |
172 |
if (!outputDirectory.isDirectory()) { |
173 |
outputDirectory.mkdirs(); |
174 |
} |
175 |
PrintWriter sourceFileWriter; |
176 |
for (int i = 0; i < testFiles.length; i += 2) { |
177 |
sourceFileWriter = new PrintWriter(new FileOutputStream( |
178 |
OUTPUT_DIR + File.separator + testFiles[i])); |
179 |
sourceFileWriter.write(testFiles[i + 1]); |
180 |
sourceFileWriter.close(); |
181 |
} |
182 |
} catch (FileNotFoundException e) { |
183 |
e.printStackTrace(); |
184 |
throw new RuntimeException(e); |
185 |
} |
186 |
String printerWritersNameRoot = OUTPUT_DIR + File.separator |
187 |
+ testName(); |
188 |
String outFileName = printerWritersNameRoot + "out.txt", errFileName = printerWritersNameRoot + "err.txt"; //$NON-NLS-1$ //$NON-NLS-2$ |
189 |
Main batchCompiler; |
190 |
try { |
191 |
batchCompiler = new Main(new PrintWriter(new FileOutputStream( |
192 |
outFileName)), new PrintWriter(new FileOutputStream( |
193 |
errFileName)), false); |
194 |
} catch (FileNotFoundException e) { |
195 |
System.out.println(getClass().getName() + '#' + getName()); |
196 |
e.printStackTrace(); |
197 |
throw new RuntimeException(e); |
198 |
} |
199 |
boolean compileKO; |
200 |
try { |
201 |
compileKO = !batchCompiler.compile(Main.tokenize(commandLine)); |
202 |
} catch (RuntimeException e) { |
203 |
compileKO = false; |
204 |
System.out.println(getClass().getName() + '#' + getName()); |
205 |
e.printStackTrace(); |
206 |
throw e; |
207 |
} |
208 |
String outOutputString = Util.fileContent(outFileName), errOutputString = Util |
209 |
.fileContent(errFileName); |
210 |
boolean compareOK = false; |
211 |
if (compileKO) { |
212 |
compareOK = |
213 |
normalizedComparison(expectedSuccessOutOutputString, |
214 |
expectedSuccessOutOutputString) |
215 |
&& normalizedComparison(expectedSuccessErrOutputString, |
216 |
expectedSuccessErrOutputString); |
217 |
} |
218 |
if (!compileKO || !compareOK) { |
219 |
System.out.println(getClass().getName() + '#' + getName()); |
220 |
for (int i = 0; i < testFiles.length; i += 2) { |
221 |
System.out.print(testFiles[i]); |
222 |
System.out.println(" ["); //$NON-NLS-1$ |
223 |
System.out.println(testFiles[i + 1]); |
224 |
System.out.println("]"); //$NON-NLS-1$ |
225 |
} |
226 |
} |
227 |
if (!compileKO) |
228 |
System.out.println(errOutputString); |
229 |
if (compileKO && !compareOK) { |
230 |
System.out.println("--[START OUT]--\n" |
231 |
+ "------------- Expected: -------------\n" |
232 |
+ expectedSuccessOutOutputString |
233 |
+ "------------- but was: -------------\n" |
234 |
+ Util.displayString(outOutputString) |
235 |
+ "\n---[END OUT]---\n--[START ERR]--\n" |
236 |
+ "------------- Expected: -------------\n" |
237 |
+ expectedSuccessErrOutputString |
238 |
+ "------------- but was: -------------\n" |
239 |
+ Util.displayString(errOutputString) |
240 |
+ "\n---[END ERR]--\n"); |
241 |
} |
242 |
assertTrue("Unexpected success: " + errOutputString, compileKO); |
243 |
assertTrue("Unexpected output for invocation with arguments [" |
244 |
+ commandLine + "]:\n" + "--[START]--\n" + outOutputString |
245 |
+ errOutputString + "---[END]---\n", compareOK); |
246 |
} |
247 |
|
248 |
/** |
249 |
* Return true if and only if the two strings passed as parameters compare equal, |
250 |
* modulo the replacement of all OUTPUT_DIR values by a normalized placeholder. |
251 |
* This is meant to erase the variations of OUTPUT_DIR in function of the |
252 |
* test machine, the user account, etc. |
253 |
* @param logA one of the strings to compare |
254 |
* @param logB one of the strings to compare |
255 |
* @return true if logA and logB compare equal once normalized |
256 |
*/ |
257 |
private boolean normalizedComparison (String logA, String logB) { |
258 |
if (logA == null) |
259 |
return logB == null; |
260 |
if (logB == null) |
261 |
return false; |
262 |
StringBuffer normalizedLogA = new StringBuffer(logA), normalizedLogB = new StringBuffer(logB); |
263 |
int outputDirLength = OUTPUT_DIR.length(), nextOccurrenceIndex; |
264 |
while ((nextOccurrenceIndex = normalizedLogA.indexOf(OUTPUT_DIR)) != -1) |
265 |
normalizedLogA.replace(nextOccurrenceIndex, nextOccurrenceIndex + outputDirLength, |
266 |
OUTPUT_DIR_PLACEHOLDER); |
267 |
// TODO check utils to find a canned suitable substitution |
268 |
while ((nextOccurrenceIndex = normalizedLogB.indexOf(OUTPUT_DIR)) != -1) |
269 |
normalizedLogB.replace(nextOccurrenceIndex, nextOccurrenceIndex + outputDirLength, |
270 |
OUTPUT_DIR_PLACEHOLDER); |
271 |
return normalizedLogA.toString().equals(normalizedLogB.toString()); |
272 |
} |
273 |
|
24 |
public void test01() { |
274 |
public void test01() { |
25 |
|
275 |
|
26 |
String commandLine = "-classpath \"D:/a folder\";d:/jdk1.4/jre/lib/rt.jar -1.4 -preserveAllLocals -g -verbose d:/eclipse/workspaces/development2.0/plugins/Bar/src2/ -d d:/test"; |
276 |
String commandLine = "-classpath \"D:/a folder\";d:/jdk1.4/jre/lib/rt.jar -1.4 -preserveAllLocals -g -verbose d:/eclipse/workspaces/development2.0/plugins/Bar/src2/ -d d:/test"; |
Lines 117-122
Link Here
|
117 |
expected, |
367 |
expected, |
118 |
result); |
368 |
result); |
119 |
} |
369 |
} |
|
|
370 |
// test the tester - runConformTest |
371 |
public void test007(){ |
372 |
this.runConformTest( |
373 |
new String[] { |
374 |
"X.java", |
375 |
"import java.util.List;\n" + |
376 |
"\n" + |
377 |
"@SuppressWarnings(\"all\"//$NON-NLS-1$\n" + |
378 |
")\n" + |
379 |
"public class X {\n" + |
380 |
" public static void main(String[] args) {\n" + |
381 |
" if (false) {\n" + |
382 |
" ;\n" + |
383 |
" } else {\n" + |
384 |
" }\n" + |
385 |
" // Zork z;\n" + |
386 |
" }\n" + |
387 |
"}" |
388 |
}, |
389 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
390 |
+ " -1.5" //$NON-NLS-1$ |
391 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
392 |
+ " -bootclasspath d:/jdk1.5.0/jre/lib/rt.jar" //$NON-NLS-1$ |
393 |
+ " -cp d:/jdk1.5.0/jre/lib/jce.jar" //$NON-NLS-1$ |
394 |
+ " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" //$NON-NLS-1$ |
395 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
396 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
397 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n" + |
398 |
"[1 .class file generated]\r\n", |
399 |
"----------\r\n" + |
400 |
"1. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
401 |
" (at line 1)\r\n" + |
402 |
" import java.util.List;\r\n" + |
403 |
" ^^^^^^^^^^^^^^\r\n" + |
404 |
"The import java.util.List is never used\r\n" + |
405 |
"----------\r\n" + |
406 |
"1 problem (1 warning)", true); |
407 |
} |
408 |
// test the tester - runNegativeTest |
409 |
public void test008(){ |
410 |
this.runNegativeTest( |
411 |
new String[] { |
412 |
"X.java", |
413 |
"import java.util.List;\n" + |
414 |
"\n" + |
415 |
"@SuppressWarnings(\"all\"//$NON-NLS-1$\n" + |
416 |
")\n" + |
417 |
"public class X {\n" + |
418 |
" public static void main(String[] args) {\n" + |
419 |
" if (false) {\n" + |
420 |
" ;\n" + |
421 |
" } else {\n" + |
422 |
" }\n" + |
423 |
" Zork z;\n" + |
424 |
" }\n" + |
425 |
"}" |
426 |
}, |
427 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
428 |
+ " -1.5" //$NON-NLS-1$ |
429 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
430 |
+ " -bootclasspath d:/jdk1.5.0/jre/lib/rt.jar" //$NON-NLS-1$ |
431 |
+ " -cp d:/jdk1.5.0/jre/lib/jce.jar" //$NON-NLS-1$ |
432 |
+ " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" //$NON-NLS-1$ |
433 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
434 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
435 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n" + |
436 |
"[1 .class file generated]\r\n", |
437 |
"----------\r\n" + |
438 |
"1. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
439 |
" (at line 1)\r\n" + |
440 |
" import java.util.List;\r\n" + |
441 |
" ^^^^^^^^^^^^^^\r\n" + |
442 |
"The import java.util.List is never used\r\n" + |
443 |
"----------\r\n" + |
444 |
"----------\r\n" + |
445 |
"2. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
446 |
" (at line 11)\r\n" + |
447 |
" Zork z;\r\n" + |
448 |
" ^^^^\r\n" + |
449 |
"Zork cannot be resolved to a type\r\n" + |
450 |
"----------\r\n" + |
451 |
"2 problems (1 error, 1 warning)", true); |
452 |
} |
453 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=92398 -- a case that works, another that does not |
454 |
public void test009(){ |
455 |
this.runNegativeTest( |
456 |
new String[] { |
457 |
"X.java", |
458 |
"/** */\n" + |
459 |
"public class X {\n" + |
460 |
" OK1 ok1;\n" + |
461 |
" OK2 ok2;\n" + |
462 |
" Warn warn;\n" + |
463 |
" KO ko;\n" + |
464 |
" Zork z;\r\n" + |
465 |
"}", |
466 |
"OK1.java", |
467 |
"/** */\n" + |
468 |
"public class OK1 {\n" + |
469 |
" // empty\n" + |
470 |
"}", |
471 |
"OK2.java", |
472 |
"/** */\n" + |
473 |
"public class OK2 {\n" + |
474 |
" // empty\n" + |
475 |
"}", |
476 |
"Warn.java", |
477 |
"/** */\n" + |
478 |
"public class Warn {\n" + |
479 |
" // empty\n" + |
480 |
"}", |
481 |
"KO.java", |
482 |
"/** */\n" + |
483 |
"public class KO {\n" + |
484 |
" // empty\n" + |
485 |
"}", |
486 |
}, |
487 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
488 |
+ " -1.5" //$NON-NLS-1$ |
489 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
490 |
+ " -cp \"" + OUTPUT_DIR //$NON-NLS-1$ |
491 |
+ "[+OK2.java;~Warn.java;-KO.java]" //$NON-NLS-1$ |
492 |
+ "\"" //$NON-NLS-1$ |
493 |
+ " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" //$NON-NLS-1$ |
494 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
495 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
496 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n" + |
497 |
"[5 .class files generated]\r\n", |
498 |
"----------\r\n" + |
499 |
"1. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
500 |
" (at line 5)\r\n" + |
501 |
" Warn warn;\r\n" + |
502 |
" ^^^^\r\n" + |
503 |
"Discouraged access: Warn\r\n" + |
504 |
"----------\r\n" + |
505 |
"----------\r\n" + |
506 |
"2. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
507 |
" (at line 6)\r\n" + |
508 |
" KO ko;\r\n" + |
509 |
" ^^\r\n" + |
510 |
"Access restriction: KO\r\n" + |
511 |
"----------\r\n" + |
512 |
// access restriction errors are expected to resolve to warnings |
513 |
"----------\r\n" + |
514 |
"3. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
515 |
" (at line 7)\r\n" + |
516 |
" Zork z;\r\n" + |
517 |
" ^^^^\r\n" + |
518 |
"Zork cannot be resolved to a type\r\n" + |
519 |
"----------\r\n" + |
520 |
"3 problems (1 error, 2 warnings)", |
521 |
true); |
522 |
} |
523 |
// command line - no user classpath nor bootclasspath |
524 |
public void test010(){ |
525 |
this.runConformTest( |
526 |
new String[] { |
527 |
"X.java", |
528 |
"import java.util.List;\n" + |
529 |
"\n" + |
530 |
"@SuppressWarnings(\"all\"//$NON-NLS-1$\n" + |
531 |
")\n" + |
532 |
"public class X {\n" + |
533 |
" public static void main(String[] args) {\n" + |
534 |
" if (false) {\n" + |
535 |
" ;\n" + |
536 |
" } else {\n" + |
537 |
" }\n" + |
538 |
" // Zork z;\n" + |
539 |
" }\n" + |
540 |
"}" |
541 |
}, |
542 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
543 |
+ " -1.5" //$NON-NLS-1$ |
544 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
545 |
// + " -bootclasspath d:/jdk1.5.0/jre/lib/rt.jar" //$NON-NLS-1$ |
546 |
// + " -cp d:/jdk1.5.0/jre/lib/jce.jar" //$NON-NLS-1$ |
547 |
+ " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" //$NON-NLS-1$ |
548 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
549 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
550 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n" + |
551 |
"[1 .class file generated]\r\n", |
552 |
"----------\r\n" + |
553 |
"1. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
554 |
" (at line 1)\r\n" + |
555 |
" import java.util.List;\r\n" + |
556 |
" ^^^^^^^^^^^^^^\r\n" + |
557 |
"The import java.util.List is never used\r\n" + |
558 |
"----------\r\n" + |
559 |
"1 problem (1 warning)", true); |
560 |
} |
561 |
// command line - improper classpath (ends with ;) |
562 |
public void test011(){ |
563 |
this.runConformTest( |
564 |
new String[] { |
565 |
"X.java", |
566 |
"/** */\n" + |
567 |
"public class X {\n" + |
568 |
"}", |
569 |
}, |
570 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
571 |
+ " -1.5" //$NON-NLS-1$ |
572 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
573 |
+ " -cp \"" + OUTPUT_DIR //$NON-NLS-1$ |
574 |
+ "[+**/OK2.java;~**/Warn.java;-KO.java]" //$NON-NLS-1$ |
575 |
+ "\";" //$NON-NLS-1$ |
576 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
577 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
578 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n", |
579 |
"incorrect classpath: C:\\Documents and Settings\\mdl\\comptest\\regression[+**/OK2.java;~**/Warn.java;-KO.java];\r\n", |
580 |
true); |
581 |
} |
582 |
// command line - help |
583 |
public void test012(){ |
584 |
this.runConformTest( |
585 |
new String[0], |
586 |
" -help" //$NON-NLS-1$ |
587 |
+ " -showversion -referenceInfo", //$NON-NLS-1$ |
588 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\n" + |
589 |
" \n" + |
590 |
" Usage: <options> <source files | directories>\n" + |
591 |
" If directories are specified, then their source contents are compiled.\n" + |
592 |
" Possible options are listed below. Options enabled by default are prefixed with \'+\'\n" + |
593 |
" \n" + |
594 |
" Classpath options:\n" + |
595 |
" -cp -classpath <directories and zip/jar files separated by ;>\n" + |
596 |
" specify location for application classes and sources. Each\n" + |
597 |
" directory or file can specify access rules for types between\n" + |
598 |
" \'[\' and \']\' (e.g. [-X.java] to deny access to type X)\n" + |
599 |
" -bootclasspath <directories and zip/jar files separated by ;>\n" + |
600 |
" specify location for system classes. Each directory or file can\n" + |
601 |
" specify access rules for types between \'[\' and \']\' (e.g. [-X.java]\n" + |
602 |
" to deny access to type X)\n" + |
603 |
" -d <dir> destination directory (if omitted, no directory is created)\n" + |
604 |
" -d none generate no .class files\n" + |
605 |
" -encoding <enc> specify custom encoding for all sources. Each file/directory can override it\n" + |
606 |
" when suffixed with \'[\'<enc>\']\' (e.g. X.java[utf8])\n" + |
607 |
" \n" + |
608 |
" Compliance options:\n" + |
609 |
" -1.3 use 1.3 compliance level (implicit -source 1.3 -target 1.1)\n" + |
610 |
" -1.4 + use 1.4 compliance level (implicit -source 1.3 -target 1.2)\n" + |
611 |
" -1.5 use 1.5 compliance level (implicit -source 1.5 -target 1.5)\n" + |
612 |
" -source <version> set source level: 1.3 to 1.5 (or 5 or 5.0)\n" + |
613 |
" -target <version> set classfile target level: 1.1 to 1.5 (or 5 or 5.0)\n" + |
614 |
" \n" + |
615 |
" Warning options:\n" + |
616 |
" -deprecation + deprecation outside deprecated code\n" + |
617 |
" -nowarn disable all warnings\n" + |
618 |
" -warn:none disable all warnings\n" + |
619 |
" -warn:<warnings separated by ,> enable exactly the listed warnings\n" + |
620 |
" -warn:+<warnings separated by ,> enable additional warnings\n" + |
621 |
" -warn:-<warnings separated by ,> disable specific warnings\n" + |
622 |
" allDeprecation deprecation including inside deprecated code\n" + |
623 |
" allJavadoc invalid or missing javadoc\n" + |
624 |
" assertIdentifier + \'assert\' used as identifier\n" + |
625 |
" boxing autoboxing conversion\n" + |
626 |
" charConcat + char[] in String concat\n" + |
627 |
" conditionAssign possible accidental boolean assignment\n" + |
628 |
" constructorName + method with constructor name\n" + |
629 |
" dep-ann missing @Deprecated annotation\n" + |
630 |
" deprecation + deprecation outside deprecated code\n" + |
631 |
" emptyBlock undocumented empty block\n" + |
632 |
" enumSwitch incomplete enum switch\n" + |
633 |
" fieldHiding field hiding another variable\n" + |
634 |
" finalBound type parameter with final bound\n" + |
635 |
" finally + finally block not completing normally\n" + |
636 |
" indirectStatic indirect reference to static member\n" + |
637 |
" intfAnnotation + annotation type used as super interface\n" + |
638 |
" intfNonInherited + interface non-inherited method compatibility\n" + |
639 |
" javadoc invalid javadoc\n" + |
640 |
" localHiding local variable hiding another variable\n" + |
641 |
" maskedCatchBlock + hidden catch block\n" + |
642 |
" nls string literal lacking non-nls tag //$NON-NLS-<n>$\n" + |
643 |
" noEffectAssign + assignment without effect\n" + |
644 |
" null missing or redundant null check\n" + |
645 |
" over-ann missing @Override annotation\n" + |
646 |
" pkgDefaultMethod + attempt to override package-default method\n" + |
647 |
" semicolon unnecessary semicolon, empty statement\n" + |
648 |
" serial + missing serialVersionUID\n" + |
649 |
" suppress + enable @SuppressWarnings\n" + |
650 |
" unqualifiedField unqualified reference to field\n" + |
651 |
" unchecked + unchecked type operation\n" + |
652 |
" unusedArgument unread method parameter\n" + |
653 |
" unusedImport + unused import declaration\n" + |
654 |
" unusedLocal unread local variable\n" + |
655 |
" unusedPrivate unused private member declaration\n" + |
656 |
" unusedThrown unused declared thrown exception\n" + |
657 |
" unnecessaryElse unnecessary else clause\n" + |
658 |
" uselessTypeCheck unnecessary cast/instanceof operation\n" + |
659 |
" specialParamHiding constructor or setter parameter hiding another field\n" + |
660 |
" staticReceiver + non-static reference to static member\n" + |
661 |
" syntheticAccess synthetic access for innerclass\n" + |
662 |
" tasks(<tags separated by |>) tasks identified by tags inside comments\n" + |
663 |
" typeHiding + type parameter hiding another type\n" + |
664 |
" varargsCast + varargs argument need explicit cast\n" + |
665 |
" warningToken + unhandled warning token in @SuppressWarnings\n" + |
666 |
" \n" + |
667 |
" Debug options:\n" + |
668 |
" -g[:lines,vars,source] custom debug info\n" + |
669 |
" -g:lines,source + both lines table and source debug info\n" + |
670 |
" -g all debug info\n" + |
671 |
" -g:none no debug info\n" + |
672 |
" -preserveAllLocals preserve unused local vars for debug purpose\n" + |
673 |
" \n" + |
674 |
" Advanced options:\n" + |
675 |
" @<file> read command line arguments from file\n" + |
676 |
" -maxProblems <n> max number of problems per compilation unit (100 by default)\n" + |
677 |
" -log <file> log to a file\n" + |
678 |
" -proceedOnError do not stop at first error, dumping class files with problem methods\n" + |
679 |
" -verbose enable verbose output\n" + |
680 |
" -referenceInfo compute reference info\n" + |
681 |
" -progress show progress (only in -log mode)\n" + |
682 |
" -time display speed information \n" + |
683 |
" -noExit do not call System.exit(n) at end of compilation (n==0 if no error)\n" + |
684 |
" -repeat <n> repeat compilation process <n> times for perf analysis\n" + |
685 |
" -inlineJSR inline JSR bytecode (implicit if target >= 1.5)\n" + |
686 |
" -enableJavadoc consider references in javadoc\n" + |
687 |
" \n" + |
688 |
" -? -help print this help message\n" + |
689 |
" -v -version print compiler version\n" + |
690 |
" -showversion print compiler version and continue\n" + |
691 |
"\r\n", |
692 |
"", true); |
693 |
} |
694 |
|
120 |
public static Class testClass() { |
695 |
public static Class testClass() { |
121 |
return BatchCompilerTest.class; |
696 |
return BatchCompilerTest.class; |
122 |
} |
697 |
} |