@@ -10,8 +10,6 @@ PLUGINSSOURCEDIR=$(CURDIR)/pkg/sm/plugins
1010PLUGINSBUILDDIR =$(BUILDDIR ) /plugins
1111BASE =$(GOPATH ) /src/$(REPO_PATH )
1212GOFILES =$(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
1614export GOPATH
1715export 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
9290test-bench : ARGS=-run=__absolutelynothing__ -bench=. # # Run benchmarks
9391test-short : ARGS=-short # # Run only short tests
9492test-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
106100COVERAGE_MODE = count
107101.PHONY : test-coverage test-coverage-tools
108102test-coverage-tools : | $(GOVERALLS )
109- test-coverage : COVERAGE_DIR := $(CURDIR ) /test
110103test-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