6802102: unignore @ignored tests where possible

Thu, 28 May 2009 09:49:56 -0700

author
jjg
date
Thu, 28 May 2009 09:49:56 -0700
changeset 290
d4828eba4939
parent 289
84061bd68019
child 291
47cf04bb80c9

6802102: unignore @ignored tests where possible
Reviewed-by: mcimadamore

test/tools/javac/T6405099.java file | annotate | diff | comparison | revisions
test/tools/javac/api/6431257/T6431257.java file | annotate | diff | comparison | revisions
test/tools/javac/api/TestJavacTaskScanner.java file | annotate | diff | comparison | revisions
test/tools/javac/code/ArrayClone.java file | annotate | diff | comparison | revisions
test/tools/javac/code/ArrayClone.sh file | annotate | diff | comparison | revisions
test/tools/javac/generics/inference/6365166/NewTest.java file | annotate | diff | comparison | revisions
     1.1 --- a/test/tools/javac/T6405099.java	Wed May 27 22:34:43 2009 -0700
     1.2 +++ b/test/tools/javac/T6405099.java	Thu May 28 09:49:56 2009 -0700
     1.3 @@ -25,20 +25,39 @@
     1.4   * @test
     1.5   * @bug 6405099
     1.6   * @summary Compiler crashes when javac encounters /usr/jdk/packges/lib/ext with no 777 permissions
     1.7 - *
     1.8 - * @ignore causes NPE in Java Test
     1.9 - * @run main T6405099
    1.10 - * @compile -extdirs bad T6405099.java
    1.11   */
    1.12  
    1.13 -import java.io.File;
    1.14 +import java.io.*;
    1.15  
    1.16  public class T6405099
    1.17  {
    1.18      public static void main(String[] args) {
    1.19          File bad = new File("bad");
    1.20 -        bad.mkdir();
    1.21 -        bad.setReadable(false);
    1.22 -        bad.setExecutable(false);
    1.23 +        try {
    1.24 +            bad.mkdir();
    1.25 +            bad.setReadable(false);
    1.26 +            bad.setExecutable(false);
    1.27 +
    1.28 +            test(bad);
    1.29 +
    1.30 +        } finally {
    1.31 +            bad.setExecutable(true);
    1.32 +            bad.setReadable(true);
    1.33 +        }
    1.34 +    }
    1.35 +
    1.36 +    static void test(File dir) {
    1.37 +        String[] args = {
    1.38 +            "-extdirs", dir.getPath(), "-d", ".",
    1.39 +            new File(System.getProperty("test.src", "."), "T6405099.java").getPath()
    1.40 +        };
    1.41 +
    1.42 +        StringWriter sw = new StringWriter();
    1.43 +        PrintWriter pw = new PrintWriter(sw);
    1.44 +        int rc = com.sun.tools.javac.Main.compile(args, pw);
    1.45 +        if (rc != 0)
    1.46 +            throw new Error("compilation failed");
    1.47 +
    1.48 +        System.out.println(sw);
    1.49      }
    1.50  }
     2.1 --- a/test/tools/javac/api/6431257/T6431257.java	Wed May 27 22:34:43 2009 -0700
     2.2 +++ b/test/tools/javac/api/6431257/T6431257.java	Thu May 28 09:49:56 2009 -0700
     2.3 @@ -27,7 +27,6 @@
     2.4   * @summary JSR 199: Changes to JavaFileManager to support JSR 269 Filer API
     2.5   * @author  Peter von der Ah\u00e9
     2.6   * @library ../lib
     2.7 - * @ignore  Need to fix this test when 6508981 is fixed.
     2.8   * @compile T6431257.java package-info.java
     2.9   * @run main T6431257 foo.bar.baz foo/bar/baz
    2.10   */
     3.1 --- a/test/tools/javac/api/TestJavacTaskScanner.java	Wed May 27 22:34:43 2009 -0700
     3.2 +++ b/test/tools/javac/api/TestJavacTaskScanner.java	Thu May 28 09:49:56 2009 -0700
     3.3 @@ -26,7 +26,7 @@
     3.4   * @bug     4813736
     3.5   * @summary Additional functionality test of task and JSR 269
     3.6   * @author  Peter von der Ah\u00e9
     3.7 - * @ignore "misuse" of context breaks with 6358786
     3.8 + * @library ./lib
     3.9   * @run main TestJavacTaskScanner TestJavacTaskScanner.java
    3.10   */
    3.11  
    3.12 @@ -42,16 +42,23 @@
    3.13  import javax.lang.model.util.Elements;
    3.14  import javax.lang.model.util.Types;
    3.15  import javax.tools.*;
    3.16 -import javax.tools.JavaFileManager;
    3.17  
    3.18 -public class TestJavacTaskScanner implements Runnable {
    3.19 +public class TestJavacTaskScanner extends ToolTester {
    3.20  
    3.21      final JavacTaskImpl task;
    3.22      final Elements elements;
    3.23      final Types types;
    3.24  
    3.25 -    TestJavacTaskScanner(JavacTaskImpl task) {
    3.26 -        this.task = task;
    3.27 +    int numTokens;
    3.28 +    int numParseTypeElements;
    3.29 +    int numAllMembers;
    3.30 +
    3.31 +    TestJavacTaskScanner(File file) {
    3.32 +        final Iterable<? extends JavaFileObject> compilationUnits =
    3.33 +            fm.getJavaFileObjects(new File[] {file});
    3.34 +        task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, compilationUnits);
    3.35 +        task.getContext().put(Scanner.Factory.scannerFactoryKey,
    3.36 +                new MyScanner.Factory(task.getContext(), this));
    3.37          elements = task.getElements();
    3.38          types = task.getTypes();
    3.39      }
    3.40 @@ -71,6 +78,23 @@
    3.41              System.out.println();
    3.42              System.out.println();
    3.43          }
    3.44 +
    3.45 +        System.out.println("#tokens: " + numTokens);
    3.46 +        System.out.println("#parseTypeElements: " + numParseTypeElements);
    3.47 +        System.out.println("#allMembers: " + numAllMembers);
    3.48 +
    3.49 +        check(numTokens, "#Tokens", 891);
    3.50 +        check(numParseTypeElements, "#parseTypeElements", 136);
    3.51 +        check(numAllMembers, "#allMembers", 67);
    3.52 +    }
    3.53 +
    3.54 +    void check(int value, String name, int expected) {
    3.55 +        // allow some slop in the comparison to allow for minor edits in the
    3.56 +        // test and in the platform
    3.57 +        if (value < expected * 9 / 10)
    3.58 +            throw new Error(name + " lower than expected; expected " + expected + "; found: " + value);
    3.59 +        if (value > expected * 11 / 10)
    3.60 +            throw new Error(name + " higher than expected; expected " + expected + "; found: " + value);
    3.61      }
    3.62  
    3.63      void testParseType(TypeElement clazz) {
    3.64 @@ -78,23 +102,19 @@
    3.65          for (Element member : elements.getAllMembers((TypeElement)type.asElement())) {
    3.66              TypeMirror mt = types.asMemberOf(type, member);
    3.67              System.out.format("%s : %s -> %s%n", member.getSimpleName(), member.asType(), mt);
    3.68 +            numParseTypeElements++;
    3.69          }
    3.70      }
    3.71  
    3.72      public static void main(String... args) throws IOException {
    3.73 -        JavaCompilerTool tool = ToolProvider.defaultJavaCompiler();
    3.74 -        JavaFileManager fm = tool.getStandardFileManager();
    3.75          String srcdir = System.getProperty("test.src");
    3.76 -        File file = new File(srcdir, args[0]);
    3.77 -        JavacTaskImpl task = (JavacTaskImpl)tool.run(null, fm.getFileForInput(file.toString()));
    3.78 -        MyScanner.Factory.preRegister(task.getContext());
    3.79 -        TestJavacTaskScanner tester = new TestJavacTaskScanner(task);
    3.80 -        tester.run();
    3.81 +        new TestJavacTaskScanner(new File(srcdir, args[0])).run();
    3.82      }
    3.83  
    3.84      private void testGetAllMembers(TypeElement clazz) {
    3.85          for (Element member : elements.getAllMembers(clazz)) {
    3.86 -            System.out.format("%s : %s", member.getSimpleName(), member.asType());
    3.87 +            System.out.format("%s : %s%n", member.getSimpleName(), member.asType());
    3.88 +            numAllMembers++;
    3.89          }
    3.90      }
    3.91  }
    3.92 @@ -102,21 +122,15 @@
    3.93  class MyScanner extends Scanner {
    3.94  
    3.95      public static class Factory extends Scanner.Factory {
    3.96 -        public static void preRegister(final Context context) {
    3.97 -            context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() {
    3.98 -                public Factory make() {
    3.99 -                    return new Factory(context);
   3.100 -                }
   3.101 -            });
   3.102 -        }
   3.103 -        public Factory(Context context) {
   3.104 +        public Factory(Context context, TestJavacTaskScanner test) {
   3.105              super(context);
   3.106 +            this.test = test;
   3.107          }
   3.108  
   3.109          @Override
   3.110          public Scanner newScanner(CharSequence input) {
   3.111              if (input instanceof CharBuffer) {
   3.112 -                return new MyScanner(this, (CharBuffer)input);
   3.113 +                return new MyScanner(this, (CharBuffer)input, test);
   3.114              } else {
   3.115                  char[] array = input.toString().toCharArray();
   3.116                  return newScanner(array, array.length);
   3.117 @@ -125,18 +139,26 @@
   3.118  
   3.119          @Override
   3.120          public Scanner newScanner(char[] input, int inputLength) {
   3.121 -            return new MyScanner(this, input, inputLength);
   3.122 +            return new MyScanner(this, input, inputLength, test);
   3.123          }
   3.124 +
   3.125 +        private TestJavacTaskScanner test;
   3.126      }
   3.127 -    protected MyScanner(Factory fac, CharBuffer buffer) {
   3.128 +    protected MyScanner(Factory fac, CharBuffer buffer, TestJavacTaskScanner test) {
   3.129          super(fac, buffer);
   3.130 +        this.test = test;
   3.131      }
   3.132 -    protected MyScanner(Factory fac, char[] input, int inputLength) {
   3.133 +    protected MyScanner(Factory fac, char[] input, int inputLength, TestJavacTaskScanner test) {
   3.134          super(fac, input, inputLength);
   3.135 +        this.test = test;
   3.136      }
   3.137  
   3.138      public void nextToken() {
   3.139          super.nextToken();
   3.140          System.err.format("Saw token %s (%s)%n", token(), name());
   3.141 +        test.numTokens++;
   3.142      }
   3.143 +
   3.144 +    private TestJavacTaskScanner test;
   3.145 +
   3.146  }
     4.1 --- a/test/tools/javac/code/ArrayClone.java	Wed May 27 22:34:43 2009 -0700
     4.2 +++ b/test/tools/javac/code/ArrayClone.java	Thu May 28 09:49:56 2009 -0700
     4.3 @@ -25,15 +25,38 @@
     4.4   * @test
     4.5   * @bug 4329886
     4.6   * @summary Clone() on arrays compiled incorrectly
     4.7 - * @author gafter
     4.8 - *
     4.9 - * @ignore Waiting for javap bug 4650860 to be fixed.
    4.10 - *
    4.11 - * @run shell ArrayClone.sh
    4.12 + * @author gafter jjg
    4.13   */
    4.14  
    4.15 +import java.io.*;
    4.16 +
    4.17  /** The qualifying type in the code for array.clone() should be the array type. */
    4.18 -class ArrayClone {
    4.19 +public class ArrayClone {
    4.20 +    public static void main(String[] args) {
    4.21 +        new ArrayClone().run();
    4.22 +    }
    4.23 +
    4.24 +    public void run() {
    4.25 +        String[] args = { "-classpath", System.getProperty("test.classes", "."), "-v", "Test" };
    4.26 +        StringWriter sw = new StringWriter();
    4.27 +        PrintWriter pw = new PrintWriter(sw);
    4.28 +        int rc = com.sun.tools.javap.Main.run(args, pw);
    4.29 +        if (rc != 0)
    4.30 +            throw new Error("javap failed; exit " + rc);
    4.31 +
    4.32 +        String out = sw.toString();
    4.33 +        System.out.println(out);
    4.34 +
    4.35 +        for (String line: out.split("\n")) {
    4.36 +            String match = "[ \t]+[0-9]+:[ \t]+invokevirtual[ \t]+#[0-9]+; //Method \"\\[Ljava/lang/String;\".clone:\\(\\)Ljava/lang/Object;";
    4.37 +            if (line.matches(match))
    4.38 +                return;
    4.39 +        }
    4.40 +        throw new Error("expected string not found in javap output");
    4.41 +    }
    4.42 +}
    4.43 +
    4.44 +class Test {
    4.45      public static void main(String[] args) {
    4.46          args.clone();
    4.47      }
     5.1 --- a/test/tools/javac/code/ArrayClone.sh	Wed May 27 22:34:43 2009 -0700
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,86 +0,0 @@
     5.4 -#!/bin/sh
     5.5 -
     5.6 -#
     5.7 -# Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
     5.8 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.9 -#
    5.10 -# This code is free software; you can redistribute it and/or modify it
    5.11 -# under the terms of the GNU General Public License version 2 only, as
    5.12 -# published by the Free Software Foundation.
    5.13 -#
    5.14 -# This code is distributed in the hope that it will be useful, but WITHOUT
    5.15 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.16 -# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.17 -# version 2 for more details (a copy is included in the LICENSE file that
    5.18 -# accompanied this code).
    5.19 -#
    5.20 -# You should have received a copy of the GNU General Public License version
    5.21 -# 2 along with this work; if not, write to the Free Software Foundation,
    5.22 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.23 -#
    5.24 -# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    5.25 -# CA 95054 USA or visit www.sun.com if you need additional information or
    5.26 -# have any questions.
    5.27 -#
    5.28 -
    5.29 -
    5.30 -if [ "${TESTSRC}" = "" ]
    5.31 -then
    5.32 -  echo "TESTSRC not set.  Test cannot execute.  Failed."
    5.33 -  exit 1
    5.34 -fi
    5.35 -echo "TESTSRC=${TESTSRC}"
    5.36 -if [ "${TESTJAVA}" = "" ]
    5.37 -then
    5.38 -  echo "TESTJAVA not set.  Test cannot execute.  Failed."
    5.39 -  exit 1
    5.40 -fi
    5.41 -echo "TESTJAVA=${TESTJAVA}"
    5.42 -if [ "${TESTCLASSES}" = "" ]
    5.43 -then
    5.44 -  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
    5.45 -  exit 1
    5.46 -fi
    5.47 -echo "TESTCLASSES=${TESTCLASSES}"
    5.48 -echo "CLASSPATH=${CLASSPATH}"
    5.49 -
    5.50 -# set platform-dependent variables
    5.51 -OS=`uname -s`
    5.52 -case "$OS" in
    5.53 -  SunOS | Linux )
    5.54 -    NULL=/dev/null
    5.55 -    PS=":"
    5.56 -    FS="/"
    5.57 -    ;;
    5.58 -  Windows_95 | Windows_98 | Windows_NT )
    5.59 -    NULL=NUL
    5.60 -    PS=";"
    5.61 -    FS="\\"
    5.62 -    ;;
    5.63 -  * )
    5.64 -    echo "Unrecognized system!"
    5.65 -    exit 1;
    5.66 -    ;;
    5.67 -esac
    5.68 -
    5.69 -TMP1=OUTPUT.txt
    5.70 -
    5.71 -cp "${TESTSRC}${FS}ArrayClone.java" .
    5.72 -"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -target 1.5 ArrayClone.java
    5.73 -result=$?
    5.74 -if [ $result -ne 0 ]
    5.75 -then
    5.76 -    exit $result
    5.77 -fi
    5.78 -
    5.79 -"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -c ArrayClone > ${TMP1}
    5.80 -grep WHAT_SHOULD_WE_LOOK_FOR ${TMP1}
    5.81 -result=$?
    5.82 -
    5.83 -if [ $result -eq 0 ]
    5.84 -then
    5.85 -  echo "Passed"
    5.86 -else
    5.87 -  echo "Failed"
    5.88 -fi
    5.89 -exit $result
     6.1 --- a/test/tools/javac/generics/inference/6365166/NewTest.java	Wed May 27 22:34:43 2009 -0700
     6.2 +++ b/test/tools/javac/generics/inference/6365166/NewTest.java	Thu May 28 09:49:56 2009 -0700
     6.3 @@ -25,7 +25,6 @@
     6.4   * @test
     6.5   * @bug     6365166
     6.6   * @summary javac (generic) unable to resolve methods
     6.7 - * @ignore  waiting for 6365166
     6.8   * @compile NewTest.java
     6.9   */
    6.10  

mercurial