Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
743 B
3
Indexable
Never
if [ "$GRADLE_PROJECT" == "true" ]; then
  total_missed=0
  total_covered=0
  shopt -s globstar nullglob
  for xml in "$WORK_DIR"/**/build/reports/jacoco/test/jacocoTestReport.xml; do
    if [ -f "$xml" ]; then
      missed=$(grep '<counter type="INSTRUCTION"' "$xml" | sed -n 's/.*missed="\([0-9]*\)".*/\1/p')
      covered=$(grep '<counter type="INSTRUCTION"' "$xml" | sed -n 's/.*covered="\([0-9]*\)".*/\1/p')
      total_missed=$((total_missed + missed))
      total_covered=$((total_covered + covered))
    fi
  done
  total=$((total_missed + total_covered))
  if [ $total -gt 0 ]; then
    coverage_percent=$((100 * total_covered / total))
    echo "Total coverage: ${coverage_percent}%"
  else
    echo "No coverage data found."
  fi
fi
Leave a Comment