From 5e7bfd046125ba485f112b6ebb1a2bd8991612e8 Mon Sep 17 00:00:00 2001 From: Romain Gilles Date: Mon, 29 Aug 2016 11:26:31 +0200 Subject: [PATCH 1/4] Isolate the complied Java classes into a target folder + log java version. It is a common practice to put all the compiled classes into a dedicated folder in order to: - avoid to mix the code and the complied classes - to allow a simple way to remove the complied classes Add log of java version in order to make it explicit to the end user. --- tests/JavaTest.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/JavaTest.sh b/tests/JavaTest.sh index 344bd1c0b..5d4285259 100755 --- a/tests/JavaTest.sh +++ b/tests/JavaTest.sh @@ -16,14 +16,25 @@ echo Compile then run the Java test. +java -version + testdir=$(readlink -fn `dirname $0`) thisdir=$(readlink -fn `pwd`) +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 -javac -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest.java -java -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest +if [ -e "${targetdir}" ]; then + echo "clean target" + rm -fr ${targetdir} +fi + +mkdir ${targetdir} + +javac -d ${targetdir} -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest.java +java -classpath ${targetdir} JavaTest From 3bb9b839b8aa5f8476126c9be067ae883f065099 Mon Sep 17 00:00:00 2001 From: Romain Gilles Date: Tue, 30 Aug 2016 10:18:47 +0200 Subject: [PATCH 2/4] Add remove of remaining class files before running the build --- tests/JavaTest.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/JavaTest.sh b/tests/JavaTest.sh index 5d4285259..679d5d315 100755 --- a/tests/JavaTest.sh +++ b/tests/JavaTest.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright 2014 Google Inc. All rights reserved. # @@ -29,7 +29,10 @@ if [[ "$testdir" != "$thisdir" ]]; then exit 1 fi -if [ -e "${targetdir}" ]; then +find ../ -name "*.class" | xargs rm +#find .. -type f -name "*.class" -exec rm {} \; + +if [[ -e "${targetdir}" ]]; then echo "clean target" rm -fr ${targetdir} fi From afd230af8ddc555b3baf399f293d8af67ea767e8 Mon Sep 17 00:00:00 2001 From: Romain Gilles Date: Thu, 1 Sep 2016 13:01:07 +0200 Subject: [PATCH 3/4] Remove commented line. Add a last step that remove the target folder after the build and the tests execution. --- tests/JavaTest.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/JavaTest.sh b/tests/JavaTest.sh index 679d5d315..ef261a756 100755 --- a/tests/JavaTest.sh +++ b/tests/JavaTest.sh @@ -30,14 +30,15 @@ if [[ "$testdir" != "$thisdir" ]]; then fi find ../ -name "*.class" | xargs rm -#find .. -type f -name "*.class" -exec rm {} \; if [[ -e "${targetdir}" ]]; then echo "clean target" - rm -fr ${targetdir} + rm -rf ${targetdir} fi mkdir ${targetdir} javac -d ${targetdir} -classpath ${testdir}/../java:${testdir}:${testdir}/namespace_test JavaTest.java java -classpath ${targetdir} JavaTest + +rm -rf ${targetdir} From 582fd90c4a351d167c98fc6d7d23ed9b6ed0c89f Mon Sep 17 00:00:00 2001 From: Romain Gilles Date: Tue, 6 Sep 2016 23:28:22 +0200 Subject: [PATCH 4/4] Use the find -exec instead of find ... | xargs otherwise when there is error log in the output of the build. --- tests/JavaTest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/JavaTest.sh b/tests/JavaTest.sh index ef261a756..40e854b50 100755 --- a/tests/JavaTest.sh +++ b/tests/JavaTest.sh @@ -29,7 +29,7 @@ if [[ "$testdir" != "$thisdir" ]]; then exit 1 fi -find ../ -name "*.class" | xargs rm +find .. -type f -name "*.class" -exec rm {} \; if [[ -e "${targetdir}" ]]; then echo "clean target"