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