t/Makefile: teach `make test` and `make prove` to run chainlint.pl
Unlike chainlint.sed which "lints" a single test body at a time, thus is invoked once per test, chainlint.pl can check all test bodies in all test scripts with a single invocation. As such, it is akin to other bulk "linters" run by the Makefile, such as `test-lint-shell-syntax`, `test-lint-duplicates`, etc. Therefore, teach `make test` and `make prove` to invoke chainlint.pl along with the other bulk linters. Also, since the single chainlint.pl invocation by `make test` or `make prove` has already checked all tests in all scripts, instruct the individual test scripts not to run chainlint.pl on themselves unnecessarily. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committed
Sep 1, 2022 at 00:29 UTC
69b9924b875079babb1d3f665bdc719c4871ba73
1 file changed
+17
-3
t/Makefile
+17
-3
@@ -36,14 +36,21 @@ CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
36
37
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
38
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
39
+TLIBS = $(sort $(wildcard lib-*.sh)) annotate-tests.sh
40
TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
41
+TINTEROP = $(sort $(wildcard interop/i[0-9][0-9][0-9][0-9]-*.sh))
42
CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
43
CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
44
45
+# `test-chainlint` (which is a dependency of `test-lint`, `test` and `prove`)
46
+# checks all tests in all scripts via a single invocation, so tell individual
47
+# scripts not to "chainlint" themselves
48
+CHAINLINTSUPPRESS = GIT_TEST_CHAIN_LINT=0 && export GIT_TEST_CHAIN_LINT &&
49
+
50
all: $(DEFAULT_TEST_TARGET)
51
52
test: pre-clean check-chainlint $(TEST_LINT)
46
- $(MAKE) aggregate-results-and-cleanup
53
+ $(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
54
55
failed:
56
@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
@@ -52,7 +59,7 @@ failed:
59
test -z "$$failed" || $(MAKE) $$failed
60
61
prove: pre-clean check-chainlint $(TEST_LINT)
55
- @echo "*** prove ***"; $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
62
+ @echo "*** prove ***"; $(CHAINLINTSUPPRESS) $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
63
$(MAKE) clean-except-prove-cache
64
65
$(T):
@@ -99,6 +106,9 @@ check-chainlint:
106
107
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
108
test-lint-filenames
109
+ifneq ($(GIT_TEST_CHAIN_LINT),0)
110
+test-lint: test-chainlint
111
+endif
112
113
test-lint-duplicates:
114
@dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
@@ -121,6 +131,9 @@ test-lint-filenames:
131
test -z "$$bad" || { \
132
echo >&2 "non-portable file name(s): $$bad"; exit 1; }
133
134
+test-chainlint:
135
+ @$(CHAINLINT) $(T) $(TLIBS) $(TPERF) $(TINTEROP)
136
+
137
aggregate-results-and-cleanup: $(T)
138
$(MAKE) aggregate-results
139
$(MAKE) clean
@@ -136,4 +149,5 @@ valgrind:
149
perf:
150
$(MAKE) -C perf/ all
151
139
-.PHONY: pre-clean $(T) aggregate-results clean valgrind perf check-chainlint clean-chainlint
152
+.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
153
+ check-chainlint clean-chainlint test-chainlint