diff --git a/.gitignore b/.gitignore index 9ac2286b663e..6989454bd2be 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ local/ # GoLand IDEA /.idea/ +*.iml # VS Code .vscode diff --git a/Makefile b/Makefile index 5ef0073e3f1b..aea9910ee54d 100644 --- a/Makefile +++ b/Makefile @@ -29,9 +29,12 @@ test-with-cover: @echo Verifying that all packages have test files to count in coverage @scripts/check-test-files.sh $(subst github.com/open-telemetry/opentelemetry-collector-contrib/,./,$(ALL_PKGS)) @echo pre-compiling tests - go test -i $(ALL_PKGS) - $(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS) - go tool cover -html=coverage.txt -o coverage.html + set -e; for dir in $(ALL_TEST_DIRS); do \ + echo "go test ./... + coverage in $${dir}"; \ + (cd "$${dir}" && \ + $(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) ./... && \ + go tool cover -html=coverage.txt -o coverage.html ); \ + done .PHONY: install-tools install-tools: diff --git a/Makefile.Common b/Makefile.Common index 15097c432eba..a94bb7fc7ac6 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -7,6 +7,8 @@ ALL_SRC_AND_DOC := $(shell find . \( -name "*.md" -o -name "*.go" -o -name "*.ya # ALL_PKGS is used with 'go cover' ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC)))) +# ALL_TEST_DIRS includes ./* dirs (excludes . dir) +ALL_TEST_DIRS := $(shell find . -type f -name "go.mod" -exec dirname {} \; | sort | egrep '^./' ) GOTEST_OPT?= -race -timeout 30s GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic @@ -35,7 +37,12 @@ common: addlicense fmt impi vet lint goimports misspell staticcheck test .PHONY: test test: - $(GOTEST) $(GOTEST_OPT) $(ALL_PKGS) + # $(GOTEST) $(GOTEST_OPT) $(ALL_TEST_DIRS) + set -e; for dir in $(ALL_TEST_DIRS); do \ + echo "go test ./... in $${dir}"; \ + (cd "$${dir}" && \ + $(GOTEST) ./... ); \ + done .PHONY: benchmark benchmark: