]> git.ipfire.org Git - thirdparty/git.git/blame_incremental - t/Makefile
Merge branch 'dl/checkout-p-merge-base'
[thirdparty/git.git] / t / Makefile
... / ...
CommitLineData
1# Run tests
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6-include ../config.mak.autogen
7-include ../config.mak
8
9#GIT_TEST_OPTS = --verbose --debug
10SHELL_PATH ?= $(SHELL)
11TEST_SHELL_PATH ?= $(SHELL_PATH)
12PERL_PATH ?= /usr/bin/perl
13TAR ?= $(TAR)
14RM ?= rm -f
15PROVE ?= prove
16DEFAULT_TEST_TARGET ?= test
17TEST_LINT ?= test-lint
18
19ifdef TEST_OUTPUT_DIRECTORY
20TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
21CHAINLINTTMP = $(TEST_OUTPUT_DIRECTORY)/chainlinttmp
22else
23TEST_RESULTS_DIRECTORY = test-results
24CHAINLINTTMP = chainlinttmp
25endif
26
27# Shell quote;
28SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
29TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH))
30PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
31TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
32CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
33
34T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
35TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
36THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
37TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
38CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
39CHAINLINT = sed -f chainlint.sed
40
41all: $(DEFAULT_TEST_TARGET)
42
43test: pre-clean check-chainlint $(TEST_LINT)
44 $(MAKE) aggregate-results-and-cleanup
45
46failed:
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
52prove: pre-clean check-chainlint $(TEST_LINT)
53 @echo "*** prove ***"; $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
54 $(MAKE) clean-except-prove-cache
55
56$(T):
57 @echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
58
59pre-clean:
60 $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
61
62clean-except-prove-cache: clean-chainlint
63 $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
64 $(RM) -r valgrind/bin
65
66clean: clean-except-prove-cache
67 $(RM) .prove
68
69clean-chainlint:
70 $(RM) -r '$(CHAINLINTTMP_SQ)'
71
72check-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
80
81test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
82 test-lint-filenames
83
84test-lint-duplicates:
85 @dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
86 test -z "$$dups" || { \
87 echo >&2 "duplicate test numbers:" $$dups; exit 1; }
88
89test-lint-executable:
90 @bad=`for i in $(T) $(TPERF); do test -x "$$i" || echo $$i; done` && \
91 test -z "$$bad" || { \
92 echo >&2 "non-executable tests:" $$bad; exit 1; }
93
94test-lint-shell-syntax:
95 @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF)
96
97test-lint-filenames:
98 @# We do *not* pass a glob to ls-files but use grep instead, to catch
99 @# non-ASCII characters (which are quoted within double-quotes)
100 @bad="$$(git -c core.quotepath=true ls-files 2>/dev/null | \
101 grep '["*:<>?\\|]')"; \
102 test -z "$$bad" || { \
103 echo >&2 "non-portable file name(s): $$bad"; exit 1; }
104
105aggregate-results-and-cleanup: $(T)
106 $(MAKE) aggregate-results
107 $(MAKE) clean
108
109aggregate-results:
110 for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
111 echo "$$f"; \
112 done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
113
114gitweb-test:
115 $(MAKE) $(TGITWEB)
116
117valgrind:
118 $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
119
120perf:
121 $(MAKE) -C perf/ all
122
123.PHONY: pre-clean $(T) aggregate-results clean valgrind perf check-chainlint clean-chainlint