]> git.ipfire.org Git - thirdparty/git.git/blame - t/Makefile
Merge branch 'en/ort-finalize-after-0-merges-fix'
[thirdparty/git.git] / t / Makefile
CommitLineData
8df786d2
ÆAB
1# Import tree-wide shared Makefile behavior and libraries
2include ../shared.mak
3
e1970ce4
JH
4# Run tests
5#
6# Copyright (c) 2005 Junio C Hamano
7#
d6928ebd 8
b2b0026e 9-include ../config.mak.autogen
c14417c4
JK
10-include ../config.mak
11
dd6fc7ca 12#GIT_TEST_OPTS = --verbose --debug
edde7a8b 13SHELL_PATH ?= $(SHELL)
3f824e91 14TEST_SHELL_PATH ?= $(SHELL_PATH)
4678a5cd 15PERL_PATH ?= /usr/bin/perl
455a7f32 16TAR ?= $(TAR)
4cb08df5 17RM ?= rm -f
28d836c8
MG
18PROVE ?= prove
19DEFAULT_TEST_TARGET ?= test
00f6991d 20TEST_LINT ?= test-lint
e1970ce4 21
54bb9015 22ifdef TEST_OUTPUT_DIRECTORY
b3e0c4ed 23TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
80339445 24CHAINLINTTMP = $(TEST_OUTPUT_DIRECTORY)/chainlinttmp
54bb9015
JK
25else
26TEST_RESULTS_DIRECTORY = test-results
80339445 27CHAINLINTTMP = chainlinttmp
54bb9015
JK
28endif
29
4769948a 30# Shell quote;
39c015c5 31SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
3f824e91 32TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH))
c7ce70ac 33PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
54bb9015 34TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
80339445 35CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
4769948a 36
aae5239b 37T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
cd78cea2 38THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
69b9924b 39TLIBS = $(sort $(wildcard lib-*.sh)) annotate-tests.sh
ed5a2457 40TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
69b9924b 41TINTEROP = $(sort $(wildcard interop/i[0-9][0-9][0-9][0-9]-*.sh))
80339445 42CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
d00113ec 43CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
e1970ce4 44
69b9924b
ES
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
7b6555ab
JK
47# scripts not to run the external "chainlint.pl" script themselves
48CHAINLINTSUPPRESS = GIT_TEST_EXT_CHAIN_LINT=0 && export GIT_TEST_EXT_CHAIN_LINT &&
69b9924b 49
28d836c8
MG
50all: $(DEFAULT_TEST_TARGET)
51
80339445 52test: pre-clean check-chainlint $(TEST_LINT)
69b9924b 53 $(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
23fc63bf 54
93a04bb1
JS
55failed:
56 @failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
57 grep -l '^failed [1-9]' *.counts | \
58 sed -n 's/\.counts$$/.sh/p') && \
59 test -z "$$failed" || $(MAKE) $$failed
60
80339445 61prove: pre-clean check-chainlint $(TEST_LINT)
69b9924b 62 @echo "*** prove ***"; $(CHAINLINTSUPPRESS) $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
60f26f63 63 $(MAKE) clean-except-prove-cache
28d836c8 64
23fc63bf 65$(T):
3f824e91 66 @echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
e1970ce4 67
f8d5ffc2 68pre-clean:
54bb9015 69 $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
f8d5ffc2 70
80339445 71clean-except-prove-cache: clean-chainlint
fee65b19 72 $(RM) -r 'trash directory'.*
34b383e7 73 $(RM) -r valgrind/bin
60f26f63
MH
74
75clean: clean-except-prove-cache
d11b8751 76 $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
9a3028b9 77 $(RM) .prove
23fc63bf 78
80339445
ES
79clean-chainlint:
80 $(RM) -r '$(CHAINLINTTMP_SQ)'
81
82check-chainlint:
83 @mkdir -p '$(CHAINLINTTMP_SQ)' && \
d00113ec
ES
84 for i in $(CHAINLINTTESTS); do \
85 echo "test_expect_success '$$i' '" && \
86 sed -e '/^# LINT: /d' chainlint/$$i.test && \
87 echo "'"; \
88 done >'$(CHAINLINTTMP_SQ)'/tests && \
89 { \
90 echo "# chainlint: $(CHAINLINTTMP_SQ)/tests" && \
91 for i in $(CHAINLINTTESTS); do \
92 echo "# chainlint: $$i" && \
93 sed -e '/^[ ]*$$/d' chainlint/$$i.expect; \
94 done \
95 } >'$(CHAINLINTTMP_SQ)'/expect && \
96 $(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests | \
48d69d8f 97 sed -e 's/^[1-9][0-9]* //;/^[ ]*$$/d' >'$(CHAINLINTTMP_SQ)'/actual && \
d00113ec
ES
98 if test -f ../GIT-BUILD-OPTIONS; then \
99 . ../GIT-BUILD-OPTIONS; \
100 fi && \
101 if test -x ../git$$X; then \
102 DIFFW="../git$$X --no-pager diff -w --no-index"; \
103 else \
104 DIFFW="diff -w -u"; \
105 fi && \
106 $$DIFFW '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
80339445 107
c2cafd39
JS
108test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
109 test-lint-filenames
69b9924b
ES
110ifneq ($(GIT_TEST_CHAIN_LINT),0)
111test-lint: test-chainlint
112endif
d38732c2
JK
113
114test-lint-duplicates:
ed5a2457 115 @dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
d38732c2
JK
116 test -z "$$dups" || { \
117 echo >&2 "duplicate test numbers:" $$dups; exit 1; }
118
119test-lint-executable:
ed5a2457 120 @bad=`for i in $(T) $(TPERF); do test -x "$$i" || echo $$i; done` && \
d38732c2
JK
121 test -z "$$bad" || { \
122 echo >&2 "non-executable tests:" $$bad; exit 1; }
123
c7ce70ac 124test-lint-shell-syntax:
ed5a2457 125 @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF)
c7ce70ac 126
c2cafd39
JS
127test-lint-filenames:
128 @# We do *not* pass a glob to ls-files but use grep instead, to catch
129 @# non-ASCII characters (which are quoted within double-quotes)
130 @bad="$$(git -c core.quotepath=true ls-files 2>/dev/null | \
131 grep '["*:<>?\\|]')"; \
132 test -z "$$bad" || { \
133 echo >&2 "non-portable file name(s): $$bad"; exit 1; }
134
69b9924b
ES
135test-chainlint:
136 @$(CHAINLINT) $(T) $(TLIBS) $(TPERF) $(TINTEROP)
137
e3df89a4
JS
138aggregate-results-and-cleanup: $(T)
139 $(MAKE) aggregate-results
140 $(MAKE) clean
141
f8d5ffc2 142aggregate-results:
90ff7c98 143 @'$(SHELL_PATH_SQ)' ./aggregate-results.sh '$(TEST_RESULTS_DIRECTORY_SQ)'
f8d5ffc2 144
7f6fdea1 145valgrind:
7ef4d6b9 146 $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
7f6fdea1 147
342e9ef2
TR
148perf:
149 $(MAKE) -C perf/ all
150
69b9924b
ES
151.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
152 check-chainlint clean-chainlint test-chainlint