mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 07:01:09 +02:00
commit
a0bcf1a256
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@
|
|||||||
# Folders
|
# Folders
|
||||||
_obj
|
_obj
|
||||||
_test
|
_test
|
||||||
|
.cover
|
||||||
|
|
||||||
# Architecture specific extensions/prefixes
|
# Architecture specific extensions/prefixes
|
||||||
*.[568vq]
|
*.[568vq]
|
||||||
|
4
Makefile
4
Makefile
@ -32,9 +32,7 @@ cover:
|
|||||||
@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
|
@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
|
||||||
go get -u golang.org/x/tools/cmd/cover; \
|
go get -u golang.org/x/tools/cmd/cover; \
|
||||||
fi
|
fi
|
||||||
godep go test $(TEST) -coverprofile=coverage.out
|
./scripts/coverage.sh --html
|
||||||
godep go tool cover -html=coverage.out
|
|
||||||
rm coverage.out
|
|
||||||
|
|
||||||
# vet runs the Go source code static analysis tool `vet` to find
|
# vet runs the Go source code static analysis tool `vet` to find
|
||||||
# any common errors.
|
# any common errors.
|
||||||
|
52
scripts/coverage.sh
Executable file
52
scripts/coverage.sh
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Generate test coverage statistics for Go packages.
|
||||||
|
#
|
||||||
|
# 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]
|
||||||
|
#
|
||||||
|
# --html Additionally create HTML report and open it in browser
|
||||||
|
# --coveralls Push coverage statistics to coveralls.io
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
workdir=.cover
|
||||||
|
profile="$workdir/cover.out"
|
||||||
|
mode=count
|
||||||
|
|
||||||
|
generate_cover_data() {
|
||||||
|
rm -rf "$workdir"
|
||||||
|
mkdir "$workdir"
|
||||||
|
|
||||||
|
for pkg in "$@"; do
|
||||||
|
f="$workdir/$(echo $pkg | tr / -).cover"
|
||||||
|
go test -covermode="$mode" -coverprofile="$f" "$pkg"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "mode: $mode" >"$profile"
|
||||||
|
grep -h -v "^mode:" "$workdir"/*.cover >>"$profile"
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ./...)
|
||||||
|
show_cover_report func
|
||||||
|
case "$1" in
|
||||||
|
"")
|
||||||
|
;;
|
||||||
|
--html)
|
||||||
|
show_cover_report html ;;
|
||||||
|
--coveralls)
|
||||||
|
push_to_coveralls ;;
|
||||||
|
*)
|
||||||
|
echo >&2 "error: invalid option: $1"; exit 1 ;;
|
||||||
|
esac
|
Loading…
x
Reference in New Issue
Block a user