1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/apt/Scanners/scanner.sh Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,146 @@ 1.4 +#!/bin/sh 1.5 + 1.6 +# 1.7 +# Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved. 1.8 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.9 +# 1.10 +# This code is free software; you can redistribute it and/or modify it 1.11 +# under the terms of the GNU General Public License version 2 only, as 1.12 +# published by the Free Software Foundation. 1.13 +# 1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 +# version 2 for more details (a copy is included in the LICENSE file that 1.18 +# accompanied this code). 1.19 +# 1.20 +# You should have received a copy of the GNU General Public License version 1.21 +# 2 along with this work; if not, write to the Free Software Foundation, 1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 +# 1.24 +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 +# CA 95054 USA or visit www.sun.com if you need additional information or 1.26 +# have any questions. 1.27 +# 1.28 + 1.29 +# @test 1.30 +# @bug 4989093 5009164 5023880 5029482 6206786 1.31 +# @run shell ../verifyVariables.sh 1.32 +# @run shell scanner.sh 1.33 +# @summary Test source order scanner 1.34 +# @author Joseph D. Darcy 1.35 + 1.36 +OS=`uname -s`; 1.37 +case "${OS}" in 1.38 + Windows* | CYGWIN* ) 1.39 + SEP=";" 1.40 + ;; 1.41 + 1.42 + * ) 1.43 + SEP=":" 1.44 + ;; 1.45 +esac 1.46 + 1.47 +JARCP=scanner.jar 1.48 + 1.49 +# Construct path to apt executable 1.50 +APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -nocompile " 1.51 + 1.52 +printf "%s\n" "APT = ${APT}" 1.53 + 1.54 +# Construct path to javac executable 1.55 +JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . " 1.56 +JAR="${TESTJAVA}/bin/jar " 1.57 + 1.58 +${JAVAC} ${TESTSRC}/Scanner.java ${TESTSRC}/VisitOrder.java ${TESTSRC}/Counter.java ${TESTSRC}/MemberOrderApf.java 1.59 +RESULT=$? 1.60 + 1.61 +case "${RESULT}" in 1.62 + 0 ) 1.63 + ;; 1.64 + 1.65 + * ) 1.66 + echo "Compilation failed." 1.67 + exit 1 1.68 +esac 1.69 + 1.70 + 1.71 +echo "Making services directory and copying services information." 1.72 +mkdir -p META-INF/services 1.73 + 1.74 +cp ${TESTSRC}/servicesScanner META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory 1.75 + 1.76 +${JAR} cf0 scanner.jar Scanner*.class META-INF 1.77 + 1.78 +# Jar files created; verify options properly present on both initial 1.79 +# and recursive apt runs 1.80 + 1.81 +#--------------------------------------------------------- 1.82 + 1.83 +unset CLASSPATH 1.84 + 1.85 +printf "%s\n" "-classpath ${JARCP}" > options 1.86 +printf "%s\n" "-sourcepath ${TESTSRC}" >> options 1.87 +printf "%s\n" "${TESTSRC}/Order.java" >> options 1.88 + 1.89 +${APT} @options 1.90 + 1.91 +RESULT=$? 1.92 +case "${RESULT}" in 1.93 + 0 ) 1.94 + ;; 1.95 + 1.96 + * ) 1.97 + echo "Program elements visited in wrong order" 1.98 + exit 1 1.99 + ;; 1.100 +esac 1.101 + 1.102 +#--------------------------------------------------------- 1.103 + 1.104 +# Verify that plain decl' scanner and source order decl' scanner 1.105 +# record the same number of elements for an enum 1.106 + 1.107 +printf "%s\n" "-factorypath ." > options2 1.108 +printf "%s\n" "-factory Counter" >> options2 1.109 +printf "%s\n" "-sourcepath ${TESTSRC}" >> options2 1.110 +printf "%s\n" "${TESTSRC}/TestEnum.java" >> options2 1.111 + 1.112 + 1.113 +$APT @options2 1.114 + 1.115 +RESULT=$? 1.116 +case "${RESULT}" in 1.117 + 0 ) 1.118 + ;; 1.119 + 1.120 + * ) 1.121 + echo "Improper counts" 1.122 + exit 1 1.123 + ;; 1.124 +esac 1.125 + 1.126 +#--------------------------------------------------------- 1.127 + 1.128 +# Verify that members happen to be returned in source order 1.129 + 1.130 +printf "%s\n" "-factorypath ." > options3 1.131 +printf "%s\n" "-factory MemberOrderApf" >> options3 1.132 +printf "%s\n" "-sourcepath ${TESTSRC}" >> options3 1.133 +printf "%s\n" "${TESTSRC}/Order.java" >> options3 1.134 + 1.135 +$APT @options3 1.136 + 1.137 +RESULT=$? 1.138 +case "${RESULT}" in 1.139 + 0 ) 1.140 + ;; 1.141 + 1.142 + * ) 1.143 + echo "Improper counts" 1.144 + exit 1 1.145 + ;; 1.146 +esac 1.147 + 1.148 + 1.149 +exit 0;