From b1308ad422b8025cf6dfccfc635ebece89a05fd9 Mon Sep 17 00:00:00 2001 From: Will Chandler Date: Sat, 24 Sep 2022 11:54:10 -0400 Subject: make: use 'override' when adding to TEST_OPTIONS When `TEST_OPTIONS` is specified as an argument to `make`, any options specified in the `Makefile` will be overwritten with the user-provided value. In several targets we append arguments to `TEST_OPTIONS`, making them vulnerable to being squashed inadvertently. For example, if running `make race-go TEST_OPTIONS='-run= -count=20'` to reproduce a race condition, the intended command would be: gotestsum --format short -- -run -count 20 -race ./... But because `TEST_OPTIONS` is specified, this is actually executed as: gotestsum --format short -- -run -count 20 ./... Resolve this by using the `override` directive in targets that attempt to append to `TEST_OPTIONS`. This will allow the user to add custom options without squashing the target's additions. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index db15f7d47..85594e8ce 100644 --- a/Makefile +++ b/Makefile @@ -395,11 +395,11 @@ debug-test-go: prepare-tests prepare-debug .PHONY: test ## Run Go benchmarks. -bench: TEST_OPTIONS := ${TEST_OPTIONS} -bench=. -run=^$ +bench: override TEST_OPTIONS := ${TEST_OPTIONS} -bench=. -run=^$ bench: ${BENCHMARK_REPO} test-go .PHONY: test-with-proxies -test-with-proxies: TEST_OPTIONS := ${TEST_OPTIONS} -exec ${SOURCE_DIR}/_support/bad-proxies +test-with-proxies: override TEST_OPTIONS := ${TEST_OPTIONS} -exec ${SOURCE_DIR}/_support/bad-proxies test-with-proxies: TEST_PACKAGES := ${GITALY_PACKAGE}/internal/gitaly/rubyserver test-with-proxies: prepare-tests ${Q}$(call run_go_tests) @@ -411,7 +411,7 @@ test-with-praefect: prepare-tests .PHONY: race-go ## Run Go tests with race detection enabled. -race-go: TEST_OPTIONS := ${TEST_OPTIONS} -race +race-go: override TEST_OPTIONS := ${TEST_OPTIONS} -race race-go: test-go .PHONY: rspec @@ -477,7 +477,7 @@ rubocop: ${SOURCE_DIR}/.ruby-bundle .PHONY: cover ## Generate coverage report via Go tests. -cover: TEST_OPTIONS := ${TEST_OPTIONS} -coverprofile "${TEST_COVERAGE_DIR}/all.merged" +cover: override TEST_OPTIONS := ${TEST_OPTIONS} -coverprofile "${TEST_COVERAGE_DIR}/all.merged" cover: prepare-tests libgit2 ${GOCOVER_COBERTURA} ${Q}rm -rf "${TEST_COVERAGE_DIR}" ${Q}mkdir -p "${TEST_COVERAGE_DIR}" -- cgit v1.2.3