interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / Makefile

216 lines · 6977 bytes Raw Blame History
1# The default target of this Makefile is...
2all::
3
4# Import tree-wide shared Makefile behavior and libraries
5include ../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
17SHELL_PATH ?= $(SHELL)
18TEST_SHELL_PATH ?= $(SHELL_PATH)
19PERL_PATH ?= /usr/bin/perl
20TAR ?= $(TAR)
21RM ?= rm -f
22PROVE ?= prove
23DEFAULT_TEST_TARGET ?= test
24DEFAULT_UNIT_TEST_TARGET ?= unit-tests-raw
25TEST_LINT ?= test-lint
26
27ifdef TEST_OUTPUT_DIRECTORY
28TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
29CHAINLINTTMP = $(TEST_OUTPUT_DIRECTORY)/chainlinttmp
30GREPLINTTMP = $(TEST_OUTPUT_DIRECTORY)/greplinttmp
31else
32TEST_RESULTS_DIRECTORY = test-results
33CHAINLINTTMP = chainlinttmp
34GREPLINTTMP = greplinttmp
35endif
36
37# Shell quote;
38SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
39TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH))
40PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
41TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
42CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
43GREPLINTTMP_SQ = $(subst ','\'',$(GREPLINTTMP))
44
45T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
46THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
47TLIBS = $(sort $(wildcard lib-*.sh)) annotate-tests.sh
48TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
49TINTEROP = $(sort $(wildcard interop/i[0-9][0-9][0-9][0-9]-*.sh))
50CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
51GREPLINTTESTS = $(sort $(patsubst greplint/%.test,%,$(wildcard greplint/*.test)))
52CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
53UNIT_TEST_SOURCES = $(wildcard unit-tests/t-*.c)
54UNIT_TEST_PROGRAMS = $(patsubst unit-tests/%.c,unit-tests/bin/%$(X),$(UNIT_TEST_SOURCES))
55UNIT_TEST_PROGRAMS += unit-tests/bin/unit-tests$(X)
56UNIT_TESTS = $(sort $(UNIT_TEST_PROGRAMS))
57UNIT_TESTS_NO_DIR = $(notdir $(UNIT_TESTS))
58
59# `test-chainlint` (which is a dependency of `test-lint`, `test` and `prove`)
60# checks all tests in all scripts via a single invocation, so tell individual
61# scripts not to run the external "chainlint.pl" script themselves
62CHAINLINTSUPPRESS = GIT_TEST_EXT_CHAIN_LINT=0 && export GIT_TEST_EXT_CHAIN_LINT &&
63
64all:: $(DEFAULT_TEST_TARGET)
65
66test: pre-clean check-meson $(TEST_LINT)
67 $(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
68
69ifneq ($(PERL_PATH),)
70test: check-chainlint check-greplint
71prove: check-chainlint check-greplint
72endif
73
74failed:
75 @failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
76 grep -l '^failed [1-9]' *.counts | \
77 sed -n 's/\.counts$$/.sh/p') && \
78 test -z "$$failed" || $(MAKE) $$failed
79
80prove: pre-clean $(TEST_LINT)
81 @echo "*** prove (shell & unit tests) ***"
82 @$(CHAINLINTSUPPRESS) TEST_OPTIONS='$(GIT_TEST_OPTS)' TEST_SHELL_PATH='$(TEST_SHELL_PATH_SQ)' $(PROVE) --exec ./run-test.sh $(GIT_PROVE_OPTS) $(T) $(UNIT_TESTS)
83 $(MAKE) clean-except-prove-cache
84
85$(T):
86 @echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
87
88$(UNIT_TESTS):
89 @echo "*** $@ ***"; $@
90
91.PHONY: unit-tests unit-tests-raw unit-tests-prove unit-tests-test-tool
92unit-tests: $(DEFAULT_UNIT_TEST_TARGET)
93
94unit-tests-raw: $(UNIT_TESTS)
95
96unit-tests-prove:
97 @echo "*** prove - unit tests ***"; $(PROVE) $(GIT_PROVE_OPTS) $(UNIT_TESTS)
98
99unit-tests-test-tool:
100 @echo "*** test-tool - unit tests **"
101 ( \
102 cd unit-tests/bin && \
103 ../../helper/test-tool$X run-command testsuite $(UNIT_TESTS_NO_DIR)\
104 )
105
106pre-clean:
107 $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
108
109clean-except-prove-cache: clean-chainlint clean-greplint
110 $(RM) -r 'trash directory'.*
111 $(RM) -r valgrind/bin
112
113clean: clean-except-prove-cache
114 $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
115 $(RM) -r mesontmp
116 $(RM) .prove
117
118clean-chainlint:
119 $(RM) -r '$(CHAINLINTTMP_SQ)'
120
121check-chainlint:
122 @mkdir -p '$(CHAINLINTTMP_SQ)' && \
123 '$(PERL_PATH_SQ)' chainlint-cat.pl '$(CHAINLINTTMP_SQ)' $(CHAINLINTTESTS) && \
124 { $(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests >'$(CHAINLINTTMP_SQ)'/actual || true; } && \
125 diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
126
127clean-greplint:
128 $(RM) -r '$(GREPLINTTMP_SQ)'
129
130check-greplint:
131 @mkdir -p '$(GREPLINTTMP_SQ)' && \
132 '$(PERL_PATH_SQ)' greplint-cat.pl '$(GREPLINTTMP_SQ)' $(GREPLINTTESTS) && \
133 { '$(PERL_PATH_SQ)' greplint.pl \
134 $(patsubst %,greplint/%.test,$(GREPLINTTESTS)) \
135 >'$(GREPLINTTMP_SQ)'/actual 2>&1 || true; } && \
136 diff -u '$(GREPLINTTMP_SQ)'/expect '$(GREPLINTTMP_SQ)'/actual
137
138check-meson:
139 @# awk acts up when trying to match single quotes, so we use \047 instead.
140 @mkdir -p mesontmp && \
141 printf "%s\n" \
142 "integration_tests t[0-9][0-9][0-9][0-9]-*.sh" \
143 "clar_test_suites unit-tests/u-*.c" | \
144 while read -r variable pattern; do \
145 awk "/^$$variable = \[\$$/ {flag=1 ; next } /^]$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047,\$$/, \"\"); print }" meson.build >mesontmp/meson.txt && \
146 ls $$pattern >mesontmp/actual.txt && \
147 if ! cmp mesontmp/meson.txt mesontmp/actual.txt; then \
148 echo "Meson tests differ from actual tests:"; \
149 diff -u mesontmp/meson.txt mesontmp/actual.txt; \
150 exit 1; \
151 fi; \
152 done
153
154test-lint: test-lint-duplicates test-lint-executable \
155 test-lint-filenames
156ifneq ($(PERL_PATH),)
157test-lint: test-lint-shell-syntax test-greplint
158else
159GIT_TEST_CHAIN_LINT = 0
160endif
161ifneq ($(GIT_TEST_CHAIN_LINT),0)
162test-lint: test-chainlint
163endif
164
165test-lint-duplicates:
166 @dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
167 test -z "$$dups" || { \
168 echo >&2 "duplicate test numbers:" $$dups; exit 1; }
169
170test-lint-executable:
171 @bad=`for i in $(T) $(TPERF); do test -x "$$i" || echo $$i; done` && \
172 test -z "$$bad" || { \
173 echo >&2 "non-executable tests:" $$bad; exit 1; }
174
175test-lint-shell-syntax:
176 @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF)
177
178test-greplint:
179 @'$(PERL_PATH_SQ)' greplint.pl $(T) $(THELPERS) $(TPERF)
180
181test-lint-filenames:
182 @# We do *not* pass a glob to ls-files but use grep instead, to catch
183 @# non-ASCII characters (which are quoted within double-quotes)
184 @bad="$$(git -c core.quotepath=true ls-files 2>/dev/null | \
185 grep '["*:<>?\\|]')"; \
186 test -z "$$bad" || { \
187 echo >&2 "non-portable file name(s): $$bad"; exit 1; }
188
189test-chainlint:
190 @$(CHAINLINT) $(T) $(TLIBS) $(TPERF) $(TINTEROP)
191
192aggregate-results-and-cleanup: $(T)
193 $(MAKE) aggregate-results
194 $(MAKE) clean
195
196aggregate-results:
197 @'$(SHELL_PATH_SQ)' ./aggregate-results.sh '$(TEST_RESULTS_DIRECTORY_SQ)'
198
199valgrind:
200 $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
201
202perf:
203 $(MAKE) -C perf/ all
204
205.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
206 check-chainlint clean-chainlint test-chainlint \
207 check-greplint clean-greplint test-greplint $(UNIT_TESTS)
208
209.PHONY: libgit-sys-test libgit-rs-test
210libgit-sys-test:
211 $(QUIET)cargo test --manifest-path ../contrib/libgit-sys/Cargo.toml
212libgit-rs-test: libgit-sys-test
213 $(QUIET)cargo test --manifest-path ../contrib/libgit-rs/Cargo.toml
214ifdef INCLUDE_LIBGIT_RS
215all:: libgit-rs-test
216endif