git

Форк
0
/t
/
Makefile 
159 строк · 5.0 Кб
1
# The default target of this Makefile is...
2
all::
3

4
# Import tree-wide shared Makefile behavior and libraries
5
include ../shared.mak
6

7
# Run tests
8
#
9
# Copyright (c) 2005 Junio C Hamano
10
#
11

12
-include ../config.mak.uname
13
-include ../config.mak.autogen
14
-include ../config.mak
15

16
#GIT_TEST_OPTS = --verbose --debug
17
SHELL_PATH ?= $(SHELL)
18
TEST_SHELL_PATH ?= $(SHELL_PATH)
19
PERL_PATH ?= /usr/bin/perl
20
TAR ?= $(TAR)
21
RM ?= rm -f
22
PROVE ?= prove
23
DEFAULT_TEST_TARGET ?= test
24
DEFAULT_UNIT_TEST_TARGET ?= unit-tests-raw
25
TEST_LINT ?= test-lint
26

27
ifdef TEST_OUTPUT_DIRECTORY
28
TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
29
CHAINLINTTMP = $(TEST_OUTPUT_DIRECTORY)/chainlinttmp
30
else
31
TEST_RESULTS_DIRECTORY = test-results
32
CHAINLINTTMP = chainlinttmp
33
endif
34

35
# Shell quote;
36
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
37
TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH))
38
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
39
TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
40
CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
41

42
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
43
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
44
TLIBS = $(sort $(wildcard lib-*.sh)) annotate-tests.sh
45
TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
46
TINTEROP = $(sort $(wildcard interop/i[0-9][0-9][0-9][0-9]-*.sh))
47
CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
48
CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
49
UNIT_TEST_SOURCES = $(wildcard unit-tests/t-*.c)
50
UNIT_TEST_PROGRAMS = $(patsubst unit-tests/%.c,unit-tests/bin/%$(X),$(UNIT_TEST_SOURCES))
51
UNIT_TESTS = $(sort $(UNIT_TEST_PROGRAMS))
52
UNIT_TESTS_NO_DIR = $(notdir $(UNIT_TESTS))
53

54
# `test-chainlint` (which is a dependency of `test-lint`, `test` and `prove`)
55
# checks all tests in all scripts via a single invocation, so tell individual
56
# scripts not to run the external "chainlint.pl" script themselves
57
CHAINLINTSUPPRESS = GIT_TEST_EXT_CHAIN_LINT=0 && export GIT_TEST_EXT_CHAIN_LINT &&
58

59
all:: $(DEFAULT_TEST_TARGET)
60

61
test: pre-clean check-chainlint $(TEST_LINT)
62
	$(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
63

64
failed:
65
	@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
66
		grep -l '^failed [1-9]' *.counts | \
67
		sed -n 's/\.counts$$/.sh/p') && \
68
	test -z "$$failed" || $(MAKE) $$failed
69

70
prove: pre-clean check-chainlint $(TEST_LINT)
71
	@echo "*** prove (shell & unit tests) ***"; $(CHAINLINTSUPPRESS) TEST_SHELL_PATH='$(TEST_SHELL_PATH_SQ)' $(PROVE) --exec ./run-test.sh $(GIT_PROVE_OPTS) $(T) $(UNIT_TESTS) :: $(GIT_TEST_OPTS)
72
	$(MAKE) clean-except-prove-cache
73

74
$(T):
75
	@echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
76

77
$(UNIT_TESTS):
78
	@echo "*** $@ ***"; $@
79

80
.PHONY: unit-tests unit-tests-raw unit-tests-prove unit-tests-test-tool
81
unit-tests: $(DEFAULT_UNIT_TEST_TARGET)
82

83
unit-tests-raw: $(UNIT_TESTS)
84

85
unit-tests-prove:
86
	@echo "*** prove - unit tests ***"; $(PROVE) $(GIT_PROVE_OPTS) $(UNIT_TESTS)
87

88
unit-tests-test-tool:
89
	@echo "*** test-tool - unit tests **"
90
	( \
91
		cd unit-tests/bin && \
92
		../../helper/test-tool$X run-command testsuite $(UNIT_TESTS_NO_DIR)\
93
	)
94

95
pre-clean:
96
	$(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
97

98
clean-except-prove-cache: clean-chainlint
99
	$(RM) -r 'trash directory'.*
100
	$(RM) -r valgrind/bin
101

102
clean: clean-except-prove-cache
103
	$(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
104
	$(RM) .prove
105

106
clean-chainlint:
107
	$(RM) -r '$(CHAINLINTTMP_SQ)'
108

109
check-chainlint:
110
	@mkdir -p '$(CHAINLINTTMP_SQ)' && \
111
	'$(PERL_PATH_SQ)' chainlint-cat.pl '$(CHAINLINTTMP_SQ)' $(CHAINLINTTESTS) && \
112
	{ $(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests >'$(CHAINLINTTMP_SQ)'/actual || true; } && \
113
	diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
114

115
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
116
	test-lint-filenames
117
ifneq ($(GIT_TEST_CHAIN_LINT),0)
118
test-lint: test-chainlint
119
endif
120

121
test-lint-duplicates:
122
	@dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
123
		test -z "$$dups" || { \
124
		echo >&2 "duplicate test numbers:" $$dups; exit 1; }
125

126
test-lint-executable:
127
	@bad=`for i in $(T) $(TPERF); do test -x "$$i" || echo $$i; done` && \
128
		test -z "$$bad" || { \
129
		echo >&2 "non-executable tests:" $$bad; exit 1; }
130

131
test-lint-shell-syntax:
132
	@'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF)
133

134
test-lint-filenames:
135
	@# We do *not* pass a glob to ls-files but use grep instead, to catch
136
	@# non-ASCII characters (which are quoted within double-quotes)
137
	@bad="$$(git -c core.quotepath=true ls-files 2>/dev/null | \
138
			grep '["*:<>?\\|]')"; \
139
		test -z "$$bad" || { \
140
		echo >&2 "non-portable file name(s): $$bad"; exit 1; }
141

142
test-chainlint:
143
	@$(CHAINLINT) $(T) $(TLIBS) $(TPERF) $(TINTEROP)
144

145
aggregate-results-and-cleanup: $(T)
146
	$(MAKE) aggregate-results
147
	$(MAKE) clean
148

149
aggregate-results:
150
	@'$(SHELL_PATH_SQ)' ./aggregate-results.sh '$(TEST_RESULTS_DIRECTORY_SQ)'
151

152
valgrind:
153
	$(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
154

155
perf:
156
	$(MAKE) -C perf/ all
157

158
.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
159
	check-chainlint clean-chainlint test-chainlint $(UNIT_TESTS)
160

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.