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("test013")); |
33 |
suite.addTest(new BatchCompilerTest("test014")); |
34 |
suite.addTest(new BatchCompilerTest("test015")); |
35 |
return suite; |
36 |
} |
22 |
return setupSuite(testClass()); |
37 |
return setupSuite(testClass()); |
|
|
38 |
// TODO find a way to reduce the number of command line tests to one per |
39 |
// test run (aka do not add 1.3, 1.4, 1.5 supplementary level) |
23 |
} |
40 |
} |
|
|
41 |
|
42 |
/** |
43 |
* Run a compilation test that is expected to complete successfully and |
44 |
* compare the outputs to expected ones. |
45 |
* |
46 |
* @param testFiles |
47 |
* the source files, given as a suite of file name, file content; |
48 |
* file names are relative to the output directory |
49 |
* @param commandLine |
50 |
* the command line to pass to |
51 |
* {@link Main#compile(String) Main#compile} |
52 |
* @param expectedSuccessOutOutputString |
53 |
* the expected contents of the standard output stream; pass null |
54 |
* to bypass the comparison |
55 |
* @param expectedSuccessErrOutputString |
56 |
* the expected contents of the standard error output stream; |
57 |
* pass null to bypass the comparison |
58 |
* @param shouldFlushOutputDirectory |
59 |
* pass true to get the output directory flushed before the test |
60 |
* runs |
61 |
*/ |
62 |
protected void runConformTest(String[] testFiles, String commandLine, |
63 |
String expectedSuccessOutOutputString, |
64 |
String expectedSuccessErrOutputString, |
65 |
boolean shouldFlushOutputDirectory) { |
66 |
File outputDirectory = new File(OUTPUT_DIR); |
67 |
if (shouldFlushOutputDirectory) |
68 |
Util.flushDirectoryContent(outputDirectory); |
69 |
try { |
70 |
if (!outputDirectory.isDirectory()) { |
71 |
outputDirectory.mkdirs(); |
72 |
} |
73 |
PrintWriter sourceFileWriter; |
74 |
for (int i = 0; i < testFiles.length; i += 2) { |
75 |
sourceFileWriter = new PrintWriter(new FileOutputStream( |
76 |
OUTPUT_DIR + File.separator + testFiles[i])); |
77 |
sourceFileWriter.write(testFiles[i + 1]); |
78 |
sourceFileWriter.close(); |
79 |
} |
80 |
} catch (FileNotFoundException e) { |
81 |
e.printStackTrace(); |
82 |
throw new RuntimeException(e); |
83 |
} |
84 |
String printerWritersNameRoot = OUTPUT_DIR + File.separator |
85 |
+ testName(); |
86 |
String outFileName = printerWritersNameRoot + "out.txt", errFileName = printerWritersNameRoot + "err.txt"; //$NON-NLS-1$ //$NON-NLS-2$ |
87 |
Main batchCompiler; |
88 |
try { |
89 |
batchCompiler = new Main(new PrintWriter(new FileOutputStream( |
90 |
outFileName)), new PrintWriter(new FileOutputStream( |
91 |
errFileName)), false); |
92 |
} catch (FileNotFoundException e) { |
93 |
System.out.println(getClass().getName() + '#' + getName()); |
94 |
e.printStackTrace(); |
95 |
throw new RuntimeException(e); |
96 |
} |
97 |
boolean compileOK; |
98 |
try { |
99 |
compileOK = batchCompiler.compile(Main.tokenize(commandLine)); |
100 |
} catch (RuntimeException e) { |
101 |
compileOK = false; |
102 |
System.out.println(getClass().getName() + '#' + getName()); |
103 |
e.printStackTrace(); |
104 |
throw e; |
105 |
} |
106 |
String outOutputString = Util.fileContent(outFileName), errOutputString = Util |
107 |
.fileContent(errFileName); |
108 |
boolean compareOK = false; |
109 |
if (compileOK) { |
110 |
compareOK = |
111 |
normalizedComparison(expectedSuccessOutOutputString, |
112 |
outOutputString) |
113 |
&& normalizedComparison(expectedSuccessErrOutputString, |
114 |
errOutputString); |
115 |
} |
116 |
if (!compileOK || !compareOK) { |
117 |
System.out.println(getClass().getName() + '#' + getName()); |
118 |
for (int i = 0; i < testFiles.length; i += 2) { |
119 |
System.out.print(testFiles[i]); |
120 |
System.out.println(" ["); //$NON-NLS-1$ |
121 |
System.out.println(testFiles[i + 1]); |
122 |
System.out.println("]"); //$NON-NLS-1$ |
123 |
} |
124 |
} |
125 |
if (!compileOK) |
126 |
System.out.println(errOutputString); |
127 |
if (compileOK && !compareOK) { |
128 |
System.out.println("--[START OUT]--\n" |
129 |
+ "------------- Expected: -------------\n" |
130 |
+ expectedSuccessOutOutputString |
131 |
+ "------------- but was: -------------\n" |
132 |
+ Util.displayString(outOutputString) |
133 |
+ "\n---[END OUT]---\n--[START ERR]--\n" |
134 |
+ "------------- Expected: -------------\n" |
135 |
+ expectedSuccessErrOutputString |
136 |
+ "------------- but was: -------------\n" |
137 |
+ Util.displayString(errOutputString) |
138 |
+ "\n---[END ERR]--\n"); |
139 |
} |
140 |
assertTrue("Unexpected problems: " + errOutputString, compileOK); |
141 |
assertTrue("Unexpected output for invocation with arguments [" |
142 |
+ commandLine + "]:\n" + "--[START]--\n" + outOutputString |
143 |
+ errOutputString + "---[END]---\n", compareOK); |
144 |
} |
145 |
|
146 |
/** |
147 |
* Run a compilation test that is expected to fail and compare the outputs |
148 |
* to expected ones. |
149 |
* |
150 |
* @param testFiles |
151 |
* the source files, given as a suite of file name, file content; |
152 |
* file names are relative to the output directory |
153 |
* @param commandLine |
154 |
* the command line to pass to |
155 |
* {@link Main#compile(String) Main#compile} |
156 |
* @param expectedSuccessOutOutputString |
157 |
* the expected contents of the standard output stream; pass null |
158 |
* to bypass the comparison |
159 |
* @param expectedSuccessErrOutputString |
160 |
* the expected contents of the standard error output stream; |
161 |
* pass null to bypass the comparison |
162 |
* @param shouldFlushOutputDirectory |
163 |
* pass true to get the output directory flushed before the test |
164 |
* runs |
165 |
*/ |
166 |
protected void runNegativeTest(String[] testFiles, String commandLine, |
167 |
String expectedSuccessOutOutputString, |
168 |
String expectedSuccessErrOutputString, |
169 |
boolean shouldFlushOutputDirectory) { |
170 |
File outputDirectory = new File(OUTPUT_DIR); |
171 |
if (shouldFlushOutputDirectory) |
172 |
Util.flushDirectoryContent(outputDirectory); |
173 |
try { |
174 |
if (!outputDirectory.isDirectory()) { |
175 |
outputDirectory.mkdirs(); |
176 |
} |
177 |
PrintWriter sourceFileWriter; |
178 |
for (int i = 0; i < testFiles.length; i += 2) { |
179 |
sourceFileWriter = new PrintWriter(new FileOutputStream( |
180 |
OUTPUT_DIR + File.separator + testFiles[i])); |
181 |
sourceFileWriter.write(testFiles[i + 1]); |
182 |
sourceFileWriter.close(); |
183 |
} |
184 |
} catch (FileNotFoundException e) { |
185 |
e.printStackTrace(); |
186 |
throw new RuntimeException(e); |
187 |
} |
188 |
String printerWritersNameRoot = OUTPUT_DIR + File.separator |
189 |
+ testName(); |
190 |
String outFileName = printerWritersNameRoot + "out.txt", errFileName = printerWritersNameRoot + "err.txt"; //$NON-NLS-1$ //$NON-NLS-2$ |
191 |
Main batchCompiler; |
192 |
try { |
193 |
batchCompiler = new Main(new PrintWriter(new FileOutputStream( |
194 |
outFileName)), new PrintWriter(new FileOutputStream( |
195 |
errFileName)), false); |
196 |
} catch (FileNotFoundException e) { |
197 |
System.out.println(getClass().getName() + '#' + getName()); |
198 |
e.printStackTrace(); |
199 |
throw new RuntimeException(e); |
200 |
} |
201 |
boolean compileKO; |
202 |
try { |
203 |
compileKO = !batchCompiler.compile(Main.tokenize(commandLine)); |
204 |
} catch (RuntimeException e) { |
205 |
compileKO = false; |
206 |
System.out.println(getClass().getName() + '#' + getName()); |
207 |
e.printStackTrace(); |
208 |
throw e; |
209 |
} |
210 |
String outOutputString = Util.fileContent(outFileName), errOutputString = Util |
211 |
.fileContent(errFileName); |
212 |
boolean compareOK = false; |
213 |
if (compileKO) { |
214 |
compareOK = |
215 |
normalizedComparison(expectedSuccessOutOutputString, |
216 |
outOutputString) |
217 |
&& normalizedComparison(expectedSuccessErrOutputString, |
218 |
errOutputString); |
219 |
} |
220 |
if (!compileKO || !compareOK) { |
221 |
System.out.println(getClass().getName() + '#' + getName()); |
222 |
for (int i = 0; i < testFiles.length; i += 2) { |
223 |
System.out.print(testFiles[i]); |
224 |
System.out.println(" ["); //$NON-NLS-1$ |
225 |
System.out.println(testFiles[i + 1]); |
226 |
System.out.println("]"); //$NON-NLS-1$ |
227 |
} |
228 |
} |
229 |
if (!compileKO) |
230 |
System.out.println(errOutputString); |
231 |
if (compileKO && !compareOK) { |
232 |
System.out.println("--[START OUT]--\n" |
233 |
+ "------------- Expected: -------------\n" |
234 |
+ expectedSuccessOutOutputString |
235 |
+ "------------- but was: -------------\n" |
236 |
+ Util.displayString(outOutputString) |
237 |
+ "\n---[END OUT]---\n--[START ERR]--\n" |
238 |
+ "------------- Expected: -------------\n" |
239 |
+ expectedSuccessErrOutputString |
240 |
+ "------------- but was: -------------\n" |
241 |
+ Util.displayString(errOutputString) |
242 |
+ "\n---[END ERR]--\n"); |
243 |
} |
244 |
assertTrue("Unexpected success: " + errOutputString, compileKO); |
245 |
assertTrue("Unexpected output for invocation with arguments [" |
246 |
+ commandLine + "]:\n" + "--[START]--\n" + outOutputString |
247 |
+ errOutputString + "---[END]---\n", compareOK); |
248 |
} |
249 |
|
250 |
/** |
251 |
* Return true if and only if the two strings passed as parameters compare equal, |
252 |
* modulo the replacement of all OUTPUT_DIR values by a normalized placeholder. |
253 |
* This is meant to erase the variations of OUTPUT_DIR in function of the |
254 |
* test machine, the user account, etc. |
255 |
* @param logA one of the strings to compare |
256 |
* @param logB one of the strings to compare |
257 |
* @return true if logA and logB compare equal once normalized |
258 |
*/ |
259 |
private boolean normalizedComparison (String logA, String logB) { |
260 |
if (logA == null) |
261 |
return logB == null; |
262 |
if (logB == null) |
263 |
return false; |
264 |
StringBuffer normalizedLogA = new StringBuffer(logA), normalizedLogB = new StringBuffer(logB); |
265 |
int outputDirLength = OUTPUT_DIR.length(), nextOccurrenceIndex; |
266 |
while ((nextOccurrenceIndex = normalizedLogA.indexOf(OUTPUT_DIR)) != -1) |
267 |
normalizedLogA.replace(nextOccurrenceIndex, nextOccurrenceIndex + outputDirLength, |
268 |
OUTPUT_DIR_PLACEHOLDER); |
269 |
// TODO check utils to find a canned suitable substitution |
270 |
while ((nextOccurrenceIndex = normalizedLogB.indexOf(OUTPUT_DIR)) != -1) |
271 |
normalizedLogB.replace(nextOccurrenceIndex, nextOccurrenceIndex + outputDirLength, |
272 |
OUTPUT_DIR_PLACEHOLDER); |
273 |
return normalizedLogA.toString().equals(normalizedLogB.toString()); |
274 |
} |
275 |
|
24 |
public void test01() { |
276 |
public void test01() { |
25 |
|
277 |
|
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"; |
278 |
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, |
369 |
expected, |
118 |
result); |
370 |
result); |
119 |
} |
371 |
} |
|
|
372 |
// test the tester - runConformTest |
373 |
public void test007(){ |
374 |
this.runConformTest( |
375 |
new String[] { |
376 |
"X.java", |
377 |
"import java.util.List;\n" + |
378 |
"\n" + |
379 |
"@SuppressWarnings(\"all\"//$NON-NLS-1$\n" + |
380 |
")\n" + |
381 |
"public class X {\n" + |
382 |
" public static void main(String[] args) {\n" + |
383 |
" if (false) {\n" + |
384 |
" ;\n" + |
385 |
" } else {\n" + |
386 |
" }\n" + |
387 |
" // Zork z;\n" + |
388 |
" }\n" + |
389 |
"}" |
390 |
}, |
391 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
392 |
+ " -1.5" //$NON-NLS-1$ |
393 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
394 |
+ " -bootclasspath d:/jdk1.5.0/jre/lib/rt.jar" //$NON-NLS-1$ |
395 |
+ " -cp d:/jdk1.5.0/jre/lib/jce.jar" //$NON-NLS-1$ |
396 |
+ " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" //$NON-NLS-1$ |
397 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
398 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
399 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n" + |
400 |
"[1 .class file generated]\r\n", |
401 |
"----------\r\n" + |
402 |
"1. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
403 |
" (at line 1)\r\n" + |
404 |
" import java.util.List;\r\n" + |
405 |
" ^^^^^^^^^^^^^^\r\n" + |
406 |
"The import java.util.List is never used\r\n" + |
407 |
"----------\r\n" + |
408 |
"1 problem (1 warning)", true); |
409 |
} |
410 |
// test the tester - runNegativeTest |
411 |
public void test008(){ |
412 |
this.runNegativeTest( |
413 |
new String[] { |
414 |
"X.java", |
415 |
"import java.util.List;\n" + |
416 |
"\n" + |
417 |
"@SuppressWarnings(\"all\"//$NON-NLS-1$\n" + |
418 |
")\n" + |
419 |
"public class X {\n" + |
420 |
" public static void main(String[] args) {\n" + |
421 |
" if (false) {\n" + |
422 |
" ;\n" + |
423 |
" } else {\n" + |
424 |
" }\n" + |
425 |
" Zork z;\n" + |
426 |
" }\n" + |
427 |
"}" |
428 |
}, |
429 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
430 |
+ " -1.5" //$NON-NLS-1$ |
431 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
432 |
+ " -bootclasspath d:/jdk1.5.0/jre/lib/rt.jar" //$NON-NLS-1$ |
433 |
+ " -cp d:/jdk1.5.0/jre/lib/jce.jar" //$NON-NLS-1$ |
434 |
+ " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" //$NON-NLS-1$ |
435 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
436 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
437 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n" + |
438 |
"[1 .class file generated]\r\n", |
439 |
"----------\r\n" + |
440 |
"1. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
441 |
" (at line 1)\r\n" + |
442 |
" import java.util.List;\r\n" + |
443 |
" ^^^^^^^^^^^^^^\r\n" + |
444 |
"The import java.util.List is never used\r\n" + |
445 |
"----------\r\n" + |
446 |
"----------\r\n" + |
447 |
"2. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
448 |
" (at line 11)\r\n" + |
449 |
" Zork z;\r\n" + |
450 |
" ^^^^\r\n" + |
451 |
"Zork cannot be resolved to a type\r\n" + |
452 |
"----------\r\n" + |
453 |
"2 problems (1 error, 1 warning)", true); |
454 |
} |
455 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=92398 -- a case that works, another that does not |
456 |
public void test009(){ |
457 |
this.runNegativeTest( |
458 |
new String[] { |
459 |
"X.java", |
460 |
"/** */\n" + |
461 |
"public class X {\n" + |
462 |
" OK1 ok1;\n" + |
463 |
" OK2 ok2;\n" + |
464 |
" Warn warn;\n" + |
465 |
" KO ko;\n" + |
466 |
" Zork z;\r\n" + |
467 |
"}", |
468 |
"OK1.java", |
469 |
"/** */\n" + |
470 |
"public class OK1 {\n" + |
471 |
" // empty\n" + |
472 |
"}", |
473 |
"OK2.java", |
474 |
"/** */\n" + |
475 |
"public class OK2 {\n" + |
476 |
" // empty\n" + |
477 |
"}", |
478 |
"Warn.java", |
479 |
"/** */\n" + |
480 |
"public class Warn {\n" + |
481 |
" // empty\n" + |
482 |
"}", |
483 |
"KO.java", |
484 |
"/** */\n" + |
485 |
"public class KO {\n" + |
486 |
" // empty\n" + |
487 |
"}", |
488 |
}, |
489 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
490 |
+ " -1.5" //$NON-NLS-1$ |
491 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
492 |
+ " -cp \"" + OUTPUT_DIR //$NON-NLS-1$ |
493 |
+ "[+OK2.java;~Warn.java;-KO.java]" //$NON-NLS-1$ |
494 |
+ "\"" //$NON-NLS-1$ |
495 |
+ " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" //$NON-NLS-1$ |
496 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
497 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
498 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n" + |
499 |
"[5 .class files generated]\r\n", |
500 |
"----------\r\n" + |
501 |
"1. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
502 |
" (at line 5)\r\n" + |
503 |
" Warn warn;\r\n" + |
504 |
" ^^^^\r\n" + |
505 |
"Discouraged access: Warn\r\n" + |
506 |
"----------\r\n" + |
507 |
"----------\r\n" + |
508 |
"2. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
509 |
" (at line 6)\r\n" + |
510 |
" KO ko;\r\n" + |
511 |
" ^^\r\n" + |
512 |
"Access restriction: KO\r\n" + |
513 |
"----------\r\n" + |
514 |
// access restriction errors are expected to resolve to warnings |
515 |
"----------\r\n" + |
516 |
"3. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
517 |
" (at line 7)\r\n" + |
518 |
" Zork z;\r\n" + |
519 |
" ^^^^\r\n" + |
520 |
"Zork cannot be resolved to a type\r\n" + |
521 |
"----------\r\n" + |
522 |
"3 problems (1 error, 2 warnings)", |
523 |
true); |
524 |
} |
525 |
// command line - no user classpath nor bootclasspath |
526 |
public void test010(){ |
527 |
this.runConformTest( |
528 |
new String[] { |
529 |
"X.java", |
530 |
"import java.util.List;\n" + |
531 |
"\n" + |
532 |
"@SuppressWarnings(\"all\"//$NON-NLS-1$\n" + |
533 |
")\n" + |
534 |
"public class X {\n" + |
535 |
" public static void main(String[] args) {\n" + |
536 |
" if (false) {\n" + |
537 |
" ;\n" + |
538 |
" } else {\n" + |
539 |
" }\n" + |
540 |
" // Zork z;\n" + |
541 |
" }\n" + |
542 |
"}" |
543 |
}, |
544 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
545 |
+ " -1.5" //$NON-NLS-1$ |
546 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
547 |
// + " -bootclasspath d:/jdk1.5.0/jre/lib/rt.jar" //$NON-NLS-1$ |
548 |
// + " -cp d:/jdk1.5.0/jre/lib/jce.jar" //$NON-NLS-1$ |
549 |
+ " -verbose -warn:+deprecation,syntheticAccess,uselessTypeCheck,unsafe,finalBound,unusedLocal" //$NON-NLS-1$ |
550 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
551 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
552 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n" + |
553 |
"[1 .class file generated]\r\n", |
554 |
"----------\r\n" + |
555 |
"1. WARNING in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
556 |
" (at line 1)\r\n" + |
557 |
" import java.util.List;\r\n" + |
558 |
" ^^^^^^^^^^^^^^\r\n" + |
559 |
"The import java.util.List is never used\r\n" + |
560 |
"----------\r\n" + |
561 |
"1 problem (1 warning)", true); |
562 |
} |
563 |
// command line - improper classpath (ends with ;) |
564 |
public void test011(){ |
565 |
this.runConformTest( |
566 |
new String[] { |
567 |
"X.java", |
568 |
"/** */\n" + |
569 |
"public class X {\n" + |
570 |
"}", |
571 |
}, |
572 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
573 |
+ " -1.5" //$NON-NLS-1$ |
574 |
+ " -g -preserveAllLocals" //$NON-NLS-1$ |
575 |
+ " -cp \"" + OUTPUT_DIR //$NON-NLS-1$ |
576 |
+ "[+**/OK2.java;~**/Warn.java;-KO.java]" //$NON-NLS-1$ |
577 |
+ "\";" //$NON-NLS-1$ |
578 |
+ " -proceedOnError -showversion -referenceInfo" //$NON-NLS-1$ |
579 |
+ " -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
580 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\r\n", |
581 |
"incorrect classpath: C:\\Documents and Settings\\mdl\\comptest\\regression[+**/OK2.java;~**/Warn.java;-KO.java];\r\n", |
582 |
true); |
583 |
} |
584 |
// command line - help |
585 |
public void test012(){ |
586 |
this.runConformTest( |
587 |
new String[0], |
588 |
" -help" //$NON-NLS-1$ |
589 |
+ " -showversion -referenceInfo", //$NON-NLS-1$ |
590 |
"Eclipse Java Compiler 0.556, pre-3.1.0 milestone-7, Copyright IBM Corp 2000, 2005. All rights reserved.\n" + |
591 |
" \n" + |
592 |
" Usage: <options> <source files | directories>\n" + |
593 |
" If directories are specified, then their source contents are compiled.\n" + |
594 |
" Possible options are listed below. Options enabled by default are prefixed with \'+\'\n" + |
595 |
" \n" + |
596 |
" Classpath options:\n" + |
597 |
" -cp -classpath <directories and zip/jar files separated by ;>\n" + |
598 |
" specify location for application classes and sources. Each\n" + |
599 |
" directory or file can specify access rules for types between\n" + |
600 |
" \'[\' and \']\' (e.g. [-X.java] to deny access to type X)\n" + |
601 |
" -bootclasspath <directories and zip/jar files separated by ;>\n" + |
602 |
" specify location for system classes. Each directory or file can\n" + |
603 |
" specify access rules for types between \'[\' and \']\' (e.g. [-X.java]\n" + |
604 |
" to deny access to type X)\n" + |
605 |
" -d <dir> destination directory (if omitted, no directory is created)\n" + |
606 |
" -d none generate no .class files\n" + |
607 |
" -encoding <enc> specify custom encoding for all sources. Each file/directory can override it\n" + |
608 |
" when suffixed with \'[\'<enc>\']\' (e.g. X.java[utf8])\n" + |
609 |
" \n" + |
610 |
" Compliance options:\n" + |
611 |
" -1.3 use 1.3 compliance level (implicit -source 1.3 -target 1.1)\n" + |
612 |
" -1.4 + use 1.4 compliance level (implicit -source 1.3 -target 1.2)\n" + |
613 |
" -1.5 use 1.5 compliance level (implicit -source 1.5 -target 1.5)\n" + |
614 |
" -source <version> set source level: 1.3 to 1.5 (or 5 or 5.0)\n" + |
615 |
" -target <version> set classfile target level: 1.1 to 1.5 (or 5 or 5.0)\n" + |
616 |
" \n" + |
617 |
" Warning options:\n" + |
618 |
" -deprecation + deprecation outside deprecated code\n" + |
619 |
" -nowarn disable all warnings\n" + |
620 |
" -warn:none disable all warnings\n" + |
621 |
" -warn:<warnings separated by ,> enable exactly the listed warnings\n" + |
622 |
" -warn:+<warnings separated by ,> enable additional warnings\n" + |
623 |
" -warn:-<warnings separated by ,> disable specific warnings\n" + |
624 |
" allDeprecation deprecation including inside deprecated code\n" + |
625 |
" allJavadoc invalid or missing javadoc\n" + |
626 |
" assertIdentifier + \'assert\' used as identifier\n" + |
627 |
" boxing autoboxing conversion\n" + |
628 |
" charConcat + char[] in String concat\n" + |
629 |
" conditionAssign possible accidental boolean assignment\n" + |
630 |
" constructorName + method with constructor name\n" + |
631 |
" dep-ann missing @Deprecated annotation\n" + |
632 |
" deprecation + deprecation outside deprecated code\n" + |
633 |
" emptyBlock undocumented empty block\n" + |
634 |
" enumSwitch incomplete enum switch\n" + |
635 |
" fieldHiding field hiding another variable\n" + |
636 |
" finalBound type parameter with final bound\n" + |
637 |
" finally + finally block not completing normally\n" + |
638 |
" indirectStatic indirect reference to static member\n" + |
639 |
" intfAnnotation + annotation type used as super interface\n" + |
640 |
" intfNonInherited + interface non-inherited method compatibility\n" + |
641 |
" javadoc invalid javadoc\n" + |
642 |
" localHiding local variable hiding another variable\n" + |
643 |
" maskedCatchBlock + hidden catch block\n" + |
644 |
" nls string literal lacking non-nls tag //$NON-NLS-<n>$\n" + |
645 |
" noEffectAssign + assignment without effect\n" + |
646 |
" null missing or redundant null check\n" + |
647 |
" over-ann missing @Override annotation\n" + |
648 |
" pkgDefaultMethod + attempt to override package-default method\n" + |
649 |
" semicolon unnecessary semicolon, empty statement\n" + |
650 |
" serial + missing serialVersionUID\n" + |
651 |
" suppress + enable @SuppressWarnings\n" + |
652 |
" unqualifiedField unqualified reference to field\n" + |
653 |
" unchecked + unchecked type operation\n" + |
654 |
" unusedArgument unread method parameter\n" + |
655 |
" unusedImport + unused import declaration\n" + |
656 |
" unusedLocal unread local variable\n" + |
657 |
" unusedPrivate unused private member declaration\n" + |
658 |
" unusedThrown unused declared thrown exception\n" + |
659 |
" unnecessaryElse unnecessary else clause\n" + |
660 |
" uselessTypeCheck unnecessary cast/instanceof operation\n" + |
661 |
" specialParamHiding constructor or setter parameter hiding another field\n" + |
662 |
" staticReceiver + non-static reference to static member\n" + |
663 |
" syntheticAccess synthetic access for innerclass\n" + |
664 |
" tasks(<tags separated by |>) tasks identified by tags inside comments\n" + |
665 |
" typeHiding + type parameter hiding another type\n" + |
666 |
" varargsCast + varargs argument need explicit cast\n" + |
667 |
" warningToken + unhandled warning token in @SuppressWarnings\n" + |
668 |
" \n" + |
669 |
" Debug options:\n" + |
670 |
" -g[:lines,vars,source] custom debug info\n" + |
671 |
" -g:lines,source + both lines table and source debug info\n" + |
672 |
" -g all debug info\n" + |
673 |
" -g:none no debug info\n" + |
674 |
" -preserveAllLocals preserve unused local vars for debug purpose\n" + |
675 |
" \n" + |
676 |
" Advanced options:\n" + |
677 |
" @<file> read command line arguments from file\n" + |
678 |
" -maxProblems <n> max number of problems per compilation unit (100 by default)\n" + |
679 |
" -log <file> log to a file\n" + |
680 |
" -proceedOnError do not stop at first error, dumping class files with problem methods\n" + |
681 |
" -verbose enable verbose output\n" + |
682 |
" -referenceInfo compute reference info\n" + |
683 |
" -progress show progress (only in -log mode)\n" + |
684 |
" -time display speed information \n" + |
685 |
" -noExit do not call System.exit(n) at end of compilation (n==0 if no error)\n" + |
686 |
" -repeat <n> repeat compilation process <n> times for perf analysis\n" + |
687 |
" -inlineJSR inline JSR bytecode (implicit if target >= 1.5)\n" + |
688 |
" -enableJavadoc consider references in javadoc\n" + |
689 |
" \n" + |
690 |
" -? -help print this help message\n" + |
691 |
" -v -version print compiler version\n" + |
692 |
" -showversion print compiler version and continue\n" + |
693 |
"\r\n", |
694 |
"", true); |
695 |
} |
696 |
|
697 |
// command line - xml log contents https://bugs.eclipse.org/bugs/show_bug.cgi?id=93904 |
698 |
public void test013() { |
699 |
String logFileName = OUTPUT_DIR + File.separator + "log.xml"; //$NON-NLS-1$ //$NON-NLS-2$ |
700 |
this.runNegativeTest(new String[] { |
701 |
"X.java", |
702 |
"/** */\n" + |
703 |
"public class X {\n" + |
704 |
" Zork z;\n" + |
705 |
"}", }, |
706 |
"\"" + OUTPUT_DIR + File.separator + |
707 |
"X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
708 |
+ " -1.5" //$NON-NLS-1$ |
709 |
+ " -proceedOnError" //$NON-NLS-1$ |
710 |
+ " -log \"" //$NON-NLS-1$ |
711 |
+ logFileName + "\" -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
712 |
"", |
713 |
"----------\r\n" + |
714 |
"1. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
715 |
" (at line 3)\r\n" + |
716 |
" Zork z;\r\n" + |
717 |
" ^^^^\r\n" + |
718 |
"Zork cannot be resolved to a type\r\n" + |
719 |
"----------\r\n" + |
720 |
"1 problem (1 error)", |
721 |
true); |
722 |
String logContents = Util.fileContent(logFileName); |
723 |
String expectedLogContents = |
724 |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + |
725 |
"<!DOCTYPE compiler SYSTEM \"compiler.dtd\">\r\n" + |
726 |
"<compiler name=\"Eclipse Java Compiler\" copyright=\"Copyright IBM Corp 2000, 2005. All rights reserved.\" version=\"0.557, pre-3.1.0 milestone-7\">\r\n" + |
727 |
" <command_line>\r\n" + |
728 |
" <argument value=\"C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\"/>\r\n" + |
729 |
" <argument value=\"-1.5\"/>\r\n" + |
730 |
" <argument value=\"-proceedOnError\"/>\r\n" + |
731 |
" <argument value=\"-log\"/>\r\n" + |
732 |
" <argument value=\"C:\\Documents and Settings\\mdl\\comptest\\regression\\log.xml\"/>\r\n" + |
733 |
" <argument value=\"-d\"/>\r\n" + |
734 |
" <argument value=\"C:\\Documents and Settings\\mdl\\comptest\\regression\"/>\r\n" + |
735 |
" </command_line>\r\n" + |
736 |
" <options>\r\n" + |
737 |
" <option key=\"org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode\" value=\"disabled\"/>\r\n" + |
738 |
" <option key=\"org.eclipse.jdt.core.compiler.codegen.targetPlatform\" value=\"1.5\"/>\r\n" + |
739 |
" <option key=\"org.eclipse.jdt.core.compiler.codegen.unusedLocal\" value=\"optimize out\"/>\r\n" + |
740 |
" <option key=\"org.eclipse.jdt.core.compiler.compliance\" value=\"1.5\"/>\r\n" + |
741 |
" <option key=\"org.eclipse.jdt.core.compiler.debug.lineNumber\" value=\"generate\"/>\r\n" + |
742 |
" <option key=\"org.eclipse.jdt.core.compiler.debug.localVariable\" value=\"do not generate\"/>\r\n" + |
743 |
" <option key=\"org.eclipse.jdt.core.compiler.debug.sourceFile\" value=\"generate\"/>\r\n" + |
744 |
" <option key=\"org.eclipse.jdt.core.compiler.doc.comment.support\" value=\"disabled\"/>\r\n" + |
745 |
" <option key=\"org.eclipse.jdt.core.compiler.maxProblemPerUnit\" value=\"100\"/>\r\n" + |
746 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.annotationSuperInterface\" value=\"warning\"/>\r\n" + |
747 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.assertIdentifier\" value=\"warning\"/>\r\n" + |
748 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.autoboxing\" value=\"ignore\"/>\r\n" + |
749 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.deprecation\" value=\"warning\"/>\r\n" + |
750 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode\" value=\"disabled\"/>\r\n" + |
751 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod\" value=\"disabled\"/>\r\n" + |
752 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.discouragedReference\" value=\"warning\"/>\r\n" + |
753 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.emptyStatement\" value=\"ignore\"/>\r\n" + |
754 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.enumIdentifier\" value=\"warning\"/>\r\n" + |
755 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.fieldHiding\" value=\"ignore\"/>\r\n" + |
756 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.finalParameterBound\" value=\"warning\"/>\r\n" + |
757 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally\" value=\"warning\"/>\r\n" + |
758 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.forbiddenReference\" value=\"warning\"/>\r\n" + |
759 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock\" value=\"warning\"/>\r\n" + |
760 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod\" value=\"warning\"/>\r\n" + |
761 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch\" value=\"ignore\"/>\r\n" + |
762 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.indirectStaticAccess\" value=\"ignore\"/>\r\n" + |
763 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.invalidJavadoc\" value=\"ignore\"/>\r\n" + |
764 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.invalidJavadocTags\" value=\"enabled\"/>\r\n" + |
765 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef\" value=\"enabled\"/>\r\n" + |
766 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef\" value=\"enabled\"/>\r\n" + |
767 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility\" value=\"private\"/>\r\n" + |
768 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.localVariableHiding\" value=\"ignore\"/>\r\n" + |
769 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.methodWithConstructorName\" value=\"warning\"/>\r\n" + |
770 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation\" value=\"ignore\"/>\r\n" + |
771 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocComments\" value=\"ignore\"/>\r\n" + |
772 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding\" value=\"enabled\"/>\r\n" + |
773 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility\" value=\"public\"/>\r\n" + |
774 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocTags\" value=\"ignore\"/>\r\n" + |
775 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding\" value=\"enabled\"/>\r\n" + |
776 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility\" value=\"private\"/>\r\n" + |
777 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation\" value=\"ignore\"/>\r\n" + |
778 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.missingSerialVersion\" value=\"warning\"/>\r\n" + |
779 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.noEffectAssignment\" value=\"warning\"/>\r\n" + |
780 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion\" value=\"warning\"/>\r\n" + |
781 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral\" value=\"ignore\"/>\r\n" + |
782 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.nullReference\" value=\"ignore\"/>\r\n" + |
783 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod\" value=\"warning\"/>\r\n" + |
784 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment\" value=\"ignore\"/>\r\n" + |
785 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.specialParameterHidingField\" value=\"disabled\"/>\r\n" + |
786 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.staticAccessReceiver\" value=\"warning\"/>\r\n" + |
787 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.suppressWarnings\" value=\"enabled\"/>\r\n" + |
788 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation\" value=\"ignore\"/>\r\n" + |
789 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.typeParameterHiding\" value=\"warning\"/>\r\n" + |
790 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation\" value=\"warning\"/>\r\n" + |
791 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock\" value=\"ignore\"/>\r\n" + |
792 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unhandledWarningToken\" value=\"warning\"/>\r\n" + |
793 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unnecessaryElse\" value=\"ignore\"/>\r\n" + |
794 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck\" value=\"ignore\"/>\r\n" + |
795 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess\" value=\"ignore\"/>\r\n" + |
796 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException\" value=\"ignore\"/>\r\n" + |
797 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding\" value=\"disabled\"/>\r\n" + |
798 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unusedImport\" value=\"warning\"/>\r\n" + |
799 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unusedLocal\" value=\"ignore\"/>\r\n" + |
800 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unusedParameter\" value=\"ignore\"/>\r\n" + |
801 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract\" value=\"disabled\"/>\r\n" + |
802 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete\" value=\"disabled\"/>\r\n" + |
803 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.unusedPrivateMember\" value=\"ignore\"/>\r\n" + |
804 |
" <option key=\"org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast\" value=\"warning\"/>\r\n" + |
805 |
" <option key=\"org.eclipse.jdt.core.compiler.source\" value=\"1.5\"/>\r\n" + |
806 |
" <option key=\"org.eclipse.jdt.core.compiler.taskCaseSensitive\" value=\"enabled\"/>\r\n" + |
807 |
" <option key=\"org.eclipse.jdt.core.compiler.taskPriorities\" value=\"\"/>\r\n" + |
808 |
" <option key=\"org.eclipse.jdt.core.compiler.taskTags\" value=\"\"/>\r\n" + |
809 |
" </options>\r\n" + |
810 |
" <classpaths>\r\n" + |
811 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\charsets.jar\" id=\"JAR\"/>\r\n" + |
812 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\deploy.jar\" id=\"JAR\"/>\r\n" + |
813 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\deploy_g.jar\" id=\"JAR\"/>\r\n" + |
814 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\javaws.jar\" id=\"JAR\"/>\r\n" + |
815 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\javaws_g.jar\" id=\"JAR\"/>\r\n" + |
816 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\jce.jar\" id=\"JAR\"/>\r\n" + |
817 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\jsse.jar\" id=\"JAR\"/>\r\n" + |
818 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\plugin.jar\" id=\"JAR\"/>\r\n" + |
819 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\plugin_g.jar\" id=\"JAR\"/>\r\n" + |
820 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\rt.jar\" id=\"JAR\"/>\r\n" + |
821 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\ext\\dnsns.jar\" id=\"JAR\"/>\r\n" + |
822 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\ext\\localedata.jar\" id=\"JAR\"/>\r\n" + |
823 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\ext\\sunjce_provider.jar\" id=\"JAR\"/>\r\n" + |
824 |
" <classpath path=\"D:\\jdk1.5.0\\jre\\lib\\ext\\sunpkcs11.jar\" id=\"JAR\"/>\r\n" + |
825 |
" <classpath path=\"D:\\eclipse\\workspaces\\tests\\M7\\org.eclipse.platform\\bin\" id=\"FOLDER\"/>\r\n" + |
826 |
" <classpath path=\"D:\\eclipse\\sdk\\eclipse\" id=\"FOLDER\"/>\r\n" + |
827 |
" </classpaths>\r\n" + |
828 |
" <sources>\r\n" + |
829 |
" <source path=\"C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\">\r\n" + |
830 |
" <problems problems=\"1\" errors=\"1\" warnings=\"0\">\r\n" + |
831 |
" <problem charEnd=\"28\" charStart=\"25\" severity=\"ERROR\" line=\"3\" id=\"UndefinedType\">\r\n" + |
832 |
" <message value=\"Zork cannot be resolved to a type\"/>\r\n" + |
833 |
" <source_context value=\"Zork z;\" sourceStart=\"0\" sourceEnd=\"3\"/>\r\n" + |
834 |
" <arguments>\r\n" + |
835 |
" <argument value=\"Zork\"/>\r\n" + |
836 |
" </arguments>\r\n" + |
837 |
" </problem>\r\n" + |
838 |
" </problems>\r\n" + |
839 |
" <classfile path=\"C:\\Documents and Settings\\mdl\\comptest\\regression\\X.class\"/>\r\n" + |
840 |
" </source>\r\n" + |
841 |
" </sources>\r\n" + |
842 |
" <stats>\r\n" + |
843 |
" <problem_summary problems=\"1\" errors=\"1\" warnings=\"0\" tasks=\"0\"/>\r\n" + |
844 |
" </stats>\r\n" + |
845 |
"</compiler>\r\n"; |
846 |
boolean compareOK = normalizedComparison(expectedLogContents, logContents); |
847 |
if (!compareOK) { |
848 |
System.out.println(getClass().getName() + '#' + getName()); |
849 |
System.out.println("--[START LOG]--\n" |
850 |
+ "------------- Expected: -------------\n" |
851 |
+ expectedLogContents |
852 |
+ "------------- but was: -------------\n" |
853 |
+ Util.displayString(logContents) |
854 |
+ "\n---[END LOG]---\n"); |
855 |
} |
856 |
assertTrue("unexpected log contents", compareOK); |
857 |
} |
858 |
|
859 |
// command line - txt log contents https://bugs.eclipse.org/bugs/show_bug.cgi?id=93904 |
860 |
public void test014() { |
861 |
String logFileName = OUTPUT_DIR + File.separator + "log.txt"; //$NON-NLS-1$ //$NON-NLS-2$ |
862 |
this.runNegativeTest(new String[] { |
863 |
"X.java", |
864 |
"/** */\n" + |
865 |
"public class X {\n" + |
866 |
" Zork z;\n" + |
867 |
"}", }, |
868 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
869 |
+ " -1.5" //$NON-NLS-1$ |
870 |
+ " -proceedOnError" //$NON-NLS-1$ |
871 |
+ " -log \"" //$NON-NLS-1$ |
872 |
+ logFileName + "\" -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
873 |
"", |
874 |
"----------\r\n" + |
875 |
"1. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
876 |
" (at line 3)\r\n" + |
877 |
" Zork z;\r\n" + |
878 |
" ^^^^\r\n" + |
879 |
"Zork cannot be resolved to a type\r\n" + |
880 |
"----------\r\n" + |
881 |
"1 problem (1 error)", |
882 |
false); |
883 |
String logContents = Util.fileContent(logFileName); |
884 |
String expectedLogContents = |
885 |
"----------\r\n" + |
886 |
"1. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
887 |
" (at line 3)\r\n" + |
888 |
" Zork z;\r\n" + |
889 |
" ^^^^\r\n" + |
890 |
"Zork cannot be resolved to a type\r\n" + |
891 |
"----------\r\n" + |
892 |
"1 problem (1 error)"; |
893 |
boolean compareOK = normalizedComparison(expectedLogContents, logContents); |
894 |
if (!compareOK) { |
895 |
System.out.println(getClass().getName() + '#' + getName()); |
896 |
System.out.println("--[START LOG]--\n" |
897 |
+ "------------- Expected: -------------\n" |
898 |
+ expectedLogContents |
899 |
+ "------------- but was: -------------\n" |
900 |
+ Util.displayString(logContents) |
901 |
+ "\n---[END LOG]---\n"); |
902 |
} |
903 |
assertTrue("unexpected log contents", compareOK); |
904 |
} |
905 |
|
906 |
// command line - no extension log contents https://bugs.eclipse.org/bugs/show_bug.cgi?id=93904 |
907 |
public void test015() { |
908 |
String logFileName = OUTPUT_DIR + File.separator + "log"; //$NON-NLS-1$ //$NON-NLS-2$ |
909 |
this.runNegativeTest(new String[] { |
910 |
"X.java", |
911 |
"/** */\n" + |
912 |
"public class X {\n" + |
913 |
" Zork z;\n" + |
914 |
"}", }, |
915 |
"\"" + OUTPUT_DIR + File.separator + "X.java\"" //$NON-NLS-1$ //$NON-NLS-2$ |
916 |
+ " -1.5" //$NON-NLS-1$ |
917 |
+ " -proceedOnError" //$NON-NLS-1$ |
918 |
+ " -log \"" //$NON-NLS-1$ |
919 |
+ logFileName + "\" -d \"" + OUTPUT_DIR + "\"", //$NON-NLS-1$ //$NON-NLS-2$ |
920 |
"", |
921 |
"----------\r\n" + |
922 |
"1. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
923 |
" (at line 3)\r\n" + |
924 |
" Zork z;\r\n" + |
925 |
" ^^^^\r\n" + |
926 |
"Zork cannot be resolved to a type\r\n" + |
927 |
"----------\r\n" + |
928 |
"1 problem (1 error)", |
929 |
false); |
930 |
String logContents = Util.fileContent(logFileName); |
931 |
String expectedLogContents = |
932 |
"----------\r\n" + |
933 |
"1. ERROR in C:\\Documents and Settings\\mdl\\comptest\\regression\\X.java\r\n" + |
934 |
" (at line 3)\r\n" + |
935 |
" Zork z;\r\n" + |
936 |
" ^^^^\r\n" + |
937 |
"Zork cannot be resolved to a type\r\n" + |
938 |
"----------\r\n" + |
939 |
"1 problem (1 error)"; |
940 |
boolean compareOK = normalizedComparison(expectedLogContents, logContents); |
941 |
if (!compareOK) { |
942 |
System.out.println(getClass().getName() + '#' + getName()); |
943 |
System.out.println("--[START LOG]--\n" |
944 |
+ "------------- Expected: -------------\n" |
945 |
+ expectedLogContents |
946 |
+ "------------- but was: -------------\n" |
947 |
+ Util.displayString(logContents) |
948 |
+ "\n---[END LOG]---\n"); |
949 |
} |
950 |
assertTrue("unexpected log contents", compareOK); |
951 |
} |
952 |
|
120 |
public static Class testClass() { |
953 |
public static Class testClass() { |
121 |
return BatchCompilerTest.class; |
954 |
return BatchCompilerTest.class; |
122 |
} |
955 |
} |