Skip to content

Commit

Permalink
Only call go test on packages with test files in cover.sh (#887)
Browse files Browse the repository at this point in the history
Only call go test on packages with test files in cover.sh (#887)
  • Loading branch information
bufdev committed Apr 4, 2017
1 parent 7f6095b commit 61f80e1
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions scripts/cover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@

set -e

if echo "${GOPATH}" | grep : >/dev/null; then
echo "error: GOPATH must be one directory, but has multiple directories separated by colons: ${GOPATH}" >&2
exit 1
fi

start_waitpids() {
WAITPIDS=
WAITPIDS=
}

do_waitpid() {
$@ &
WAITPIDS="${WAITPIDS} $!"
$@ &
WAITPIDS="${WAITPIDS} $!"
}

reset_waitpids() {
for waitpid in ${WAITPIDS}; do
wait "${waitpid}" || exit 1
done
WAITPIDS=
for waitpid in ${WAITPIDS}; do
wait "${waitpid}" || exit 1
done
WAITPIDS=
}

COVER=cover
Expand All @@ -41,6 +46,9 @@ done
i=0
start_waitpids
for pkg in "$@"; do
if ! ls "${GOPATH}/src/${pkg}" | grep _test\.go$ >/dev/null; then
continue
fi
i=$((i + 1))

extracoverpkg=""
Expand Down Expand Up @@ -69,7 +77,7 @@ for pkg in "$@"; do
args="-coverprofile $COVER/cover.${i}.out -coverpkg $coverpkg"
fi

do_waitpid go test -race $args "$pkg"
do_waitpid go test -race $args "$pkg"
done
reset_waitpids

Expand Down

0 comments on commit 61f80e1

Please sign in to comment.