Merge branch 'jc/merge-blobs' into maint
[git] / t / Makefile
1 # Run tests
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 -include ../config.mak.autogen
7 -include ../config.mak
8
9 #GIT_TEST_OPTS = --verbose --debug
10 SHELL_PATH ?= $(SHELL)
11 PERL_PATH ?= /usr/bin/perl
12 TAR ?= $(TAR)
13 RM ?= rm -f
14 PROVE ?= prove
15 DEFAULT_TEST_TARGET ?= test
16 TEST_LINT ?= test-lint-duplicates test-lint-executable
17
18 # Shell quote;
19 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
20
21 T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
22 TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
23 TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
24
25 all: $(DEFAULT_TEST_TARGET)
26
27 test: pre-clean $(TEST_LINT)
28         $(MAKE) aggregate-results-and-cleanup
29
30 prove: pre-clean $(TEST_LINT)
31         @echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
32         $(MAKE) clean-except-prove-cache
33
34 $(T):
35         @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
36
37 pre-clean:
38         $(RM) -r test-results
39
40 clean-except-prove-cache:
41         $(RM) -r 'trash directory'.* test-results
42         $(RM) -r valgrind/bin
43
44 clean: clean-except-prove-cache
45         $(RM) .prove
46
47 test-lint: test-lint-duplicates test-lint-executable
48
49 test-lint-duplicates:
50         @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
51                 test -z "$$dups" || { \
52                 echo >&2 "duplicate test numbers:" $$dups; exit 1; }
53
54 test-lint-executable:
55         @bad=`for i in $(T); do test -x "$$i" || echo $$i; done` && \
56                 test -z "$$bad" || { \
57                 echo >&2 "non-executable tests:" $$bad; exit 1; }
58
59 aggregate-results-and-cleanup: $(T)
60         $(MAKE) aggregate-results
61         $(MAKE) clean
62
63 aggregate-results:
64         for f in test-results/t*-*.counts; do \
65                 echo "$$f"; \
66         done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
67
68 # we can test NO_OPTIMIZE_COMMITS independently of LC_ALL
69 full-svn-test:
70         $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C
71         $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8
72
73 gitweb-test:
74         $(MAKE) $(TGITWEB)
75
76 valgrind:
77         $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
78
79 perf:
80         $(MAKE) -C perf/ all
81
82 # Smoke testing targets
83 -include ../GIT-VERSION-FILE
84 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo unknown')
85 uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo unknown')
86
87 test-results:
88         mkdir -p test-results
89
90 test-results/git-smoke.tar.gz: test-results
91         $(PERL_PATH) ./harness \
92                 --archive="test-results/git-smoke.tar.gz" \
93                 $(T)
94
95 smoke: test-results/git-smoke.tar.gz
96
97 SMOKE_UPLOAD_FLAGS =
98 ifdef SMOKE_USERNAME
99         SMOKE_UPLOAD_FLAGS += -F username="$(SMOKE_USERNAME)" -F password="$(SMOKE_PASSWORD)"
100 endif
101 ifdef SMOKE_COMMENT
102         SMOKE_UPLOAD_FLAGS += -F comments="$(SMOKE_COMMENT)"
103 endif
104 ifdef SMOKE_TAGS
105         SMOKE_UPLOAD_FLAGS += -F tags="$(SMOKE_TAGS)"
106 endif
107
108 smoke_report: smoke
109         curl \
110                 -H "Expect: " \
111                 -F project=Git \
112                 -F architecture="$(uname_M)" \
113                 -F platform="$(uname_S)" \
114                 -F revision="$(GIT_VERSION)" \
115                 -F report_file=@test-results/git-smoke.tar.gz \
116                 $(SMOKE_UPLOAD_FLAGS) \
117                 http://smoke.git.nix.is/app/projects/process_add_report/1 \
118         | grep -v ^Redirecting
119
120 .PHONY: pre-clean $(T) aggregate-results clean valgrind perf