Skip to content

Commit

Permalink
Issue checkstyle#3843: Add check for missing classes in Cobertura cov…
Browse files Browse the repository at this point in the history
…erage report
  • Loading branch information
MEZk committed Feb 24, 2017
1 parent f4223fd commit d31d25d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions .ci/travis/travis.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
# Attention, there is no "-x" to avoid problems on Travis
set -e
set -o pipefail

case $1 in

Expand Down Expand Up @@ -171,6 +172,23 @@ no-exception-test-alot-of-project1)
groovy ./launch.groovy --listOfProjects projects-for-travis.properties --config checks-nonjavadoc-error.xml
;;

cobertura-check)
mvn clean compile cobertura:cobertura
xmlstarlet sel -t -m "//class" -v "@name" -n target/site/cobertura/coverage.xml | sed 's/\./\//g' | sort | uniq > cobertura_classes.log
find target/classes -type f -name "*.class" | grep -vE ".*\\$.*" | sed 's/target\/classes\///g' | sed "s/.class//" | sort | uniq > target_classes.log
xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -m "//pom:instrumentation/pom:excludes" -v "pom:exclude" pom.xml | sed 's/\.class//g' | sed 's/\*//g' | sort | uniq > cobertura_excluded_classes.log
grep -Fxv -f cobertura_classes.log target_classes.log > missed_classes_with_excludes.log
grep -Fv -f cobertura_excluded_classes.log missed_classes_with_excludes.log > missed_classes_without_excludes.log
if [[ -s missed_classes_without_excludes.log ]] ; then
echo "Classes which are missed in Cobertura coverage report:"
cat missed_classes_without_excludes.log
exit 1
else
echo "All classes are present in Cobertura coverage report."
exit 0
fi
;;

*)
echo "Unexpected argument: $1"
exit 1
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ matrix:
- jdk: oraclejdk8
env:
- DESC="cobertura and codecov"
- CMD="mvn clean compile cobertura:check cobertura:cobertura"
- CMD="./.ci/travis/travis.sh cobertura-check"
- CMD_AFTER_SUCCESS="bash <(curl -s https://codecov.io/bash)"
# findbugs and pmd (oraclejdk8)
- jdk: oraclejdk8
Expand Down Expand Up @@ -159,6 +159,7 @@ matrix:

script:
- set -e
- set -o pipefail
- SKIP_FILES=".github|appveyor.yml|circle.yml|distelli-manifest.yml|fast-forward-merge.sh|LICENSE|LICENSE.apache20|README.md|release.sh|RIGHTS.antlr|shippable.yml|wercker.yml"
- SKIP_CI=$(if [[ $(git diff --name-only HEAD HEAD~1 | grep -vE "$SKIP_FILES" | cat | wc -c) > 0 ]]; then echo false; else echo true; fi;)
- echo "SKIP_CI="$SKIP_CI
Expand Down

0 comments on commit d31d25d

Please sign in to comment.