Commit cfbab31f authored by Travis Wellman's avatar Travis Wellman Committed by Wouter van Oortmerssen

cleaning up JavaTest.sh - quote paths, and less error-prone deletion (#4301)

parent cb2481ef
......@@ -14,31 +14,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
echo Compile then run the Java test.
java -version
testdir=$(readlink -fn `dirname $0`)
thisdir=$(readlink -fn `pwd`)
testdir="$(readlink -fn "$(dirname "$0")")"
targetdir=${testdir}/target
targetdir="${testdir}/target"
if [[ "$testdir" != "$thisdir" ]]; then
echo error: must be run from inside the ${testdir} directory
echo you ran it from ${thisdir}
exit 1
if [[ -e "${targetdir}" ]]; then
echo "cleaning target"
rm -rf "${targetdir}"
fi
find .. -type f -name "*.class" -exec rm {} \;
mkdir -v "${targetdir}"
if [[ -e "${targetdir}" ]]; then
echo "clean target"
rm -rf ${targetdir}
if ! find "${testdir}/../java" -type f -name "*.class" -delete; then
echo "failed to clean .class files from java directory" >&2
exit 1
fi
mkdir ${targetdir}
javac -d "${targetdir}" -classpath "${testdir}/../java:${testdir}:${testdir}/namespace_test" "${testdir}/JavaTest.java"
javac -d ${targetdir} -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest.java
java -classpath ${targetdir} JavaTest
(cd "${testdir}" && java -classpath "${targetdir}" JavaTest )
rm -rf ${targetdir}
rm -rf "${targetdir}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment