diff --git a/.gitignore b/.gitignore index 40548e3753d..ed0ab91e19f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # Folders _obj _test +.cover/ # Architecture specific extensions/prefixes *.[568vq] diff --git a/.travis.yml b/.travis.yml index 68c0c6c1c0e..83a53341b9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ install: - glide install script: - - ./validate.sh --nofmt + - ./validate.sh --nofmt --cov diff --git a/scripts/check_coverage.sh b/scripts/check_coverage.sh index a45c991b609..4dd795a062b 100755 --- a/scripts/check_coverage.sh +++ b/scripts/check_coverage.sh @@ -6,10 +6,6 @@ CHECKCOV=false #cleanup finish() { - cat scripts/results.tmp - if [ -e "scripts/results.tmp" ]; then - rm scripts/results.tmp - fi if [ -d ".cover" ]; then rm -rf .cover @@ -19,16 +15,16 @@ finish() { trap finish EXIT ERR INT TERM #start script logic -./scripts/coverage.sh > scripts/results.tmp +OUTPUT=`./scripts/coverage.sh` while read -r LINE; do if [[ $LINE =~ "%" ]]; then - PERCENT=$(echo "$LINE"|cut -d: -f2- |cut -d% -f1| cut -d. -f1|tr -d ' ') + PERCENT=$(echo "$LINE"|cut -d: -f2-|cut -d% -f1|cut -d. -f1|tr -d ' ') if [[ $PERCENT -lt 20 ]]; then CHECKCOV=true fi fi -done < scripts/results.tmp +done < "$OUTPUT" if $CHECKCOV; then echo "Detected at least one package had less than 20% code coverage. Please review results below or from your terminal run ./scripts/coverage.sh --html for more detailed results" diff --git a/scripts/coverage.sh b/scripts/coverage.sh index 18d02d21318..38df9e77538 100755 --- a/scripts/coverage.sh +++ b/scripts/coverage.sh @@ -4,10 +4,9 @@ # Works around the fact that `go test -coverprofile` currently does not work # with multiple packages, see https://code.google.com/p/go/issues/detail?id=6909 # -# Usage: script/coverage [--html|--coveralls] +# Usage: script/coverage.sh [--html] # # --html Additionally create HTML report and open it in browser -# --coveralls Push coverage statistics to coveralls.io # set -e @@ -33,11 +32,6 @@ show_cover_report() { go tool cover -${1}="$profile" } -push_to_coveralls() { - echo "Pushing coverage statistics to coveralls.io" - goveralls -coverprofile="$profile" -} - generate_cover_data $(go list ./... | grep -v /vendor/) #show_cover_report func case "$1" in @@ -45,8 +39,6 @@ case "$1" in ;; --html) show_cover_report html ;; ---coveralls) - push_to_coveralls ;; *) echo >&2 "error: invalid option: $1"; exit 1 ;; esac diff --git a/validate.sh b/validate.sh index 6527d475fbb..49ba96786b1 100755 --- a/validate.sh +++ b/validate.sh @@ -3,10 +3,12 @@ set -e AUTOFMT=true +COVERAGE=false while true; do case "$1" in --nofmt ) AUTOFMT=false; shift ;; + --cov ) COVERAGE=true; shift ;; * ) break ;; esac done @@ -29,5 +31,8 @@ else test $GOFMT_LINES -eq 0 || die "gofmt needs to be run, ${GOFMT_LINES} files have issues. Below is a list of files to review:\n`gofmt -l *.go pbs adapters`" fi -#go test $(go list ./... | grep -v /vendor/) -./scripts/check_coverage.sh \ No newline at end of file +if $COVERAGE; then + ./scripts/check_coverage.sh +else + go test $(go list ./... | grep -v /vendor/) +fi \ No newline at end of file