send-email: windows drive prefix (e.g. C:) appears only at the beginning
[git] / t / Makefile
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
10 SHELL_PATH ?= $(SHELL)
11 PERL_PATH ?= /usr/bin/perl
12 TAR ?= $(TAR)
13 RM ?= rm -f
14 PROVE ?= prove
15 DEFAULT_TEST_TARGET ?= test
16 TEST_LINT ?= test-lint-duplicates test-lint-executable
17
18 ifdef TEST_OUTPUT_DIRECTORY
19 TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
20 else
21 TEST_RESULTS_DIRECTORY = test-results
22 endif
23
24 # Shell quote;
25 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
26 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
27 TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
28
29 T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
30 TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
31 TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
32
33 all: $(DEFAULT_TEST_TARGET)
34
35 test: pre-clean $(TEST_LINT)
36         $(MAKE) aggregate-results-and-cleanup
37
38 prove: pre-clean $(TEST_LINT)
39         @echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
40         $(MAKE) clean-except-prove-cache
41
42 $(T):
43         @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
44
45 pre-clean:
46         $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
47
48 clean-except-prove-cache:
49         $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
50         $(RM) -r valgrind/bin
51
52 clean: clean-except-prove-cache
53         $(RM) .prove
54
55 test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax
56
57 test-lint-duplicates:
58         @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
59                 test -z "$$dups" || { \
60                 echo >&2 "duplicate test numbers:" $$dups; exit 1; }
61
62 test-lint-executable:
63         @bad=`for i in $(T); do test -x "$$i" || echo $$i; done` && \
64                 test -z "$$bad" || { \
65                 echo >&2 "non-executable tests:" $$bad; exit 1; }
66
67 test-lint-shell-syntax:
68         @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T)
69
70 aggregate-results-and-cleanup: $(T)
71         $(MAKE) aggregate-results
72         $(MAKE) clean
73
74 aggregate-results:
75         for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
76                 echo "$$f"; \
77         done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
78
79 # we can test NO_OPTIMIZE_COMMITS independently of LC_ALL
80 full-svn-test:
81         $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C
82         $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8
83
84 gitweb-test:
85         $(MAKE) $(TGITWEB)
86
87 valgrind:
88         $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
89
90 perf:
91         $(MAKE) -C perf/ all
92
93 .PHONY: pre-clean $(T) aggregate-results clean valgrind perf