support Count Lines of Code report.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-07-20 22:49:59 +08:00
parent 8a0772849a
commit 511d8b8700
2 changed files with 21 additions and 1 deletions

View File

@ -98,7 +98,10 @@ lint_report:
vet_report: vet_report:
sh ./script/coverage.sh vet sh ./script/coverage.sh vet
report: junit_report coverage_report lint_report vet_report cloc_report:
sh ./script/coverage.sh cloc
report: junit_report coverage_report lint_report vet_report cloc_report
clean: clean:
-rm -rf build.tar.gz \ -rm -rf build.tar.gz \

View File

@ -22,6 +22,7 @@ junit_report="$workdir/junit.txt"
junit_xml_report="$workdir/report.xml" junit_xml_report="$workdir/report.xml"
lint_report="$workdir/lint.txt" lint_report="$workdir/lint.txt"
vet_report="$workdir/vet.txt" vet_report="$workdir/vet.txt"
cloc_report="$workdir/cloc.xml"
packages=$(go list ./... | grep -v vendor) packages=$(go list ./... | grep -v vendor)
test -d $workdir || mkdir -p $workdir test -d $workdir || mkdir -p $workdir
@ -35,6 +36,7 @@ Generate test coverage statistics for Go packages.
junit Generate coverage xml report for junit plugin junit Generate coverage xml report for junit plugin
lint Generate Lint report for all packages lint Generate Lint report for all packages
vet Generate Vet report for all packages vet Generate Vet report for all packages
cloc Generate Count Lines of Code report for all files
EOF EOF
} }
@ -75,6 +77,19 @@ generate_vet_report() {
done done
} }
generate_cloc_report() {
case "$OSTYPE" in
darwin*)
which cloc || brew install cloc ;;
linux*)
which cloc || apt-get install cloc ;;
*)
output "unknown: $OSTYPE" 1 ;;
esac
cloc --by-file --xml --out=${cloc_report} --exclude-dir=vendor,Godeps .
}
case "$1" in case "$1" in
"") "")
show_help ;; show_help ;;
@ -90,6 +105,8 @@ case "$1" in
generate_lint_report ;; generate_lint_report ;;
vet) vet)
generate_vet_report ;; generate_vet_report ;;
cloc)
generate_cloc_report ;;
*) *)
show_help ;; show_help ;;
esac esac