6802102: unignore @ignored tests where possible

Reviewed-by: mcimadamore
This commit is contained in:
Jonathan Gibbons 2009-05-28 09:49:56 -07:00
parent 05ea258bbb
commit 6fb18b568c
6 changed files with 103 additions and 127 deletions

View File

@ -25,20 +25,39 @@
* @test
* @bug 6405099
* @summary Compiler crashes when javac encounters /usr/jdk/packges/lib/ext with no 777 permissions
*
* @ignore causes NPE in Java Test
* @run main T6405099
* @compile -extdirs bad T6405099.java
*/
import java.io.File;
import java.io.*;
public class T6405099
{
public static void main(String[] args) {
File bad = new File("bad");
bad.mkdir();
bad.setReadable(false);
bad.setExecutable(false);
try {
bad.mkdir();
bad.setReadable(false);
bad.setExecutable(false);
test(bad);
} finally {
bad.setExecutable(true);
bad.setReadable(true);
}
}
static void test(File dir) {
String[] args = {
"-extdirs", dir.getPath(), "-d", ".",
new File(System.getProperty("test.src", "."), "T6405099.java").getPath()
};
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javac.Main.compile(args, pw);
if (rc != 0)
throw new Error("compilation failed");
System.out.println(sw);
}
}

View File

@ -27,7 +27,6 @@
* @summary JSR 199: Changes to JavaFileManager to support JSR 269 Filer API
* @author Peter von der Ah\u00e9
* @library ../lib
* @ignore Need to fix this test when 6508981 is fixed.
* @compile T6431257.java package-info.java
* @run main T6431257 foo.bar.baz foo/bar/baz
*/

View File

@ -26,7 +26,7 @@
* @bug 4813736
* @summary Additional functionality test of task and JSR 269
* @author Peter von der Ah\u00e9
* @ignore "misuse" of context breaks with 6358786
* @library ./lib
* @run main TestJavacTaskScanner TestJavacTaskScanner.java
*/
@ -42,16 +42,23 @@ import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import javax.tools.*;
import javax.tools.JavaFileManager;
public class TestJavacTaskScanner implements Runnable {
public class TestJavacTaskScanner extends ToolTester {
final JavacTaskImpl task;
final Elements elements;
final Types types;
TestJavacTaskScanner(JavacTaskImpl task) {
this.task = task;
int numTokens;
int numParseTypeElements;
int numAllMembers;
TestJavacTaskScanner(File file) {
final Iterable<? extends JavaFileObject> compilationUnits =
fm.getJavaFileObjects(new File[] {file});
task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, compilationUnits);
task.getContext().put(Scanner.Factory.scannerFactoryKey,
new MyScanner.Factory(task.getContext(), this));
elements = task.getElements();
types = task.getTypes();
}
@ -71,6 +78,23 @@ public class TestJavacTaskScanner implements Runnable {
System.out.println();
System.out.println();
}
System.out.println("#tokens: " + numTokens);
System.out.println("#parseTypeElements: " + numParseTypeElements);
System.out.println("#allMembers: " + numAllMembers);
check(numTokens, "#Tokens", 891);
check(numParseTypeElements, "#parseTypeElements", 136);
check(numAllMembers, "#allMembers", 67);
}
void check(int value, String name, int expected) {
// allow some slop in the comparison to allow for minor edits in the
// test and in the platform
if (value < expected * 9 / 10)
throw new Error(name + " lower than expected; expected " + expected + "; found: " + value);
if (value > expected * 11 / 10)
throw new Error(name + " higher than expected; expected " + expected + "; found: " + value);
}
void testParseType(TypeElement clazz) {
@ -78,23 +102,19 @@ public class TestJavacTaskScanner implements Runnable {
for (Element member : elements.getAllMembers((TypeElement)type.asElement())) {
TypeMirror mt = types.asMemberOf(type, member);
System.out.format("%s : %s -> %s%n", member.getSimpleName(), member.asType(), mt);
numParseTypeElements++;
}
}
public static void main(String... args) throws IOException {
JavaCompilerTool tool = ToolProvider.defaultJavaCompiler();
JavaFileManager fm = tool.getStandardFileManager();
String srcdir = System.getProperty("test.src");
File file = new File(srcdir, args[0]);
JavacTaskImpl task = (JavacTaskImpl)tool.run(null, fm.getFileForInput(file.toString()));
MyScanner.Factory.preRegister(task.getContext());
TestJavacTaskScanner tester = new TestJavacTaskScanner(task);
tester.run();
new TestJavacTaskScanner(new File(srcdir, args[0])).run();
}
private void testGetAllMembers(TypeElement clazz) {
for (Element member : elements.getAllMembers(clazz)) {
System.out.format("%s : %s", member.getSimpleName(), member.asType());
System.out.format("%s : %s%n", member.getSimpleName(), member.asType());
numAllMembers++;
}
}
}
@ -102,21 +122,15 @@ public class TestJavacTaskScanner implements Runnable {
class MyScanner extends Scanner {
public static class Factory extends Scanner.Factory {
public static void preRegister(final Context context) {
context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() {
public Factory make() {
return new Factory(context);
}
});
}
public Factory(Context context) {
public Factory(Context context, TestJavacTaskScanner test) {
super(context);
this.test = test;
}
@Override
public Scanner newScanner(CharSequence input) {
if (input instanceof CharBuffer) {
return new MyScanner(this, (CharBuffer)input);
return new MyScanner(this, (CharBuffer)input, test);
} else {
char[] array = input.toString().toCharArray();
return newScanner(array, array.length);
@ -125,18 +139,26 @@ class MyScanner extends Scanner {
@Override
public Scanner newScanner(char[] input, int inputLength) {
return new MyScanner(this, input, inputLength);
return new MyScanner(this, input, inputLength, test);
}
private TestJavacTaskScanner test;
}
protected MyScanner(Factory fac, CharBuffer buffer) {
protected MyScanner(Factory fac, CharBuffer buffer, TestJavacTaskScanner test) {
super(fac, buffer);
this.test = test;
}
protected MyScanner(Factory fac, char[] input, int inputLength) {
protected MyScanner(Factory fac, char[] input, int inputLength, TestJavacTaskScanner test) {
super(fac, input, inputLength);
this.test = test;
}
public void nextToken() {
super.nextToken();
System.err.format("Saw token %s (%s)%n", token(), name());
test.numTokens++;
}
private TestJavacTaskScanner test;
}

View File

@ -25,15 +25,38 @@
* @test
* @bug 4329886
* @summary Clone() on arrays compiled incorrectly
* @author gafter
*
* @ignore Waiting for javap bug 4650860 to be fixed.
*
* @run shell ArrayClone.sh
* @author gafter jjg
*/
import java.io.*;
/** The qualifying type in the code for array.clone() should be the array type. */
class ArrayClone {
public class ArrayClone {
public static void main(String[] args) {
new ArrayClone().run();
}
public void run() {
String[] args = { "-classpath", System.getProperty("test.classes", "."), "-v", "Test" };
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
int rc = com.sun.tools.javap.Main.run(args, pw);
if (rc != 0)
throw new Error("javap failed; exit " + rc);
String out = sw.toString();
System.out.println(out);
for (String line: out.split("\n")) {
String match = "[ \t]+[0-9]+:[ \t]+invokevirtual[ \t]+#[0-9]+; //Method \"\\[Ljava/lang/String;\".clone:\\(\\)Ljava/lang/Object;";
if (line.matches(match))
return;
}
throw new Error("expected string not found in javap output");
}
}
class Test {
public static void main(String[] args) {
args.clone();
}

View File

@ -1,86 +0,0 @@
#!/bin/sh
#
# Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
if [ "${TESTSRC}" = "" ]
then
echo "TESTSRC not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTSRC=${TESTSRC}"
if [ "${TESTJAVA}" = "" ]
then
echo "TESTJAVA not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTJAVA=${TESTJAVA}"
if [ "${TESTCLASSES}" = "" ]
then
echo "TESTCLASSES not set. Test cannot execute. Failed."
exit 1
fi
echo "TESTCLASSES=${TESTCLASSES}"
echo "CLASSPATH=${CLASSPATH}"
# set platform-dependent variables
OS=`uname -s`
case "$OS" in
SunOS | Linux )
NULL=/dev/null
PS=":"
FS="/"
;;
Windows_95 | Windows_98 | Windows_NT )
NULL=NUL
PS=";"
FS="\\"
;;
* )
echo "Unrecognized system!"
exit 1;
;;
esac
TMP1=OUTPUT.txt
cp "${TESTSRC}${FS}ArrayClone.java" .
"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -target 1.5 ArrayClone.java
result=$?
if [ $result -ne 0 ]
then
exit $result
fi
"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -c ArrayClone > ${TMP1}
grep WHAT_SHOULD_WE_LOOK_FOR ${TMP1}
result=$?
if [ $result -eq 0 ]
then
echo "Passed"
else
echo "Failed"
fi
exit $result

View File

@ -25,7 +25,6 @@
* @test
* @bug 6365166
* @summary javac (generic) unable to resolve methods
* @ignore waiting for 6365166
* @compile NewTest.java
*/