### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java,v retrieving revision 1.4 diff -u -r1.4 NonFatalErrorTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java 29 Mar 2006 03:50:22 -0000 1.4 +++ src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java 1 Apr 2008 11:22:41 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -57,7 +57,8 @@ " ^^^^^^^^^\n" + "The import java.util is never used\n" + "----------\n", - "SUCCESS", + "SUCCESS" /* expectedOuputString */, + null /* expectedErrorString */, null, true, null, @@ -86,8 +87,8 @@ " ^^^^^^^^^\n" + "The import java.util is never used\n" + "----------\n", - "Unexpected target error running resulting class file for X.java:\n" + - "java.lang.Error: Unresolved compilation problem: \n" + + null /* expectedOutputString */, + "java.lang.Error: Unresolved compilation problem: \n" + /* expectedErrorString */ "\n", null, true, @@ -116,6 +117,7 @@ "Non-externalized string literal; it should be followed by //$NON-NLS-$\n" + "----------\n", "SUCCESS", + null /* expectedErrorString */, null, true, null, @@ -145,6 +147,7 @@ "Empty block should be documented\n" + "----------\n", "SUCCESS", + null /* expectedErrorString */, null, true, null, @@ -173,9 +176,9 @@ " ^^\n" + "Empty block should be documented\n" + "----------\n", - "Unexpected target error running resulting class file for X.java:\n" + - "java.lang.Error: Unresolved compilation problem: \n" + - " Empty block should be documented\n" + + null, + "java.lang.Error: Unresolved compilation problem: \n" + /* expectedErrorString */ + " Empty block should be documented\n" + "\n", null, true, Index: src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java,v retrieving revision 1.27 diff -u -r1.27 FlowAnalysisTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java 17 Jan 2008 13:02:07 -0000 1.27 +++ src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java 1 Apr 2008 11:22:40 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1375,6 +1375,7 @@ "The label label is never explicitly referenced\n" + "----------\n" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, @@ -1408,6 +1409,7 @@ false /* expectingCompilerErrors */, "" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, Index: src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java,v retrieving revision 1.82 diff -u -r1.82 AbstractRegressionTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java 21 Mar 2008 16:59:39 -0000 1.82 +++ src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java 1 Apr 2008 11:22:40 -0000 @@ -1131,7 +1131,8 @@ protected void runNegativeTestWithExecution( String[] testFiles, String expectedProblemLog, - String expectedSuccessOutputString, + String expectedOutputString, + String expectedErrorString, String[] classLib, boolean shouldFlushOutputDirectory, String[] vmArguments, @@ -1211,13 +1212,14 @@ boolean passed = this.verifier.verifyClassFiles( sourceFile, - className, - expectedSuccessOutputString, + className, + expectedOutputString /* expectedOutputString */, + expectedErrorString /* expectedErrorString */, this.classpaths, null, vmArguments); if (!passed) { - String platformIndependantExpectedSuccessOutputString = Util.convertToIndependantLineDelimiter(expectedSuccessOutputString); + String platformIndependantExpectedSuccessOutputString = Util.convertToIndependantLineDelimiter(expectedOutputString); String platformIndependantFailureReason = Util.convertToIndependantLineDelimiter(this.verifier.failureReason); if (platformIndependantFailureReason.indexOf(platformIndependantExpectedSuccessOutputString) == -1) { System.out.println(getClass().getName() + '#' + getName()); @@ -1245,6 +1247,7 @@ boolean expectingCompilerErrors, String expectedCompilerLog, String expectedOutputString, + String expectedErrorString, boolean forceExecution, String[] classLib, boolean shouldFlushOutputDirectory, @@ -1330,8 +1333,9 @@ boolean passed = this.verifier.verifyClassFiles( sourceFile, - className, + className, expectedOutputString, + expectedErrorString, this.classpaths, null, vmArguments); Index: src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java,v retrieving revision 1.11 diff -u -r1.11 ProgrammingProblemsTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 10 Mar 2008 10:14:50 -0000 1.11 +++ src/org/eclipse/jdt/core/tests/compiler/regression/ProgrammingProblemsTest.java 1 Apr 2008 11:22:42 -0000 @@ -88,6 +88,7 @@ expectingCompilerErrors, expectedCompilerLog, expectedOutputString, + "" /* expectedErrorString */, forceExecution, classLib, shouldFlushOutputDirectory, Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v retrieving revision 1.75 diff -u -r1.75 NullReferenceTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 10 Mar 2008 08:41:01 -0000 1.75 +++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 1 Apr 2008 11:22:42 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -5194,6 +5194,7 @@ false /* expectingCompilerErrors */, "" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, @@ -5725,6 +5726,7 @@ "Null pointer access: The variable t can only be null at this location\n" + "----------\n" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, @@ -5759,6 +5761,7 @@ "Potential null pointer access: The variable t may be null at this location\n" + "----------\n" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, @@ -5788,6 +5791,7 @@ false /* expectingCompilerErrors */, "" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, @@ -7238,6 +7242,7 @@ "Potential null pointer access: The variable str may be null at this location\n" + "----------\n" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, @@ -7276,6 +7281,7 @@ "Potential null pointer access: The variable str may be null at this location\n" + "----------\n" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, @@ -8760,6 +8766,7 @@ "Null pointer access: The variable o can only be null at this location\n" + "----------\n" /* expectedCompilerLog */, "" /* expectedOutputString */, + "" /* expectedErrorString */, false /* forceExecution */, null /* classLib */, true /* shouldFlushOutputDirectory */, Index: src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java,v retrieving revision 1.13 diff -u -r1.13 RuntimeTests.java --- src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java 16 Oct 2007 10:24:51 -0000 1.13 +++ src/org/eclipse/jdt/core/tests/compiler/regression/RuntimeTests.java 1 Apr 2008 11:22:43 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -44,8 +44,8 @@ // memory exhaustion - try to allocate too big an instance public void test0001_memory_exhaustion() { - this.runConformTest( - new String[] { + runTest( + new String[] { /* testFiles */ "X.java", "public class X {\n" + " public static void main(String args[]) {\n" + @@ -65,8 +65,17 @@ " storage = new long[itemsNb];\n" + " }\n" + "}\n"}, - "SUCCESS" - ); + false /* expectingCompilerErrors */, + "" /* expectedCompilerLog */, + "SUCCESS" /* expectedOutputString */, + null /* expectedErrorString - skip this because some JREs emit additional info to stderr in case of exception */, + false /* forceExecution */, + null /* classLib */, + true /* shouldFlushOutputDirectory */, + null /* vmArguments */, + null /* customOptions */, + null /* clientRequestor */, + true /* skipJavac */); } // synchronization - concurrent access to a resource with explicit and Index: src/org/eclipse/jdt/core/tests/util/TestVerifier.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java,v retrieving revision 1.22 diff -u -r1.22 TestVerifier.java --- src/org/eclipse/jdt/core/tests/util/TestVerifier.java 21 Mar 2008 16:59:39 -0000 1.22 +++ src/org/eclipse/jdt/core/tests/util/TestVerifier.java 1 Apr 2008 11:22:43 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,29 +30,46 @@ public TestVerifier(boolean reuseVM) { this.reuseVM = reuseVM; } -private boolean checkBuffers(String errorString, String outputString, String sourceFileName, String expectedSuccessOutputString) { - - if (errorString.trim().length() > 0) { - this.failureReason = - "Unexpected target error running resulting class file for " - + sourceFileName - + ":\n" - + errorString; - return false; - } - String platformIndependantOutputString = Util.convertToIndependantLineDelimiter(outputString.trim()); - if (expectedSuccessOutputString != null && !Util.convertToIndependantLineDelimiter(expectedSuccessOutputString).equals(platformIndependantOutputString)) { - System.out.println(Util.displayString(platformIndependantOutputString, 2)); - this.failureReason = - "Unexpected output running resulting class file for " - + sourceFileName - + ":\n" - + "--[START]--\n" - + outputString - + "---[END]---\n"; - return false; +private boolean checkBuffers(String outputString, String errorString, + String sourceFileName, String expectedOutputString, String expectedErrorStringStart) { + String platformIndependantString; + if (expectedOutputString != null) { + platformIndependantString = Util.convertToIndependantLineDelimiter(outputString.trim()); + if (!Util.convertToIndependantLineDelimiter(expectedOutputString).equals(platformIndependantString)) { + System.out.println(Util.displayString(platformIndependantString, 2)); + this.failureReason = + "Unexpected output running resulting class file for " + + sourceFileName + + ":\n" + + "--[START]--\n" + + outputString + + "---[END]---\n"; + return false; + } + } + if (expectedErrorStringStart != null) { + platformIndependantString = Util.convertToIndependantLineDelimiter(errorString.trim()); + if (expectedErrorStringStart.length() == 0 && platformIndependantString.length() > 0 || + !platformIndependantString.startsWith(Util.convertToIndependantLineDelimiter(expectedErrorStringStart))) { + /* + * This is an opportunistic heuristic for error strings comparison: + * - null means skip test; + * - empty means exactly empty; + * - other means starts with. + * If this became insufficient, we could envision using specific + * matchers for specific needs. + */ + System.out.println(Util.displayString(platformIndependantString, 2)); + this.failureReason = + "Unexpected error running resulting class file for " + + sourceFileName + + ":\n" + + "--[START]--\n" + + errorString + + "---[END]---\n"; + return false; + } } - return true; } @@ -557,13 +574,17 @@ * a virtual machine. */ public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths) { - return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, classpaths, null, null); + return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, "", classpaths, null, null); } /** * Verify that the class files created for the given test file can be loaded by * a virtual machine. */ public boolean verifyClassFiles(String sourceFilePath, String className, String expectedSuccessOutputString, String[] classpaths, String[] programArguments, String[] vmArguments) { + return verifyClassFiles(sourceFilePath, className, expectedSuccessOutputString, "", classpaths, programArguments, vmArguments); +} +public boolean verifyClassFiles(String sourceFilePath, String className, String expectedOutputString, + String expectedErrorStringStart, String[] classpaths, String[] programArguments, String[] vmArguments) { this.outputBuffer = new StringBuffer(); this.errorBuffer = new StringBuffer(); if (this.reuseVM && programArguments == null) { @@ -574,7 +595,7 @@ } this.failureReason = null; - return this.checkBuffers(this.errorBuffer.toString(), this.outputBuffer.toString(), sourceFilePath, expectedSuccessOutputString); + return this.checkBuffers(this.outputBuffer.toString(), this.errorBuffer.toString(), sourceFilePath, expectedOutputString, expectedErrorStringStart); } /**