]> git.ipfire.org Git - thirdparty/git.git/blob - contrib/scalar/t/Makefile
clone: allow "--bare" with "-o"
[thirdparty/git.git] / contrib / scalar / t / Makefile
1 # Import tree-wide shared Makefile behavior and libraries
2 include ../../../shared.mak
3
4 # Run scalar tests
5 #
6 # Copyright (c) 2005,2021 Junio C Hamano, Johannes Schindelin
7 #
8
9 -include ../../../config.mak.autogen
10 -include ../../../config.mak
11
12 SHELL_PATH ?= $(SHELL)
13 PERL_PATH ?= /usr/bin/perl
14 RM ?= rm -f
15 PROVE ?= prove
16 DEFAULT_TEST_TARGET ?= test
17 TEST_LINT ?= test-lint
18
19 ifdef TEST_OUTPUT_DIRECTORY
20 TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
21 else
22 TEST_RESULTS_DIRECTORY = ../../../t/test-results
23 endif
24
25 # Shell quote;
26 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
27 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
28 TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
29
30 T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
31
32 all: $(DEFAULT_TEST_TARGET)
33
34 test: $(TEST_LINT)
35 $(MAKE) aggregate-results-and-cleanup
36
37 prove: $(TEST_LINT)
38 @echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
39 $(MAKE) clean-except-prove-cache
40
41 $(T):
42 @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
43
44 clean-except-prove-cache:
45 $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
46 $(RM) -r valgrind/bin
47
48 clean: clean-except-prove-cache
49 $(RM) .prove
50
51 test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax
52
53 test-lint-duplicates:
54 @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
55 test -z "$$dups" || { \
56 echo >&2 "duplicate test numbers:" $$dups; exit 1; }
57
58 test-lint-executable:
59 @bad=`for i in $(T); do test -x "$$i" || echo $$i; done` && \
60 test -z "$$bad" || { \
61 echo >&2 "non-executable tests:" $$bad; exit 1; }
62
63 test-lint-shell-syntax:
64 @'$(PERL_PATH_SQ)' ../../../t/check-non-portable-shell.pl $(T)
65
66 aggregate-results-and-cleanup: $(T)
67 $(MAKE) aggregate-results
68 $(MAKE) clean
69
70 aggregate-results:
71 for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
72 echo "$$f"; \
73 done | '$(SHELL_PATH_SQ)' ../../../t/aggregate-results.sh
74
75 valgrind:
76 $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
77
78 test-results:
79 mkdir -p test-results
80
81 .PHONY: $(T) aggregate-results clean valgrind