8000 Speed up tests with go test -i by tomwilkie · Pull Request #799 · weaveworks/scope · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Speed up tests with go test -i #799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ $(RUNSVINIT): vendor/runsvinit/*.go
$(SCOPE_EXE): $(shell find ./ -path ./vendor -prune -o -type f -name *.go) prog/static.go

ifeq ($(BUILD_IN_CONTAINER),true)
$(SCOPE_EXE) $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE)
@mkdir -p $(shell pwd)/.pkg
$(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd):/go/src/github.com/weaveworks/scope -e GOARCH -e GOOS \
-v $(shell pwd)/.pkg:/go/pkg \
$(SCOPE_BACKEND_BUILD_IMAGE) SCOPE_VERSION=$(SCOPE_VERSION) GO_BUILD_INSTALL_DEPS=$(GO_BUILD_INSTALL_DEPS) $@

shell:
$(SCOPE_EXE) $(RUNSVINIT) tests shell: $(SCOPE_BACKEND_BUILD_UPTODATE)
@mkdir -p $(shell pwd)/.pkg
$(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd):/go/src/github.com/weaveworks/scope -e GOARCH -e GOOS \
$(SUDO) docker run $(RM) $(RUN_FLAGS) \
-v $(shell pwd):/go/src/github.com/weaveworks/scope \
-v $(shell pwd)/.pkg:/go/pkg \
-e GOARCH -e GOOS -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL \
-e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW \
$(SCOPE_BACKEND_BUILD_IMAGE) SCOPE_VERSION=$(SCOPE_VERSION) GO_BUILD_INSTALL_DEPS=$(GO_BUILD_INSTALL_DEPS) $@

else

$(SCOPE_EXE): $(SCOPE_BACKEND_BUILD_UPTODATE)
time go build $(GO_BUILD_FLAGS) -o $@ ./$(@D)
@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
Expand All @@ -69,6 +69,10 @@ $(RUNSVINIT):

shell:
/bin/bash

tests:
./tools/test -no-go-get

endif

static: prog/static.go
Expand Down Expand Up @@ -116,16 +120,6 @@ clean:
rm -rf $(SCOPE_EXPORT) $(SCOPE_UI_BUILD_UPTODATE) $(SCOPE_BACKEND_BUILD_UPTODATE) \
$(SCOPE_EXE) $(RUNSVINIT) prog/static.go client/build/app.js docker/weave .pkg

ifeq ($(BUILD_IN_CONTAINER),true)
tests: $(SCOPE_BACKEND_BUILD_UPTODATE)
$(SUDO) docker run $(RM) $(RUN_FLAGS) -v $(shell pwd):/go/src/github.com/weaveworks/scope \
-e GOARCH -e GOOS -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL -e CIRCLE_NODE_INDEX -e COVERDIR\
$(SCOPE_BACKEND_BUILD_IMAGE) tests
else
tests:
./tools/test -no-go-get
endif

deps:
go get -u -f -tags netgo \
github.com/golang/lint/golint \
Expand Down
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM golang:1.5.2
ENV GO15VENDOREXPERIMENT 1
RUN apt-get update && apt-get install -y libpcap-dev python-requests time
RUN go clean -i net && go install -tags netgo std
RUN go clean -i net && go install -tags netgo std && go install -race -tags netgo std
COPY build.sh /
ENTRYPOINT ["/build.sh"]
3 changes: 3 additions & 0 deletions tools/test
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ fi

PACKAGE_BASE=$(go list -e ./)

# Speed up the tests by compiling and installing their dependancies first.
go test -i $GO_TEST_ARGS $TESTDIRS

for dir in $TESTDIRS; do
if [ -z "$NO_GO_GET" ]; then
go get -t -tags netgo $dir
Expand Down
0