t/Makefile: optimize chainlint self-test

Rather than running `chainlint` and `diff` once per self-test -- which may become expensive as more tests are added -- instead run `chainlint` a single time over all tests bodies collectively and compare the result to the collective "expected" output. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Dec 13, 2021 at 01:30 UTC f30c1d5eb1ceeec460ea4cd2089ece63156f5eb0
1 file changed +4 -6
t/Makefile
+4 -6
@@ -71,12 +71,10 @@ clean-chainlint:
71
72 check-chainlint:
73 @mkdir -p '$(CHAINLINTTMP_SQ)' && \
74 - err=0 && \
75 - for i in $(CHAINLINTTESTS); do \
76 - $(CHAINLINT) <chainlint/$$i.test | \
77 - sed -e '/^# LINT: /d' >'$(CHAINLINTTMP_SQ)'/$$i.actual && \
78 - diff -u chainlint/$$i.expect '$(CHAINLINTTMP_SQ)'/$$i.actual || err=1; \
79 - done && exit $$err
74 + sed -e '/^# LINT: /d' $(patsubst %,chainlint/%.test,$(CHAINLINTTESTS)) >'$(CHAINLINTTMP_SQ)'/tests && \
75 + cat $(patsubst %,chainlint/%.expect,$(CHAINLINTTESTS)) >'$(CHAINLINTTMP_SQ)'/expect && \
76 + $(CHAINLINT) '$(CHAINLINTTMP_SQ)'/tests >'$(CHAINLINTTMP_SQ)'/actual && \
77 + diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
78
79 test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
80 test-lint-filenames