Skip to content

Commit 2a0e445

Browse files
[chore] update integration test runs to only run tests in integration test files (#42369)
See #42366 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 8ed987a commit 2a0e445

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Makefile.Common

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,37 @@ ifneq (,$(wildcard ./builtunitetest.test))
139139
$(GOTESTSUM) --raw-command -- $(GOCMD) tool test2json -p "./..." -t ./builtunitetest.test -test.v -test.failfast -test.timeout $(GOTEST_TIMEOUT)
140140
endif
141141

142+
INTEGRATION_TEST_FILES := $(shell find . -name *integration_test.go)
143+
INTEGRATION_TESTS := $(shell cat $(INTEGRATION_TEST_FILES) | sed -n "s/func \(Test[A-Za-z0-9_]*\).*/\1/p" | xargs | sed "s/ /|/g")
142144
.PHONY: mod-integration-test
143145
mod-integration-test: $(GOTESTSUM)
144-
@echo "running $(GOCMD) integration test ./... in `pwd`"
145-
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION)
146+
@echo "running $(GOCMD) integration test $(INTEGRATION_TESTS) in `pwd`"
147+
@if [ -n "$(INTEGRATION_TESTS)" ]; then \
148+
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- -run "$(INTEGRATION_TESTS)" $(GOTEST_OPT_WITH_INTEGRATION); \
149+
else \
150+
echo "No integration tests in `pwd`"; \
151+
fi
146152
@if [ -e integration-coverage.txt ]; then \
147153
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
148154
fi
149155

150156
.PHONY: mod-integration-sudo-test
151157
mod-integration-sudo-test: $(GOTESTSUM)
152-
@echo "running $(GOCMD) integration sudo (root/privileged) test ./... in `pwd`"
153-
$(GOTESTSUM) $(GOTESTSUM_OPT) --format standard-verbose --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION_SUDO)
158+
@echo "running $(GOCMD) integration sudo (root/privileged) test $(INTEGRATION_TESTS) in `pwd`"
159+
@if [ -n "$(INTEGRATION_TESTS)" ]; then \
160+
$(GOTESTSUM) $(GOTESTSUM_OPT) --format standard-verbose --packages="./..." -- -run "$(INTEGRATION_TESTS)" $(GOTEST_OPT_WITH_INTEGRATION_SUDO); \
161+
else \
162+
echo "No integration tests in `pwd`"; \
163+
fi
154164

155165
.PHONY: do-integration-tests-with-cover
156166
do-integration-tests-with-cover: $(GOTESTSUM)
157-
@echo "running $(GOCMD) integration test ./... + coverage in `pwd`"
158-
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION_COVERAGE)
167+
@echo "running $(GOCMD) integration test $(INTEGRATION_TESTS) + coverage in `pwd`"
168+
@if [ -n "$(INTEGRATION_TESTS)" ]; then \
169+
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- -run "$(INTEGRATION_TESTS)" $(GOTEST_OPT_WITH_INTEGRATION_COVERAGE); \
170+
else \
171+
echo "No integration tests in `pwd`"; \
172+
fi
159173
@if [ -e integration-coverage.txt ]; then \
160174
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
161175
fi

0 commit comments

Comments
 (0)