cleaning up JavaTest.sh - quote paths, and less error-prone deletion (#4301)
This commit is contained in:
parent
cb2481efdc
commit
cfbab31fb1
|
@ -14,31 +14,30 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
echo Compile then run the Java test.
|
echo Compile then run the Java test.
|
||||||
|
|
||||||
java -version
|
java -version
|
||||||
|
|
||||||
testdir=$(readlink -fn `dirname $0`)
|
testdir="$(readlink -fn "$(dirname "$0")")"
|
||||||
thisdir=$(readlink -fn `pwd`)
|
|
||||||
|
|
||||||
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
|
|
||||||
fi
|
|
||||||
|
|
||||||
find .. -type f -name "*.class" -exec rm {} \;
|
|
||||||
|
|
||||||
if [[ -e "${targetdir}" ]]; then
|
if [[ -e "${targetdir}" ]]; then
|
||||||
echo "clean target"
|
echo "cleaning target"
|
||||||
rm -rf ${targetdir}
|
rm -rf "${targetdir}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir ${targetdir}
|
mkdir -v "${targetdir}"
|
||||||
|
|
||||||
javac -d ${targetdir} -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest.java
|
if ! find "${testdir}/../java" -type f -name "*.class" -delete; then
|
||||||
java -classpath ${targetdir} JavaTest
|
echo "failed to clean .class files from java directory" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf ${targetdir}
|
javac -d "${targetdir}" -classpath "${testdir}/../java:${testdir}:${testdir}/namespace_test" "${testdir}/JavaTest.java"
|
||||||
|
|
||||||
|
(cd "${testdir}" && java -classpath "${targetdir}" JavaTest )
|
||||||
|
|
||||||
|
rm -rf "${targetdir}"
|
||||||
|
|
Loading…
Reference in New Issue