Skip to content

Commit 4679fb1

Browse files
Fix "make test" and "make lint" (#627)
* Fix "make test" and "make lint" Fixes #626 * Fix failing unit test In logging, policy for fields was reversed in 972f219.
1 parent 48c13f0 commit 4679fb1

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

Makefile

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include .bingo/Variables.mk
33
SHELL=/usr/bin/env bash
44

55
PROVIDER_MODULES ?= $(shell find $(PWD)/providers/ -name "go.mod" | grep -v ".bingo" | xargs dirname)
6-
MODULES ?= $(PROVIDER_MODULES) $(PWD)/ $(PWD)/examples
6+
MODULES ?= $(PROVIDER_MODULES) $(PWD) $(PWD)/examples
77
GO_FILES_TO_FMT ?= $(shell find . -path -prune -o -name '*.go' -print)
88

99
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
@@ -48,14 +48,12 @@ fmt: $(GOIMPORTS)
4848
.PHONY: test
4949
test:
5050
@echo "Running tests for all modules: $(MODULES)"
51-
for dir in $(MODULES) ; do \
52-
$(MAKE) test_module DIR=$${dir} ; \
53-
done
51+
$(MAKE) $(MODULES:%=test_module_%)
5452

55-
.PHONY: test_module
56-
test_module:
57-
@echo "Running tests for dir: $(DIR)"
58-
cd $(DIR) && go test -v -race ./...
53+
.PHONY: test_module_%
54+
$(MODULES:%=test_module_%): test_module_%:
55+
@echo "Running tests for dir: $*"
56+
cd $* && go test -v -race ./...
5957

6058
.PHONY: deps
6159
deps:
@@ -93,27 +91,25 @@ lint: $(BUF) $(COPYRIGHT) fmt docs
9391

9492
@echo "Running lint for all modules: $(MODULES)"
9593
@$(call require_clean_work_tree,"before lint")
96-
for dir in $(MODULES) ; do \
97-
$(MAKE) lint_module DIR=$${dir} ; \
98-
done
94+
$(MAKE) $(MODULES:%=lint_module_%)
9995
@$(call require_clean_work_tree,"lint and format files")
10096

101-
.PHONY: lint_module
97+
.PHONY: lint_module_%
10298
# PROTIP:
10399
# Add
104100
# --cpu-profile-path string Path to CPU profile output file
105101
# --mem-profile-path string Path to memory profile output file
106102
# to debug big allocations during linting.
107-
lint_module: ## Runs various static analysis against our code.
108-
lint_module: $(FAILLINT) $(GOLANGCI_LINT) $(MISSPELL)
103+
lint_module_%: ## Runs various static analysis against our code.
104+
$(MODULES:%=lint_module_%): lint_module_%: $(FAILLINT) $(GOLANGCI_LINT) $(MISSPELL)
109105
@echo ">> verifying modules being imported"
110-
@cd $(DIR) && $(FAILLINT) -paths "fmt.{Print,Printf,Println},github.com/golang/protobuf=google.golang.org/protobuf" ./...
106+
@cd $* && $(FAILLINT) -paths "fmt.{Print,Printf,Println},github.com/golang/protobuf=google.golang.org/protobuf" ./...
111107

112108
@echo ">> examining all of the Go files"
113-
@cd $(DIR) && go vet -stdmethods=false ./...
109+
@cd $* && go vet -stdmethods=false ./...
114110

115111
@echo ">> linting all of the Go files GOGC=${GOGC}"
116-
@cd $(DIR) && $(GOLANGCI_LINT) run
112+
@cd $* && $(GOLANGCI_LINT) run
117113
@$(call require_clean_work_tree,"golangci lint")
118114

119115

interceptors/logging/interceptors_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ type loggingClientServerSuite struct {
173173
}
174174

175175
func customFields(_ context.Context) logging.Fields {
176-
return logging.Fields{"custom-field", "yolo"}
176+
// Add custom fields. The second one overrides the first one.
177+
return logging.Fields{"custom-field", "foo", "custom-field", "yolo"}
177178
}
178179

179180
func TestSuite(t *testing.T) {

0 commit comments

Comments
 (0)