Skip to content

Commit 4b9adaa

Browse files
committed
Update Makefile to support running specific unit and e2e tests (kmesh-net#1230)
1 parent 28bd8ad commit 4b9adaa

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

Makefile

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,49 @@ e2e-ipv6:
211211
format:
212212
./hack/format.sh
213213

214+
# New variables for test filtering
215+
RUN_IN_CONTAINER ?= 0
216+
UNIT_TEST_PATTERN ?= .
217+
E2E_TEST_PATTERN ?= .
218+
219+
# Run unit tests
220+
.PHONY: test-unit
221+
test-unit:
222+
ifeq ($(RUN_IN_CONTAINER), 1)
223+
@echo "Running unit tests in Docker..."
224+
./hack/run-ut.sh --docker -run $(UNIT_TEST_PATTERN)
225+
else
226+
@echo "Running unit tests locally..."
227+
./hack/run-ut.sh --local -run $(UNIT_TEST_PATTERN)
228+
endif
229+
230+
# Run E2E tests
231+
.PHONY: test-e2e
232+
test-e2e:
233+
@echo "Running E2E tests..."
234+
./test/e2e/run_test.sh --only-run-tests -run $(E2E_TEST_PATTERN)
235+
236+
# Run all tests (unit + E2E)
214237
.PHONY: test
215-
ifeq ($(RUN_IN_CONTAINER),1)
216-
test:
217-
./hack/run-ut.sh --docker
238+
test: test-unit test-e2e
239+
240+
# Run specific unit tests
241+
.PHONY: test-unit-specific
242+
test-unit-specific:
243+
ifeq ($(RUN_IN_CONTAINER), 1)
244+
@echo "Running specific unit tests in Docker..."
245+
./hack/run-ut.sh --docker -run $(UNIT_TEST_PATTERN)
218246
else
219-
test:
220-
./hack/run-ut.sh --local
247+
@echo "Running specific unit tests locally..."
248+
./hack/run-ut.sh --local -run $(UNIT_TEST_PATTERN)
221249
endif
222250

251+
# Run specific E2E tests
252+
.PHONY: test-e2e-specific
253+
test-e2e-specific:
254+
@echo "Running specific E2E tests..."
255+
./test/e2e/run_test.sh --only-run-tests -run $(E2E_TEST_PATTERN)
256+
223257
UPDATE_VERSION ?= ${VERSION}
224258
.PHONY: update-version
225259
update-version:
@@ -288,4 +322,4 @@ helm-push: helm-package
288322
# run other make targets
289323
@for chart in $(CHARTS); do \
290324
$(MAKE) $(addprefix helm-push., $$(basename $${chart})); \
291-
done
325+
done

0 commit comments

Comments
 (0)