Use test script from tools.git
This commit is contained in:
1 parent
d5c85a3d53
commit
958a3bbd99
3 files changed
+6
-60
No files matched your search
@@ -62,3 +62,4 @@ Vagrantfile.local
|
|||||||
test/tls/*.pem
|
test/tls/*.pem
|
||||||
test/coverage
|
test/coverage
|
||||||
test/coverage.*
|
test/coverage.*
|
||||||
|
.tools/
|
||||||
@@ -44,6 +44,9 @@ NETGO_CHECK=@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
|
|||||||
echo " sudo go install -tags netgo std"; \
|
echo " sudo go install -tags netgo std"; \
|
||||||
false; \
|
false; \
|
||||||
}
|
}
|
||||||
|
ENSURE_TOOLS=@if [ ! -d .tools ]; then \
|
||||||
|
git clone https://github.com/weaveworks/tools.git .tools/;\
|
||||||
|
fi
|
||||||
BUILD_FLAGS=-ldflags "-extldflags \"-static\" -X main.version $(WEAVE_VERSION)" -tags netgo
|
BUILD_FLAGS=-ldflags "-extldflags \"-static\" -X main.version $(WEAVE_VERSION)" -tags netgo
|
||||||
|
|
||||||
all: $(WEAVE_EXPORT) $(COVER_EXE) $(RUNNER_EXE)
|
all: $(WEAVE_EXPORT) $(COVER_EXE) $(RUNNER_EXE)
|
||||||
@@ -109,7 +112,8 @@ $(DOCKER_DISTRIB):
|
|||||||
curl -o $(DOCKER_DISTRIB) $(DOCKER_DISTRIB_URL)
|
curl -o $(DOCKER_DISTRIB) $(DOCKER_DISTRIB_URL)
|
||||||
|
|
||||||
tests: $(COVER_EXE)
|
tests: $(COVER_EXE)
|
||||||
@test/units.sh
|
$(ENSURE_TOOLS)
|
||||||
|
.tools/test
|
||||||
|
|
||||||
$(PUBLISH): publish_%: $(IMAGES_UPTODATE)
|
$(PUBLISH): publish_%: $(IMAGES_UPTODATE)
|
||||||
$(SUDO) docker tag -f $(DOCKERHUB_USER)/$* $(DOCKERHUB_USER)/$*:$(WEAVE_VERSION)
|
$(SUDO) docker tag -f $(DOCKERHUB_USER)/$* $(DOCKERHUB_USER)/$*:$(WEAVE_VERSION)
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
||||||
SLOW=${SLOW-}
|
|
||||||
GO_TEST_ARGS="-tags netgo -cpu 4 -timeout 8m"
|
|
||||||
if [ -n "$SLOW" -o "$1" = "-slow" ]; then
|
|
||||||
GO_TEST_ARGS="$GO_TEST_ARGS -race -covermode=atomic"
|
|
||||||
|
|
||||||
if [ -n "$COVERDIR" ] ; then
|
|
||||||
coverdir="$COVERDIR"
|
|
||||||
else
|
|
||||||
coverdir=$(mktemp -d coverage.XXXXXXXXXX)
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p $coverdir
|
|
||||||
fi
|
|
||||||
|
|
||||||
fail=0
|
|
||||||
|
|
||||||
TESTDIRS=$(find . -type f -name '*_test.go' | xargs -n1 dirname | grep -v prog | sort -u)
|
|
||||||
|
|
||||||
# If running on circle, use the scheduler to work out what tests to run on what shard
|
|
||||||
if [ -n "$CIRCLECI" -a -z "$NO_SCHEDULER" ]; then
|
|
||||||
TESTDIRS=$(echo $TESTDIRS | "$DIR/sched" sched units-$CIRCLE_BUILD_NUM $CIRCLE_NODE_TOTAL $CIRCLE_NODE_INDEX)
|
|
||||||
echo $TESTDIRS
|
|
||||||
fi
|
|
||||||
|
|
||||||
for dir in $TESTDIRS; do
|
|
||||||
go get -t -tags netgo $dir
|
|
||||||
|
|
||||||
GO_TEST_ARGS_RUN="$GO_TEST_ARGS"
|
|
||||||
if [ -n "$SLOW" ]; then
|
|
||||||
COVERPKGS=$((go list $dir; go list -f '{{join .Deps "\n"}}' $dir | grep "weaveworks") | paste -s -d,)
|
|
||||||
output=$(mktemp $coverdir/unit.XXXXXXXXXX)
|
|
||||||
GO_TEST_ARGS_RUN="$GO_TEST_ARGS -coverprofile=$output -coverpkg=$COVERPKGS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
START=$(date +%s)
|
|
||||||
if ! go test $GO_TEST_ARGS_RUN $dir ; then
|
|
||||||
fail=1
|
|
||||||
fi
|
|
||||||
RUNTIME=$(( $(date +%s) - $START ))
|
|
||||||
|
|
||||||
# Report test runtime when running on circle, to help scheduler
|
|
||||||
if [ -n "$CIRCLECI" -a -z "$NO_SCHEDULER" ]; then
|
|
||||||
"$DIR/sched" time $dir $RUNTIME
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -n "$SLOW" -a -z "$COVERDIR" ] ; then
|
|
||||||
$DIR/../testing/cover/cover $coverdir/* >profile.cov
|
|
||||||
rm -rf $coverdir
|
|
||||||
go tool cover -html=profile.cov -o=coverage.html
|
|
||||||
go tool cover -func=profile.cov | tail -n1
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $fail
|
|
||||||
Reference in new issue
Block a user