]> git.ipfire.org Git - thirdparty/git.git/blob - t/Makefile
Merge branch 'sy/mv-out-of-cone'
[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 THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
39 TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
40 CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
41 CHAINLINT = sed -f chainlint.sed
42
43 all: $(DEFAULT_TEST_TARGET)
44
45 test: pre-clean check-chainlint $(TEST_LINT)
46 $(MAKE) aggregate-results-and-cleanup
47
48 failed:
49 @failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
50 grep -l '^failed [1-9]' *.counts | \
51 sed -n 's/\.counts$$/.sh/p') && \
52 test -z "$$failed" || $(MAKE) $$failed
53
54 prove: pre-clean check-chainlint $(TEST_LINT)
55 @echo "*** prove ***"; $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
56 $(MAKE) clean-except-prove-cache
57
58 $(T):
59 @echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
60
61 pre-clean:
62 $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
63
64 clean-except-prove-cache: clean-chainlint
65 $(RM) -r 'trash directory'.*
66 $(RM) -r valgrind/bin
67
68 clean: clean-except-prove-cache
69 $(RM) .prove
70
71 clean-chainlint:
72 $(RM) -r '$(CHAINLINTTMP_SQ)'
73
74 check-chainlint:
75 @mkdir -p '$(CHAINLINTTMP_SQ)' && \
76 sed -e '/^# LINT: /d' $(patsubst %,chainlint/%.test,$(CHAINLINTTESTS)) >'$(CHAINLINTTMP_SQ)'/tests && \
77 sed -e '/^[ ]*$$/d' $(patsubst %,chainlint/%.expect,$(CHAINLINTTESTS)) >'$(CHAINLINTTMP_SQ)'/expect && \
78 $(CHAINLINT) '$(CHAINLINTTMP_SQ)'/tests | grep -v '^[ ]*$$' >'$(CHAINLINTTMP_SQ)'/actual && \
79 diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
80
81 test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
82 test-lint-filenames
83
84 test-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
89 test-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
94 test-lint-shell-syntax:
95 @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF)
96
97 test-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
105 aggregate-results-and-cleanup: $(T)
106 $(MAKE) aggregate-results
107 $(MAKE) clean
108
109 aggregate-results:
110 for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
111 echo "$$f"; \
112 done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
113
114 valgrind:
115 $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
116
117 perf:
118 $(MAKE) -C perf/ all
119
120 .PHONY: pre-clean $(T) aggregate-results clean valgrind perf check-chainlint clean-chainlint