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>maint
parent
23a14f3016
commit
69b9924b87
20
t/Makefile
20
t/Makefile
|
@ -36,14 +36,21 @@ CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
|
||||||
|
|
||||||
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
|
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
|
||||||
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
|
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
|
||||||
|
TLIBS = $(sort $(wildcard lib-*.sh)) annotate-tests.sh
|
||||||
TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
|
TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
|
||||||
|
TINTEROP = $(sort $(wildcard interop/i[0-9][0-9][0-9][0-9]-*.sh))
|
||||||
CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
|
CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
|
||||||
CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
|
CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
|
||||||
|
|
||||||
|
# `test-chainlint` (which is a dependency of `test-lint`, `test` and `prove`)
|
||||||
|
# checks all tests in all scripts via a single invocation, so tell individual
|
||||||
|
# scripts not to "chainlint" themselves
|
||||||
|
CHAINLINTSUPPRESS = GIT_TEST_CHAIN_LINT=0 && export GIT_TEST_CHAIN_LINT &&
|
||||||
|
|
||||||
all: $(DEFAULT_TEST_TARGET)
|
all: $(DEFAULT_TEST_TARGET)
|
||||||
|
|
||||||
test: pre-clean check-chainlint $(TEST_LINT)
|
test: pre-clean check-chainlint $(TEST_LINT)
|
||||||
$(MAKE) aggregate-results-and-cleanup
|
$(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
|
@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
|
||||||
|
@ -52,7 +59,7 @@ failed:
|
||||||
test -z "$$failed" || $(MAKE) $$failed
|
test -z "$$failed" || $(MAKE) $$failed
|
||||||
|
|
||||||
prove: pre-clean check-chainlint $(TEST_LINT)
|
prove: pre-clean check-chainlint $(TEST_LINT)
|
||||||
@echo "*** prove ***"; $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
|
@echo "*** prove ***"; $(CHAINLINTSUPPRESS) $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
|
||||||
$(MAKE) clean-except-prove-cache
|
$(MAKE) clean-except-prove-cache
|
||||||
|
|
||||||
$(T):
|
$(T):
|
||||||
|
@ -99,6 +106,9 @@ check-chainlint:
|
||||||
|
|
||||||
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
|
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
|
||||||
test-lint-filenames
|
test-lint-filenames
|
||||||
|
ifneq ($(GIT_TEST_CHAIN_LINT),0)
|
||||||
|
test-lint: test-chainlint
|
||||||
|
endif
|
||||||
|
|
||||||
test-lint-duplicates:
|
test-lint-duplicates:
|
||||||
@dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
|
@dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
|
||||||
|
@ -121,6 +131,9 @@ test-lint-filenames:
|
||||||
test -z "$$bad" || { \
|
test -z "$$bad" || { \
|
||||||
echo >&2 "non-portable file name(s): $$bad"; exit 1; }
|
echo >&2 "non-portable file name(s): $$bad"; exit 1; }
|
||||||
|
|
||||||
|
test-chainlint:
|
||||||
|
@$(CHAINLINT) $(T) $(TLIBS) $(TPERF) $(TINTEROP)
|
||||||
|
|
||||||
aggregate-results-and-cleanup: $(T)
|
aggregate-results-and-cleanup: $(T)
|
||||||
$(MAKE) aggregate-results
|
$(MAKE) aggregate-results
|
||||||
$(MAKE) clean
|
$(MAKE) clean
|
||||||
|
@ -136,4 +149,5 @@ valgrind:
|
||||||
perf:
|
perf:
|
||||||
$(MAKE) -C perf/ all
|
$(MAKE) -C perf/ all
|
||||||
|
|
||||||
.PHONY: pre-clean $(T) aggregate-results clean valgrind perf check-chainlint clean-chainlint
|
.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
|
||||||
|
check-chainlint clean-chainlint test-chainlint
|
||||||
|
|
Loading…
Reference in New Issue