2016-06-30 05:41:26 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
output() {
|
|
|
|
printf "\033[32m"
|
|
|
|
echo $1
|
|
|
|
printf "\033[0m"
|
2016-07-10 08:16:06 +00:00
|
|
|
exit 1
|
2016-06-30 05:41:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
coverage_mode=$1
|
|
|
|
|
|
|
|
test -z $coverage_mode && output "Usage: $0 coverage_mode"
|
2016-07-10 08:16:06 +00:00
|
|
|
test -z $(which glide) && output "glide command not found"
|
2016-06-30 05:41:26 +00:00
|
|
|
|
|
|
|
test -f coverage.txt && rm -rf coverage.txt
|
|
|
|
echo "mode: ${coverage_mode}" > coverage.txt
|
|
|
|
|
2016-07-13 06:26:10 +00:00
|
|
|
for d in $(go list ./... | grep -v vendor); do
|
2016-06-30 05:41:26 +00:00
|
|
|
go test -v -cover -coverprofile=profile.out -covermode=${coverage_mode} $d
|
|
|
|
if [ -f profile.out ]; then
|
|
|
|
sed '1d' profile.out >> coverage.txt
|
|
|
|
rm profile.out
|
|
|
|
fi
|
|
|
|
done
|