compile.sh revision 330
#
# Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# 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.
#
# @test
# @bug 5033855 4990902 5023880 5043516 5048534 5048535 5041279 5048539 5067261 5068145 5023881 4996963 5095716 6191667 6433634
# @run shell ../verifyVariables.sh
# @build ErrorAPF
# @build WarnAPF
# @build StaticApf
# @build ClassDeclApf
# @build ClassDeclApf2
# @build Rounds
# @build Round1Apf Round2Apf Round3Apf Round4Apf
# @build WrappedStaticApf
# @run shell compile.sh
# @summary Test simple usages of apt, including delegating to javac
# @author Joseph D. Darcy
# If the file *does* exist, exit with an error
if [ -f ${1} ]; then
printf "%s\n" "File ${1} found."
exit 1
fi
}
# If the file does not exist, exit with an error
if [ ! -f ${1} ]; then
printf "%s\n" "File ${1} not found."
exit 1
fi
}
case "${OS}" in
SEP=";"
;;
* )
SEP=":"
;;
esac
unset CLASSPATH
# ---------------------------------------------------------------
echo "Verify that source 1.6 is not supported
rm -f HelloWorld.class
printf "%s\n" "-source 1.6" > options0
${APT} @options0
RESULT=$?
0 )
exit 1
;;
esac
# ---------------------------------------------------------------
RESULT=$?
0 )
echo "FAILED: accepted target 1.6"
exit 1
;;
esac
# ---------------------------------------------------------------
echo "Testing javac pass-through with -A in options file"
RESULT=$?
0 )
;;
* )
echo "FAILED: javac with -A in options file did not compile"
exit 1
esac
# ---------------------------------------------------------------
echo "Verifying reporting an error will prevent compilation"
if [ ! -f HelloWorld.java ]; then
fi
RESULT=$?
0 )
;;
* )
echo "FAILED: did not record expected error messages"
exit 1
esac
# ---------------------------------------------------------------
echo "Verifying reporting a warning *won't* prevent compilation"
if [ ! -f HelloAnnotation.java ]; then
fi
RESULT=$?
0 )
;;
* )
echo "FAILED: did not record expected warning messages"
exit 1
esac
# ---------------------------------------------------------------
echo "Verifying static state is available across apt rounds; -factory, -cp"
# printf "%s\n" "-XPrintAptRounds" >> options4
# ---------------------------------------------------------------
echo "Verifying static state is available across apt rounds; -factory, -factorypath"
# printf "%s\n" "-XPrintAptRounds" >> options5
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Create jar file for StaticApf
# ---------------------------------------------------------------
echo "Verifying static state is available across apt rounds; -cp"
# ---------------------------------------------------------------
echo "Verifying static state is available across apt rounds; -factorypath"
# ---------------------------------------------------------------
echo "Verifying -XclassesAsDecls handles class files properly"
${JAVAC} -d ./tmp/classes ${TESTSRC}/src/Round1Class.java ${TESTSRC}/src/AhOneClass.java ${TESTSRC}/src/AndAhTwoClass.java
RESULT=$?
0 )
;;
* )
echo "FAILED: javac failed to succesfully compile."
exit 1
esac
# ---------------------------------------------------------------
echo "Verifying -XclassesAsDecls works with command-line arguments"
RESULT=$?
0 )
;;
* )
echo "FAILED: javac failed to succesfully compile."
exit 1
esac
RESULT=$?
0 )
;;
* )
echo "FAILED: apt exited with an error code."
exit 1
esac
TestFile "./class/AhOne.class"
# ---------------------------------------------------------------
echo "Verifying -XclassesAsDecls works with all source files"
RESULT=$?
0 )
;;
* )
echo "FAILED: javac failed to succesfully compile."
exit 1
esac
RESULT=$?
0 )
;;
* )
echo "FAILED: apt exited with an error code."
exit 1
esac
TestFile "./class/AhOne.class"
# ---------------------------------------------------------------
echo "Verifying -XclassesAsDecls works with mixed class and source files"
RESULT=$?
0 )
;;
* )
echo "FAILED: javac failed to succesfully compile."
exit 1
esac
RESULT=$?
0 )
;;
* )
echo "FAILED: apt exited with an error code."
exit 1
esac
TestFile "./class/AhOne.class"
# ---------------------------------------------------------------
echo "Testing productive factories are called on subsequent rounds"
# cleanup file to prevent accidental discovery in current directory
printf "%s\n" "-factorypath round1Apf.jar${SEP}round2Apf.jar${SEP}round3Apf.jar${SEP}round4Apf.jar" > options8
#printf "%s\n" "-XPrintFactoryInfo" >> options8
#printf "%s\n" "-XPrintAptRounds" >> options8
RESULT=$?
0 )
;;
* )
echo "FAILED: unexpected factory state"
exit 1
esac
# ---------------------------------------------------------------
echo "Verifying static state with programmatic apt entry; no factory options"
${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -s ./src -d ./class -XPrintAptRounds
echo "Verifying static state with programmatic apt entry; -factory"
${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factory ErrorAPF -s ./src -d ./class -XPrintAptRounds
echo "Verifying static state with programmatic apt entry; -factorypath"
${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factorypath round1Apf.jar -s ./src -d ./class -XPrintAptRounds
echo "Verifying static state with programmatic apt entry; -factory and -factorypath"
${JAVA} -cp ${TESTJAVA}/lib/tools.jar${SEP}${TESTCLASSES} WrappedStaticApf -factorypath round1Apf.jar -factory Round1Apf -s ./src -d ./class -XPrintAptRounds
exit 0