From: Chris Jaekl Date: Tue, 28 Nov 2017 13:19:04 +0000 (+0900) Subject: Add support for pegging the JVM version when checking code coverage. X-Git-Url: https://jaekl.net/gitweb/?a=commitdiff_plain;ds=sidebyside;p=cfb.git Add support for pegging the JVM version when checking code coverage. 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. --- diff --git a/cov.sh b/cov.sh index e442016..3162f01 100755 --- 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" +JAVA=${JAVA_HOME}/bin/java +JAVAC=${JAVA_HOME}/bin/javac . ${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" @@ -44,7 +46,7 @@ done ##################### 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... @@ -59,15 +61,15 @@ do 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 -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... -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