Files
weave-scope/bin/test
2015-07-06 15:07:33 +00:00

44 lines
930 B
Bash
Executable File

#!/bin/sh
set -eu
GO_TEST_ARGS="-cpu 4 -timeout 10s -tags netgo"
SLOW=""
if [ $# -eq 1 ] && [ "$1" = "-slow" ]; then
GO_TEST_ARGS="$GO_TEST_ARGS -race -covermode=atomic"
SLOW="yes"
fi
echo "mode: count" > profile.cov
fail=0
for dir in $(find . -type f -name '*_test.go' | grep -v '^./.git/' | grep -v '^./experimental/' | grep -v '^./releases/' | xargs -n1 dirname | sort -u); do
if [ "$SLOW" = "yes" ]; then
go get -t $dir
if ! errcheck -ignore 'Close' $dir ; then
fail=1
fi
output=$(mktemp cover.XXXXXXXXXX)
GO_TEST_ARGS_RUN="$GO_TEST_ARGS -coverprofile=$output"
else
GO_TEST_ARGS_RUN="$GO_TEST_ARGS"
fi
if ! go test $GO_TEST_ARGS_RUN $dir ; then
fail=1
fi
if [ "$SLOW" = "yes" ] && [ -f $output ]; then
tail -n +2 <$output >>profile.cov
rm $output
fi
done
if [ "$SLOW" = "yes" ]; then
go tool cover -html=profile.cov -o=coverage.html
fi
exit $fail