Skip to content

Commit

Permalink
Revert "Make no-go-get the default, and don't assume -tags netgo"
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwilkie committed Jan 16, 2017
1 parent e75c226 commit 8c3883a
Showing 1 changed file with 11 additions and 39 deletions.
50 changes: 11 additions & 39 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
set -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GO_TEST_ARGS=(-tags netgo -cpu 4 -timeout 8m)
SLOW=
NO_GO_GET=true
TAGS=
PARALLEL=
NO_GO_GET=

usage() {
echo "$0 [-slow] [-in-container foo] [-netgo] [-(no-)go-get]"
echo "$0 [-slow] [-in-container foo]"
}

while [ $# -gt 0 ]; do
Expand All @@ -22,27 +21,13 @@ while [ $# -gt 0 ]; do
NO_GO_GET=true
shift 1
;;
"-go-get")
NO_GO_GET=
shift 1
;;
"-netgo")
TAGS="-tags netgo"
shift 1
;;
"-p")
PARALLEL=true
shift 1
;;
*)
usage
exit 2
;;
esac
done

GO_TEST_ARGS=($TAGS -cpu 4 -timeout 8m)

if [ -n "$SLOW" ] || [ -n "$CIRCLECI" ]; then
SLOW=true
fi
Expand Down Expand Up @@ -84,46 +69,33 @@ PACKAGE_BASE=$(go list -e ./)
# Speed up the tests by compiling and installing their dependencies first.
go test -i "${GO_TEST_ARGS[@]}" "${TESTDIRS[@]}"

run_test() {
local dir=$1
for dir in "${TESTDIRS[@]}"; do
if [ -z "$NO_GO_GET" ]; then
go get -t $TAGS "$dir"
go get -t -tags netgo "$dir"
fi

local GO_TEST_ARGS_RUN=("${GO_TEST_ARGS[@]}")
GO_TEST_ARGS_RUN=("${GO_TEST_ARGS[@]}")
if [ -n "$SLOW" ]; then
local COVERPKGS=$( (
COVERPKGS=$( (
go list "$dir"
go list -f '{{join .Deps "\n"}}' "$dir" | grep -v "vendor" | grep "^$PACKAGE_BASE/"
) | paste -s -d, -)
local output=$(mktemp "$coverdir/unit.XXXXXXXXXX")
local GO_TEST_ARGS_RUN=("${GO_TEST_ARGS[@]}" -coverprofile=$output -coverpkg=$COVERPKGS)
output=$(mktemp "$coverdir/unit.XXXXXXXXXX")
GO_TEST_ARGS_RUN=("${GO_TEST_ARGS[@]}" -coverprofile=$output -coverpkg=$COVERPKGS)
fi

local START=$(date +%s)
START=$(date +%s)
if ! go test "${GO_TEST_ARGS_RUN[@]}" "$dir"; then
fail=1
fi
local RUNTIME=$(($(date +%s) - START))
RUNTIME=$(($(date +%s) - START))

# Report test runtime when running on circle, to help scheduler
if [ -n "$CIRCLECI" ] && [ -z "$NO_SCHEDULER" ] && [ -x "$DIR/sched" ]; then
"$DIR/sched" time "$dir" "$RUNTIME"
fi
}

for dir in "${TESTDIRS[@]}"; do
if [ -n "$PARALLEL" ]; then
run_test "$dir" &
else
run_test "$dir"
fi
done

if [ -n "$PARALLEL" ]; then
wait
fi

if [ -n "$SLOW" ] && [ -z "$COVERDIR" ]; then
go get github.com/weaveworks/tools/cover
cover "$coverdir"/* >profile.cov
Expand Down

0 comments on commit 8c3883a

Please sign in to comment.