Skip to content

Commit ede9f82

Browse files
authored
Merge pull request #60 from moshe010/fix_make
make: improve Makefile
2 parents a7e0e25 + e8f993a commit ede9f82

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ script:
1313
- make
1414
- make lint
1515
- make test-coverage
16-
- goveralls -coverprofile=ib-kubernetes.cover -service=travis-ci
16+
- goveralls -coverprofile=coverage.out -service=travis-ci
1717
- make image
1818

1919
before_deploy:

Makefile

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ PLUGINSSOURCEDIR=$(CURDIR)/pkg/sm/plugins
1010
PLUGINSBUILDDIR=$(BUILDDIR)/plugins
1111
BASE=$(GOPATH)/src/$(REPO_PATH)
1212
GOFILES=$(shell find . -name *.go | grep -vE "(\/vendor\/)|(_test.go)")
13-
PKGS=$(or $(PKG),$(shell cd $(BASE) && env GOPATH=$(GOPATH) $(GO) list ./... | grep -v "^$(PACKAGE)/vendor/"))
14-
TESTPKGS = $(shell env GOPATH=$(GOPATH) $(GO) list -f '{{ if or .TestGoFiles .XTestGoFiles }}{{ .ImportPath }}{{ end }}' $(PKGS))
1513

1614
export GOPATH
1715
export GOBIN
@@ -84,42 +82,26 @@ plugins: noop-plugin ufm-plugin ; $(info Building plugins...) ## Build plugins
8482

8583
%-plugin: $(PLUGINSBUILDDIR)
8684
@echo Building $* plugin
87-
$Q $(GO) build -ldflags "-X $(REPO_PATH)/version=1.0" -o $(PLUGINSBUILDDIR)/$*.so -buildmode=plugin -i $(REPO_PATH)/pkg/sm/plugins/$*
85+
$Q $(GO) build $(GOFLAGS) -ldflags "-X $(REPO_PATH)/version=1.0" -o $(PLUGINSBUILDDIR)/$*.so -buildmode=plugin -i $(REPO_PATH)/pkg/sm/plugins/$*
8886
@echo Done building $* plugin
8987

90-
TEST_TARGETS := test-default test-bench test-short test-verbose test-race
91-
.PHONY: $(TEST_TARGETS) test-xml check test tests
88+
TEST_TARGETS := test-bench test-short test-verbose test-race
89+
.PHONY: $(TEST_TARGETS) test
9290
test-bench: ARGS=-run=__absolutelynothing__ -bench=. ## Run benchmarks
9391
test-short: ARGS=-short ## Run only short tests
9492
test-verbose: ARGS=-v ## Run tests in verbose mode with coverage reporting
95-
test-race: ARGS=-race ## Run tests with race detector
93+
test-race: GOFLAGS=-race ## Run tests with race detector
9694
$(TEST_TARGETS): NAME=$(MAKECMDGOALS:test-%=%)
9795
$(TEST_TARGETS): test
9896

99-
check test tests: | $(BASE) plugins; $(info running $(NAME:%=% )tests...) @ ## Run tests
100-
$Q cd $(BASE) && $(GO) test -timeout $(TIMEOUT)s $(ARGS) $(TESTPKGS)
101-
102-
test-xml: | $(BASE) $(GO2XUNIT) ; $(info running $(NAME:%=% )tests...) @ ## Run tests with xUnit output
103-
$Q cd $(BASE) && 2>&1 $(GO) test -timeout 20s -v $(TESTPKGS) | tee test/tests.output
104-
$(GO2XUNIT) -fail -input test/tests.output -output test/tests.xml
97+
test: | $(BASE) plugins; $(info running $(NAME:%=% )tests...) @ ## Run tests
98+
$Q cd $(BASE) ; $(GO) test -timeout $(TIMEOUT)s $(ARGS) ./...
10599

106100
COVERAGE_MODE = count
107101
.PHONY: test-coverage test-coverage-tools
108102
test-coverage-tools: | $(GOVERALLS)
109-
test-coverage: COVERAGE_DIR := $(CURDIR)/test
110103
test-coverage: test-coverage-tools | $(BASE) plugins; $(info running coverage tests...) @ ## Run coverage tests
111-
$Q mkdir -p $(COVERAGE_DIR)/coverage
112-
$Q cd $(BASE) && for pkg in $(TESTPKGS); do \
113-
$(GO) test \
114-
-coverpkg=$$($(GO) list -f '{{ join .Deps "\n" }}' $$pkg | \
115-
grep '^$(PACKAGE)/' | grep -v '^$(PACKAGE)/vendor/' | \
116-
tr '\n' ',')$$pkg \
117-
-covermode=$(COVERAGE_MODE) \
118-
-coverprofile="$(COVERAGE_DIR)/coverage/`echo $$pkg | tr "/" "-"`.cover" $$pkg ;\
119-
done
120-
$Q echo "mode: ${COVERAGE_MODE}" > ${PACKAGE}.cover
121-
$Q grep -h -v "mode:" $(COVERAGE_DIR)/coverage/*.cover >> ${PACKAGE}.cover
122-
$Q rm -rf $(COVERAGE_DIR)/coverage
104+
$Q cd $(BASE); $(GO) test -covermode=$(COVERAGE_MODE) -coverprofile=coverage.out ./...
123105

124106
# Container image
125107
.PHONY: image

0 commit comments

Comments
 (0)