Skip to content

Commit

Permalink
Add the ability to multiple test iterations without rebuilding.
Browse files Browse the repository at this point in the history
Address comments.
  • Loading branch information
brendandburns committed Aug 28, 2014
1 parent dcf9f30 commit 9fce47a
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions hack/test-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,54 @@ KUBE_TIMEOUT=${KUBE_TIMEOUT:--timeout 30s}

cd "${KUBE_TARGET}"

if [ "$1" != "" ]; then
go test -race $KUBE_TIMEOUT $KUBE_COVER -coverprofile=tmp.out "$KUBE_GO_PACKAGE/$1" "${@:2}"
while getopts "i:" opt ; do
case $opt in
i)
iterations=$OPTARG
;;
?)
echo "Invalid argument -$OPTARG"
exit 1
;;
:)
echo "Option -$OPTARG <value>"
exit 1
;;
esac
done
shift $((OPTIND - 1))

if [[ -n "${iterations}" ]]; then
echo "Running ${iterations} times"
if [[ -n "$1" ]]; then
pkg=$KUBE_GO_PACKAGE/$1
fi
rm -f *.test
# build a test binary
echo "${pkg}"
go test -c -race ${KUBE_TIMEOUT} "${pkg}"
# keep going, even if there are failures
pass=0
count=0
for i in $(seq 1 ${iterations}); do
for test_binary in *.test; do
if "./${test_binary}"; then
((pass++))
fi
((count++))
done
done 2>&1
echo "${pass}" / "${count}" passing
if [[ ${pass} != ${count} ]]; then
exit 1
else
exit 0
fi
fi

if [[ -n "$1" ]]; then
go test -race ${KUBE_TIMEOUT} ${KUBE_COVER} -coverprofile=tmp.out "${KUBE_GO_PACKAGE}/$1" "${@:2}"
exit 0
fi

find_test_dirs | xargs go test -race -timeout 30s $KUBE_COVER "${@:2}"
find_test_dirs | xargs go test -race -timeout 30s ${KUBE_COVER} "${@:2}"

0 comments on commit 9fce47a

Please sign in to comment.