test/tools/apt/Scanners/scanner.sh

Thu, 25 Aug 2011 17:18:25 -0700

author
schien
date
Thu, 25 Aug 2011 17:18:25 -0700
changeset 1067
f497fac86cf9
parent 554
9d9f26857129
permissions
-rw-r--r--

Added tag jdk8-b02 for changeset b3c059de2a61

     1 #!/bin/sh
     3 #
     4 # Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
     5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6 #
     7 # This code is free software; you can redistribute it and/or modify it
     8 # under the terms of the GNU General Public License version 2 only, as
     9 # published by the Free Software Foundation.
    10 #
    11 # This code is distributed in the hope that it will be useful, but WITHOUT
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14 # version 2 for more details (a copy is included in the LICENSE file that
    15 # accompanied this code).
    16 #
    17 # You should have received a copy of the GNU General Public License version
    18 # 2 along with this work; if not, write to the Free Software Foundation,
    19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20 #
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22 # or visit www.oracle.com if you need additional information or have any
    23 # questions.
    24 #
    26 # @test
    27 # @bug 4989093 5009164 5023880 5029482 6206786
    28 # @run shell ../verifyVariables.sh
    29 # @run shell scanner.sh
    30 # @summary Test source order scanner
    31 # @author Joseph D. Darcy
    33 OS=`uname -s`;
    34 case "${OS}" in
    35         Windows* | CYGWIN* )
    36                 SEP=";"
    37         ;;
    39 	* )
    40 	SEP=":"
    41 	;;
    42 esac
    44 JARCP=scanner.jar
    46 # Construct path to apt executable
    47 APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile "
    49 printf "%s\n" "APT = ${APT}"
    51 # Construct path to javac executable
    52 JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
    53 JAR="${TESTJAVA}/bin/jar "
    55 ${JAVAC} ${TESTSRC}/Scanner.java ${TESTSRC}/VisitOrder.java ${TESTSRC}/Counter.java ${TESTSRC}/MemberOrderApf.java
    56 RESULT=$?
    58 case "${RESULT}" in
    59         0  )
    60         ;;
    62         * )
    63         echo "Compilation failed."
    64         exit 1
    65 esac
    68 echo "Making services directory and copying services information."
    69 mkdir -p META-INF/services
    71 cp ${TESTSRC}/servicesScanner META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
    73 ${JAR} cf0 scanner.jar Scanner*.class META-INF
    75 # Jar files created; verify options properly present on both initial
    76 # and recursive apt runs
    78 #---------------------------------------------------------
    80 unset CLASSPATH
    82 printf "%s\n" "-classpath ${JARCP}"     > options
    83 printf "%s\n" "-sourcepath ${TESTSRC}" >> options
    84 printf "%s\n" "${TESTSRC}/Order.java"  >> options
    86 ${APT} @options
    88 RESULT=$?
    89 case "${RESULT}" in
    90         0  )
    91 	;;	
    93 	* )
    94 	echo "Program elements visited in wrong order"
    95 	exit 1
    96         ;;
    97 esac
    99 #---------------------------------------------------------
   101 # Verify that plain decl' scanner and source order decl' scanner
   102 # record the same number of elements for an enum
   104 printf "%s\n" "-factorypath ."            > options2
   105 printf "%s\n" "-factory Counter"         >> options2
   106 printf "%s\n" "-sourcepath ${TESTSRC}"   >> options2
   107 printf "%s\n" "${TESTSRC}/TestEnum.java" >> options2
   110 $APT @options2
   112 RESULT=$?
   113 case "${RESULT}" in
   114         0  )
   115 	;;	
   117 	* )
   118 	echo "Improper counts"
   119 	exit 1
   120         ;;
   121 esac
   123 #---------------------------------------------------------
   125 # Verify that members happen to be returned in source order
   127 printf "%s\n" "-factorypath ."            > options3
   128 printf "%s\n" "-factory MemberOrderApf"  >> options3
   129 printf "%s\n" "-sourcepath ${TESTSRC}"   >> options3
   130 printf "%s\n" "${TESTSRC}/Order.java"    >> options3
   132 $APT @options3
   134 RESULT=$?
   135 case "${RESULT}" in
   136         0  )
   137 	;;	
   139 	* )
   140 	echo "Improper counts"
   141 	exit 1
   142         ;;
   143 esac
   146 exit 0;

mercurial