rebase: use correct base for --keep-base when a branch is given
[alt-git.git] / t / Makefile
blob056ce55dcc92c923ce560ef61a0b2888d799c450
1 # Import tree-wide shared Makefile behavior and libraries
2 include ../shared.mak
4 # Run tests
6 # Copyright (c) 2005 Junio C Hamano
9 -include ../config.mak.autogen
10 -include ../config.mak
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
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
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))
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
44 all: $(DEFAULT_TEST_TARGET)
46 test: pre-clean check-chainlint $(TEST_LINT)
47 $(MAKE) aggregate-results-and-cleanup
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
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
59 $(T):
60 @echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
62 pre-clean:
63 $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
65 clean-except-prove-cache: clean-chainlint
66 $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
67 $(RM) -r valgrind/bin
69 clean: clean-except-prove-cache
70 $(RM) .prove
72 clean-chainlint:
73 $(RM) -r '$(CHAINLINTTMP_SQ)'
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
82 test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
83 test-lint-filenames
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; }
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; }
95 test-lint-shell-syntax:
96 @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF)
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; }
106 aggregate-results-and-cleanup: $(T)
107 $(MAKE) aggregate-results
108 $(MAKE) clean
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
115 gitweb-test:
116 $(MAKE) $(TGITWEB)
118 valgrind:
119 $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
121 perf:
122 $(MAKE) -C perf/ all
124 .PHONY: pre-clean $(T) aggregate-results clean valgrind perf check-chainlint clean-chainlint