@@ -51,11 +51,15 @@ IMAGE_TAGS+=$(shell tagged="$$(git describe --tags --match='v*' --abbrev=0)"; if
5151IMAGE_NAME =$(REGISTRY_NAME ) /$*
5252
5353ifdef V
54+ # Adding "-alsologtostderr" assumes that all test binaries contain glog. This is not guaranteed.
5455TESTARGS = -v -args -alsologtostderr -v 5
5556else
5657TESTARGS =
5758endif
5859
60+ # Specific packages can be excluded from each of the tests below by setting the *_FILTER_CMD variables
61+ # to something like "| grep -v 'github.com/kubernetes-csi/project/pkg/foobar'". See usage below.
62+
5963build-% :
6064 mkdir -p bin
6165 CGO_ENABLED=0 GOOS=linux go build -a -ldflags ' -X main.version=$(REV) -extldflags "-static"' -o ./bin/$* ./cmd/$*
@@ -70,7 +74,7 @@ push-%: container-%
7074 docker push $(IMAGE_NAME ) :$$ tag; \
7175 }; \
7276 for tag in $( IMAGE_TAGS) ; do \
73- if echo $$ tag | grep -q -e ' -canary$$' ; then \
77+ if [ " $$ tag " = " canary " ] || echo " $$ tag" | grep -q -e ' -canary$$' ; then \
7478 : " creating or overwriting canary image" ; \
7579 push_image; \
7680 elif docker pull $(IMAGE_NAME ) :$$ tag 2>&1 | tee /dev/stderr | grep -q " manifest for $( IMAGE_NAME) :$$ tag not found" ; then \
@@ -93,20 +97,20 @@ test:
9397.PHONY : test-go
9498test : test-go
9599test-go :
96- @ echo ; echo $@
97- go test ` go list ./... | grep -v ' vendor' ` $(TESTARGS )
100+ @ echo ; echo " ### $@ : "
101+ go test ` go list ./... | grep -v ' vendor' $( TEST_GO_FILTER_CMD ) ` $(TESTARGS )
98102
99103.PHONY : test-vet
100104test : test-vet
101105test-vet :
102- @ echo ; echo $@
103- go vet ` go list ./... | grep -v vendor`
106+ @ echo ; echo " ### $@ : "
107+ go vet ` go list ./... | grep -v vendor $( TEST_VET_FILTER_CMD ) `
104108
105109.PHONY : test-fmt
106110test : test-fmt
107111test-fmt :
108- @ echo ; echo $@
109- files=$$(find . -name '*.go' | grep -v './vendor' ) ; \
112+ @ echo ; echo " ### $@ : "
113+ files=$$(find . -name '*.go' | grep -v './vendor' $( TEST_FMT_FILTER_CMD ) ) ; \
110114 if [ $$ (gofmt -d $$ files | wc -l) -ne 0 ]; then \
111115 echo " formatting errors:" ; \
112116 gofmt -d $$ files; \
@@ -116,5 +120,5 @@ test-fmt:
116120.PHONY : test-subtree
117121test : test-subtree
118122test-subtree :
119- @ echo ; echo $@
123+ @ echo ; echo " ### $@ : "
120124 ./release-tools/verify-subtree.sh release-tools
0 commit comments