]> jaekl.net Git - cfb.git/commitdiff
Add support for pegging the JVM version when checking code coverage. master
authorChris Jaekl <cejaekl@yahoo.com>
Tue, 28 Nov 2017 13:19:04 +0000 (22:19 +0900)
committerChris Jaekl <cejaekl@yahoo.com>
Tue, 28 Nov 2017 13:19:04 +0000 (22:19 +0900)
It seems that jcov has trouble with Java 9, and has been failing since I upgraded the
system default JVM to Java 9.  This change consults JAVA_HOME for the JVM path, so that
Jenkins can override it and have a successful build.

cov.sh

diff --git a/cov.sh b/cov.sh
index e442016c4d6157434ce450ea3c833123570e40f7..3162f0165693b8262eeced743521a85e5a7cc67f 100755 (executable)
--- a/cov.sh
+++ b/cov.sh
@@ -5,13 +5,15 @@ set -o errexit   ## (set -e) error exit if subcommand returns nonzero
 
 CFB_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 INSTR_DIR="${CFB_ROOT}/../instr"
 
 CFB_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 INSTR_DIR="${CFB_ROOT}/../instr"
+JAVA=${JAVA_HOME}/bin/java
+JAVAC=${JAVA_HOME}/bin/javac
 
 . ${CFB_ROOT}/setcp.sh
 
 #####################
 echo Compiling...
 
 . ${CFB_ROOT}/setcp.sh
 
 #####################
 echo Compiling...
-find "${CFB_ROOT}/prod" -name "*.java" | xargs javac -g -Xlint:deprecation
-find "${CFB_ROOT}/test" -name "*.java" | xargs javac -g -classpath ${CFB_ROOT}/prod:${CLASSPATH} -Xlint:deprecation
+find "${CFB_ROOT}/prod" -name "*.java" | xargs ${JAVAC} -g -Xlint:deprecation
+find "${CFB_ROOT}/test" -name "*.java" | xargs ${JAVAC} -g -classpath ${CFB_ROOT}/prod:${CLASSPATH} -Xlint:deprecation
 
 if [ -d "${CFB_ROOT}/bin" ]; then
     rm -rf "${CFB_ROOT}/bin"
 
 if [ -d "${CFB_ROOT}/bin" ]; then
     rm -rf "${CFB_ROOT}/bin"
@@ -44,7 +46,7 @@ done
 
 #####################
 echo Instrumenting...
 
 #####################
 echo Instrumenting...
-java -classpath "${CLASSPATH}" -jar `pwd`/jcov/jcov.jar Instr -t template.xml -o "${INSTR_DIR}" -type all "${CFB_ROOT}/prod"
+${JAVA} -classpath "${CLASSPATH}" -jar `pwd`/jcov/jcov.jar Instr -t template.xml -o "${INSTR_DIR}" -type all "${CFB_ROOT}/prod"
 
 #####################
 echo Running unit tests...
 
 #####################
 echo Running unit tests...
@@ -59,15 +61,15 @@ do
 done
 
 echo First run:  locale es_ES, timezone Europe/Madrid
 done
 
 echo First run:  locale es_ES, timezone Europe/Madrid
-java -Duser.language=es -Duser.country=ES -Duser.timezone=Europe/Madrid -Djcov.template=${CFB_ROOT}/template.xml -Djcov.file=${CFB_ROOT}/result.xml -classpath "${INSTR_DIR}:${CFB_ROOT}/test:${CLASSPATH}:/usr/share/java/junit.jar:${CFB_ROOT}/jcov/jcov_file_saver.jar" org.junit.runner.JUnitCore ${TESTS}
+${JAVA} -Duser.language=es -Duser.country=ES -Duser.timezone=Europe/Madrid -Djcov.template=${CFB_ROOT}/template.xml -Djcov.file=${CFB_ROOT}/result.xml -classpath "${INSTR_DIR}:${CFB_ROOT}/test:${CLASSPATH}:/usr/share/java/junit.jar:${CFB_ROOT}/jcov/jcov_file_saver.jar" org.junit.runner.JUnitCore ${TESTS}
 
 echo Second run:  server default locale and timezone
 
 echo Second run:  server default locale and timezone
-java -Djcov.template=${CFB_ROOT}/template.xml -Djcov.file=${CFB_ROOT}/result.xml -classpath "${INSTR_DIR}:${CFB_ROOT}/test:${CLASSPATH}:/usr/share/java/junit.jar:${CFB_ROOT}/jcov/jcov_file_saver.jar" org.junit.runner.JUnitCore ${TESTS}
+${JAVA} -Djcov.template=${CFB_ROOT}/template.xml -Djcov.file=${CFB_ROOT}/result.xml -classpath "${INSTR_DIR}:${CFB_ROOT}/test:${CLASSPATH}:/usr/share/java/junit.jar:${CFB_ROOT}/jcov/jcov_file_saver.jar" org.junit.runner.JUnitCore ${TESTS}
 
 #####################
 echo Generating HTML Report...
 
 
 #####################
 echo Generating HTML Report...
 
-java -jar "${CFB_ROOT}/jcov/jcov.jar" RepGen -sourcepath "${CFB_ROOT}/prod" -log.level FINE result.xml
+${JAVA} -jar "${CFB_ROOT}/jcov/jcov.jar" RepGen -sourcepath "${CFB_ROOT}/prod" -log.level FINE result.xml
 
 #####################
 echo Cleaning up
 
 #####################
 echo Cleaning up