]>
Commit | Line | Data |
---|---|---|
e1970ce4 JH |
1 | # Run tests |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
d6928ebd | 5 | |
b2b0026e | 6 | -include ../config.mak.autogen |
c14417c4 JK |
7 | -include ../config.mak |
8 | ||
dd6fc7ca | 9 | #GIT_TEST_OPTS = --verbose --debug |
edde7a8b | 10 | SHELL_PATH ?= $(SHELL) |
3f824e91 | 11 | TEST_SHELL_PATH ?= $(SHELL_PATH) |
4678a5cd | 12 | PERL_PATH ?= /usr/bin/perl |
455a7f32 | 13 | TAR ?= $(TAR) |
4cb08df5 | 14 | RM ?= rm -f |
28d836c8 MG |
15 | PROVE ?= prove |
16 | DEFAULT_TEST_TARGET ?= test | |
00f6991d | 17 | TEST_LINT ?= test-lint |
e1970ce4 | 18 | |
54bb9015 | 19 | ifdef TEST_OUTPUT_DIRECTORY |
b3e0c4ed | 20 | TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results |
80339445 | 21 | CHAINLINTTMP = $(TEST_OUTPUT_DIRECTORY)/chainlinttmp |
54bb9015 JK |
22 | else |
23 | TEST_RESULTS_DIRECTORY = test-results | |
80339445 | 24 | CHAINLINTTMP = chainlinttmp |
54bb9015 JK |
25 | endif |
26 | ||
4769948a | 27 | # Shell quote; |
39c015c5 | 28 | SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) |
3f824e91 | 29 | TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH)) |
c7ce70ac | 30 | PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) |
54bb9015 | 31 | TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY)) |
80339445 | 32 | CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP)) |
4769948a | 33 | |
aae5239b | 34 | T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) |
aae5239b | 35 | TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh)) |
cd78cea2 | 36 | THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh))) |
ed5a2457 | 37 | TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh)) |
80339445 ES |
38 | CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test))) |
39 | CHAINLINT = sed -f chainlint.sed | |
e1970ce4 | 40 | |
28d836c8 MG |
41 | all: $(DEFAULT_TEST_TARGET) |
42 | ||
80339445 | 43 | test: pre-clean check-chainlint $(TEST_LINT) |
e3df89a4 | 44 | $(MAKE) aggregate-results-and-cleanup |
23fc63bf | 45 | |
93a04bb1 JS |
46 | failed: |
47 | @failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \ | |
48 | grep -l '^failed [1-9]' *.counts | \ | |
49 | sed -n 's/\.counts$$/.sh/p') && \ | |
50 | test -z "$$failed" || $(MAKE) $$failed | |
51 | ||
80339445 | 52 | prove: pre-clean check-chainlint $(TEST_LINT) |
3f824e91 | 53 | @echo "*** prove ***"; $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS) |
60f26f63 | 54 | $(MAKE) clean-except-prove-cache |
28d836c8 | 55 | |
23fc63bf | 56 | $(T): |
3f824e91 | 57 | @echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS) |
e1970ce4 | 58 | |
f8d5ffc2 | 59 | pre-clean: |
54bb9015 | 60 | $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)' |
f8d5ffc2 | 61 | |
80339445 | 62 | clean-except-prove-cache: clean-chainlint |
54bb9015 | 63 | $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)' |
34b383e7 | 64 | $(RM) -r valgrind/bin |
60f26f63 MH |
65 | |
66 | clean: clean-except-prove-cache | |
9a3028b9 | 67 | $(RM) .prove |
23fc63bf | 68 | |
80339445 ES |
69 | clean-chainlint: |
70 | $(RM) -r '$(CHAINLINTTMP_SQ)' | |
71 | ||
72 | check-chainlint: | |
73 | @mkdir -p '$(CHAINLINTTMP_SQ)' && \ | |
f30c1d5e ES |
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 | |
80339445 | 78 | |
c2cafd39 JS |
79 | test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \ |
80 | test-lint-filenames | |
d38732c2 JK |
81 | |
82 | test-lint-duplicates: | |
ed5a2457 | 83 | @dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \ |
d38732c2 JK |
84 | test -z "$$dups" || { \ |
85 | echo >&2 "duplicate test numbers:" $$dups; exit 1; } | |
86 | ||
87 | test-lint-executable: | |
ed5a2457 | 88 | @bad=`for i in $(T) $(TPERF); do test -x "$$i" || echo $$i; done` && \ |
d38732c2 JK |
89 | test -z "$$bad" || { \ |
90 | echo >&2 "non-executable tests:" $$bad; exit 1; } | |
91 | ||
c7ce70ac | 92 | test-lint-shell-syntax: |
ed5a2457 | 93 | @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF) |
c7ce70ac | 94 | |
c2cafd39 JS |
95 | test-lint-filenames: |
96 | @# We do *not* pass a glob to ls-files but use grep instead, to catch | |
97 | @# non-ASCII characters (which are quoted within double-quotes) | |
98 | @bad="$$(git -c core.quotepath=true ls-files 2>/dev/null | \ | |
99 | grep '["*:<>?\\|]')"; \ | |
100 | test -z "$$bad" || { \ | |
101 | echo >&2 "non-portable file name(s): $$bad"; exit 1; } | |
102 | ||
e3df89a4 JS |
103 | aggregate-results-and-cleanup: $(T) |
104 | $(MAKE) aggregate-results | |
105 | $(MAKE) clean | |
106 | ||
f8d5ffc2 | 107 | aggregate-results: |
54bb9015 | 108 | for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \ |
6508eedf BC |
109 | echo "$$f"; \ |
110 | done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh | |
f8d5ffc2 | 111 | |
958a8467 JN |
112 | gitweb-test: |
113 | $(MAKE) $(TGITWEB) | |
114 | ||
7f6fdea1 | 115 | valgrind: |
7ef4d6b9 | 116 | $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind" |
7f6fdea1 | 117 | |
342e9ef2 TR |
118 | perf: |
119 | $(MAKE) -C perf/ all | |
120 | ||
80339445 | 121 | .PHONY: pre-clean $(T) aggregate-results clean valgrind perf check-chainlint clean-chainlint |