Skip to content

Commit 69b9924

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 23a14f3 commit 69b9924

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

t/Makefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,21 @@ CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
3636

3737
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
3838
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
39+
TLIBS = $(sort $(wildcard lib-*.sh)) annotate-tests.sh
3940
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))
4042
CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
4143
CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
4244

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+
4350
all: $(DEFAULT_TEST_TARGET)
4451

4552
test: pre-clean check-chainlint $(TEST_LINT)
46-
$(MAKE) aggregate-results-and-cleanup
53+
$(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
4754

4855
failed:
4956
@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
@@ -52,7 +59,7 @@ failed:
5259
test -z "$$failed" || $(MAKE) $$failed
5360

5461
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)
5663
$(MAKE) clean-except-prove-cache
5764

5865
$(T):
@@ -99,6 +106,9 @@ check-chainlint:
99106

100107
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
101108
test-lint-filenames
109+
ifneq ($(GIT_TEST_CHAIN_LINT),0)
110+
test-lint: test-chainlint
111+
endif
102112

103113
test-lint-duplicates:
104114
@dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
@@ -121,6 +131,9 @@ test-lint-filenames:
121131
test -z "$$bad" || { \
122132
echo >&2 "non-portable file name(s): $$bad"; exit 1; }
123133

134+
test-chainlint:
135+
@$(CHAINLINT) $(T) $(TLIBS) $(TPERF) $(TINTEROP)
136+
124137
aggregate-results-and-cleanup: $(T)
125138
$(MAKE) aggregate-results
126139
$(MAKE) clean
@@ -136,4 +149,5 @@ valgrind:
136149
perf:
137150
$(MAKE) -C perf/ all
138151

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

0 commit comments

Comments
 (0)