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