Skip to content

Commit f30c1d5

Browse files
sunshinecogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0cca54c commit f30c1d5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

t/Makefile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ clean-chainlint:
7171

7272
check-chainlint:
7373
@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
8078

8179
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
8280
test-lint-filenames

0 commit comments

Comments
 (0)