5 MIN_COVERAGE_PERCENT="$2"
6 LOG_FILE=target/check-coverage.log
8 function coverage_from_report() {
9 local xpath_expr="string(/report/counter[@type='INSTRUCTION']/@$1)"
10 xpath -q -e "$xpath_expr" "$JACOCO_REPORT" 2>> ${LOG_FILE}
13 missed=$(coverage_from_report missed)
14 covered=$(coverage_from_report covered)
15 total=$(($missed + $covered))
16 coverage=$((100 * $covered / $total))
18 if [[ $(wc -c < ${LOG_FILE}) > 0 ]]; then
19 echo "Warnings from xpath evaluation:"
24 echo "Coverage: $coverage% (covered/total: $covered/$total)"
26 if [[ ${coverage} -lt ${MIN_COVERAGE_PERCENT} ]]; then
27 echo "Coverage is too low. Minimum coverage: $MIN_COVERAGE_PERCENT%"