Thu, 27 Aug 2009 17:50:21 -0700
6876755: apt tests fail on Windows
Reviewed-by: darcy
1 #!/bin/sh
3 #
4 # Copyright 2004-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 # CA 95054 USA or visit www.sun.com if you need additional information or
23 # have any questions.
24 #
26 # @test
27 # @bug 4908512 5024825 4957203 4993280 4996963 6174696 6177059
28 # @run shell ../verifyVariables.sh
29 # @build Milk MethodAnnotations NestedClassAnnotations StaticFieldAnnotations StaticMethodAnnotations ParameterAnnotations
30 # @run shell apt.sh
31 # @summary test consistency of annotation discovery
32 # @author Joseph D. Darcy
34 OS=`uname -s`;
35 case "${OS}" in
36 CYGWIN* )
37 DIFFOPTS="--strip-trailing-cr"
38 ;;
40 * )
41 ;;
42 esac
44 # Construct path to apt executable
45 APT="${TESTJAVA}/bin/apt ${TESTTOOLVMOPTS} -XDsuppress-tool-api-removal-message "
47 printf "%s\n" "-classpath ${TESTCLASSES}" > options
48 printf "%s\n" "-factorypath ./nullap.jar" >> options
49 printf "%s\n" "-sourcepath ${TESTSRC} " >> options
50 printf "%s\n" "-nocompile" >> options
51 printf "%s\n" "-XListAnnotationTypes" >> options
53 printf "%s\n" "-classpath ${TESTCLASSES}" > options1
54 printf "%s\n" "-factorypath ./nullap.jar" >> options1
55 printf "%s\n" "-sourcepath ${TESTSRC} " >> options1
56 printf "%s\n" "-nocompile" >> options1
57 printf "%s\n" "-XListAnnotationTypes" >> options1
58 printf "%s\n" "-XclassesAsDecls" >> options1
61 # Construct path to javac executable
62 JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
63 JAR="${TESTJAVA}/bin/jar "
65 $JAVAC ${TESTSRC}/NullAPF.java \
66 ${TESTSRC}/FreshnessApf.java \
67 ${TESTSRC}/TestGetTypeDeclarationApf.java \
68 ${TESTSRC}/TestGetPackageApf.java
69 RESULT=$?
71 case "${RESULT}" in
72 0 )
73 ;;
75 * )
76 echo "Compilation failed."
77 exit 1
78 esac
80 echo "Making services directory and copying services information."
81 mkdir -p META-INF/services
82 cp ${TESTSRC}/com.sun.mirror.apt.AnnotationProcessorFactory ./META-INF/services
83 $JAR cvf0 nullap.jar NullAPF*.class META-INF
85 ANNOTATION_FILES="${TESTSRC}/ClassAnnotations.java \
86 ${TESTSRC}/MethodAnnotations.java \
87 ${TESTSRC}/NestedClassAnnotations.java \
88 ${TESTSRC}/StaticFieldAnnotations.java \
89 ${TESTSRC}/StaticMethodAnnotations.java \
90 ${TESTSRC}/ParameterAnnotations.java"
92 for i in ${ANNOTATION_FILES}
93 do
94 printf "%s\n" "Testing annotations on source file ${i}"
95 ${APT} @options ${i} 2> result.txt
96 diff ${DIFFOPTS} ${TESTSRC}/golden.txt result.txt
98 RESULT=$?
99 case "$RESULT" in
100 0 )
101 ;;
103 * )
104 echo "Unexpected set of annotations on source files found."
105 exit 1
106 esac
108 CLASS=`basename ${i} .java`
109 printf "%s\n" "Testing annotations on class file ${CLASS}"
110 ${APT} @options1 ${CLASS} 2> result2.txt
111 diff ${DIFFOPTS} ${TESTSRC}/golden.txt result2.txt
113 RESULT=$?
114 case "$RESULT" in
115 0 )
116 ;;
118 * )
119 echo "Unexpected set of annotations on class files found."
120 exit 1
121 esac
122 done
124 # Verify source files are favored over class files
126 printf "%s\n" "-factorypath ." > options2
127 printf "%s\n" "-factory FreshnessApf" >> options2
128 printf "%s\n" "-sourcepath ${TESTSRC}" >> options2
129 printf "%s\n" "-classpath ${TESTCLASSES}" >> options2
130 printf "%s\n" "-nocompile" >> options2
132 ${APT} @options2 ${TESTSRC}/Indirect.java
134 RESULT=$?
135 case "$RESULT" in
136 0 )
137 ;;
139 * )
140 exit 1
141 esac
143 # Verify new classes can be loaded by getTypeDeclaration
145 printf "%s\n" "-factorypath ." > options3
146 printf "%s\n" "-factory TestGetTypeDeclarationApf" >> options3
147 printf "%s\n" "-sourcepath ${TESTSRC}" >> options3
149 # ${APT} @options3
151 RESULT=$?
152 case "$RESULT" in
153 0 )
154 ;;
156 * )
157 exit 1
158 esac
160 # Verify packages can be loaded by getPackage
162 printf "%s\n" "-factorypath ." > options4
163 printf "%s\n" "-factory TestGetPackageApf" >> options4
164 printf "%s\n" "-sourcepath ${TESTSRC}" >> options4
166 ${APT} @options4
168 RESULT=$?
169 case "$RESULT" in
170 0 )
171 ;;
173 * )
174 exit 1
175 esac
176 exit 0