Lines 229-237
Link Here
|
229 |
} |
229 |
} |
230 |
} |
230 |
} |
231 |
|
231 |
|
232 |
/*###################################### |
|
|
233 |
* Specific method to let tests Sun javac compilation available... |
234 |
#######################################*/ |
235 |
protected void compileAndDeploy(String source, String directoryName, String className) { |
232 |
protected void compileAndDeploy(String source, String directoryName, String className) { |
236 |
File directory = new File(SOURCE_DIRECTORY); |
233 |
File directory = new File(SOURCE_DIRECTORY); |
237 |
if (!directory.exists()) { |
234 |
if (!directory.exists()) { |
Lines 266-273
Link Here
|
266 |
.append(EVAL_DIRECTORY); |
263 |
.append(EVAL_DIRECTORY); |
267 |
if (this.complianceLevel.compareTo(COMPLIANCE_1_5) < 0) { |
264 |
if (this.complianceLevel.compareTo(COMPLIANCE_1_5) < 0) { |
268 |
buffer.append("\" -1.4 -source 1.3 -target 1.2"); |
265 |
buffer.append("\" -1.4 -source 1.3 -target 1.2"); |
269 |
} else { |
266 |
} else if (this.complianceLevel.compareTo(COMPLIANCE_1_5) == 0) { |
270 |
buffer.append("\" -1.5"); |
267 |
buffer.append("\" -1.5"); |
|
|
268 |
} else if (this.complianceLevel.compareTo(COMPLIANCE_1_6) == 0) { |
269 |
buffer.append("\" -1.6"); |
270 |
} else if (this.complianceLevel.compareTo(COMPLIANCE_1_7) == 0) { |
271 |
buffer.append("\" -1.7"); |
271 |
} |
272 |
} |
272 |
buffer |
273 |
buffer |
273 |
.append(" -preserveAllLocals -nowarn -g -classpath \"") |
274 |
.append(" -preserveAllLocals -nowarn -g -classpath \"") |
Lines 1243-1248
Link Here
|
1243 |
} |
1244 |
} |
1244 |
} |
1245 |
} |
1245 |
|
1246 |
|
|
|
1247 |
protected void runTest( |
1248 |
String[] testFiles, |
1249 |
boolean expectingCompilerErrors, |
1250 |
String expectedCompilerLog, |
1251 |
String expectedOutputString, |
1252 |
boolean forceExecution, |
1253 |
String[] classLib, |
1254 |
boolean shouldFlushOutputDirectory, |
1255 |
String[] vmArguments, |
1256 |
Map customOptions, |
1257 |
ICompilerRequestor clientRequestor, |
1258 |
boolean skipJavac) { |
1259 |
// Non-javac part |
1260 |
try { |
1261 |
if (shouldFlushOutputDirectory) |
1262 |
Util.flushDirectoryContent(new File(OUTPUT_DIR)); |
1263 |
|
1264 |
IProblemFactory problemFactory = getProblemFactory(); |
1265 |
Requestor requestor = |
1266 |
new Requestor( |
1267 |
problemFactory, |
1268 |
OUTPUT_DIR.endsWith(File.separator) ? OUTPUT_DIR : OUTPUT_DIR + File.separator, |
1269 |
forceExecution, |
1270 |
clientRequestor, |
1271 |
false, /* show category */ |
1272 |
false /* show warning token*/); |
1273 |
|
1274 |
Map options = getCompilerOptions(); |
1275 |
if (customOptions != null) { |
1276 |
options.putAll(customOptions); |
1277 |
} |
1278 |
CompilerOptions compilerOptions = new CompilerOptions(options); |
1279 |
compilerOptions.performMethodsFullRecovery = false; |
1280 |
compilerOptions.performStatementsRecovery = false; |
1281 |
Compiler batchCompiler = |
1282 |
new Compiler( |
1283 |
getNameEnvironment(new String[]{}, classLib), |
1284 |
getErrorHandlingPolicy(), |
1285 |
compilerOptions, |
1286 |
requestor, |
1287 |
problemFactory); |
1288 |
compilerOptions.produceReferenceInfo = true; |
1289 |
Throwable exception = null; |
1290 |
try { |
1291 |
batchCompiler.compile(Util.compilationUnits(testFiles)); // compile all files together |
1292 |
} catch(RuntimeException e){ |
1293 |
exception = e; |
1294 |
throw e; |
1295 |
} catch(Error e) { |
1296 |
exception = e; |
1297 |
throw e; |
1298 |
} finally { |
1299 |
String computedProblemLog = Util.convertToIndependantLineDelimiter(requestor.problemLog.toString()); |
1300 |
String platformIndependantExpectedLog = Util.convertToIndependantLineDelimiter(expectedCompilerLog); |
1301 |
if (!platformIndependantExpectedLog.equals(computedProblemLog)) { |
1302 |
System.out.println(getClass().getName() + '#' + getName()); |
1303 |
System.out.println(Util.displayString(computedProblemLog, INDENT, SHIFT)); |
1304 |
for (int i = 0; i < testFiles.length; i += 2) { |
1305 |
System.out.print(testFiles[i]); |
1306 |
System.out.println(" ["); //$NON-NLS-1$ |
1307 |
System.out.println(testFiles[i + 1]); |
1308 |
System.out.println("]"); //$NON-NLS-1$ |
1309 |
} |
1310 |
} |
1311 |
if (exception == null) { |
1312 |
if (expectingCompilerErrors) { |
1313 |
assertTrue("Unexpected success", requestor.hasErrors); |
1314 |
} else { |
1315 |
assertFalse("Unexpected failure", requestor.hasErrors); |
1316 |
} |
1317 |
assertEquals("Invalid problem log ", platformIndependantExpectedLog, computedProblemLog); |
1318 |
} |
1319 |
} |
1320 |
if (!requestor.hasErrors || forceExecution) { |
1321 |
String sourceFile = testFiles[0]; |
1322 |
|
1323 |
// Compute class name by removing ".java" and replacing slashes with dots |
1324 |
String className = sourceFile.substring(0, sourceFile.length() - 5).replace('/', '.').replace('\\', '.'); |
1325 |
if (className.endsWith(PACKAGE_INFO_NAME)) return; |
1326 |
|
1327 |
if (vmArguments != null) { |
1328 |
if (this.verifier != null) { |
1329 |
this.verifier.shutDown(); |
1330 |
} |
1331 |
this.verifier = new TestVerifier(false); |
1332 |
this.createdVerifier = true; |
1333 |
} |
1334 |
boolean passed = |
1335 |
this.verifier.verifyClassFiles( |
1336 |
sourceFile, |
1337 |
className, |
1338 |
expectedOutputString, |
1339 |
this.classpaths, |
1340 |
null, |
1341 |
vmArguments); |
1342 |
if (!passed) { |
1343 |
System.out.println(getClass().getName() + '#' + getName()); |
1344 |
for (int i = 0; i < testFiles.length; i += 2) { |
1345 |
System.out.print(testFiles[i]); |
1346 |
System.out.println(" ["); //$NON-NLS-1$ |
1347 |
System.out.println(testFiles[i + 1]); |
1348 |
System.out.println("]"); //$NON-NLS-1$ |
1349 |
} |
1350 |
} |
1351 |
assertTrue(this.verifier.failureReason, // computed by verifyClassFiles(...) action |
1352 |
passed); |
1353 |
if (vmArguments != null) { |
1354 |
if (this.verifier != null) { |
1355 |
this.verifier.shutDown(); |
1356 |
} |
1357 |
this.verifier = new TestVerifier(false); |
1358 |
this.createdVerifier = true; |
1359 |
} |
1360 |
} |
1361 |
// javac part |
1362 |
} catch (AssertionFailedError e) { |
1363 |
throw e; |
1364 |
} finally { |
1365 |
if (RUN_JAVAC && !skipJavac) |
1366 |
runJavac(testFiles, null, expectedOutputString, shouldFlushOutputDirectory); |
1367 |
// PREMATURE for now, skipping javac implies skipping the compile |
1368 |
// and execution steps; yet, only cases for which the |
1369 |
// execution step was a problem have been discovered so |
1370 |
// far; may consider skipping the execution step only |
1371 |
} |
1372 |
} |
1373 |
|
1246 |
protected void setUp() throws Exception { |
1374 |
protected void setUp() throws Exception { |
1247 |
super.setUp(); |
1375 |
super.setUp(); |
1248 |
if (this.verifier == null) { |
1376 |
if (this.verifier == null) { |