t / Makefileon commit Merge branch 'pe/doc-email-env-is-trumped-by-config' (e928b70)
   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
  10SHELL_PATH ?= $(SHELL)
  11PERL_PATH ?= /usr/bin/perl
  12TAR ?= $(TAR)
  13RM ?= rm -f
  14PROVE ?= prove
  15DEFAULT_TEST_TARGET ?= test
  16TEST_LINT ?= test-lint-duplicates test-lint-executable
  17
  18# Shell quote;
  19SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  20PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
  21
  22T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
  23TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
  24TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
  25
  26all: $(DEFAULT_TEST_TARGET)
  27
  28test: pre-clean $(TEST_LINT)
  29        $(MAKE) aggregate-results-and-cleanup
  30
  31prove: pre-clean $(TEST_LINT)
  32        @echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
  33        $(MAKE) clean-except-prove-cache
  34
  35$(T):
  36        @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
  37
  38pre-clean:
  39        $(RM) -r test-results
  40
  41clean-except-prove-cache:
  42        $(RM) -r 'trash directory'.* test-results
  43        $(RM) -r valgrind/bin
  44
  45clean: clean-except-prove-cache
  46        $(RM) .prove
  47
  48test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax
  49
  50test-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
  55test-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
  60test-lint-shell-syntax:
  61        @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T)
  62
  63aggregate-results-and-cleanup: $(T)
  64        $(MAKE) aggregate-results
  65        $(MAKE) clean
  66
  67aggregate-results:
  68        for f in test-results/t*-*.counts; do \
  69                echo "$$f"; \
  70        done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
  71
  72# we can test NO_OPTIMIZE_COMMITS independently of LC_ALL
  73full-svn-test:
  74        $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C
  75        $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8
  76
  77gitweb-test:
  78        $(MAKE) $(TGITWEB)
  79
  80valgrind:
  81        $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
  82
  83perf:
  84        $(MAKE) -C perf/ all
  85
  86# Smoke testing targets
  87-include ../GIT-VERSION-FILE
  88uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo unknown')
  89uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo unknown')
  90
  91test-results:
  92        mkdir -p test-results
  93
  94test-results/git-smoke.tar.gz: test-results
  95        '$(PERL_PATH_SQ)' ./harness \
  96                --archive="test-results/git-smoke.tar.gz" \
  97                $(T)
  98
  99smoke: test-results/git-smoke.tar.gz
 100
 101SMOKE_UPLOAD_FLAGS =
 102ifdef SMOKE_USERNAME
 103        SMOKE_UPLOAD_FLAGS += -F username="$(SMOKE_USERNAME)" -F password="$(SMOKE_PASSWORD)"
 104endif
 105ifdef SMOKE_COMMENT
 106        SMOKE_UPLOAD_FLAGS += -F comments="$(SMOKE_COMMENT)"
 107endif
 108ifdef SMOKE_TAGS
 109        SMOKE_UPLOAD_FLAGS += -F tags="$(SMOKE_TAGS)"
 110endif
 111
 112smoke_report: smoke
 113        curl \
 114                -H "Expect: " \
 115                -F project=Git \
 116                -F architecture="$(uname_M)" \
 117                -F platform="$(uname_S)" \
 118                -F revision="$(GIT_VERSION)" \
 119                -F report_file=@test-results/git-smoke.tar.gz \
 120                $(SMOKE_UPLOAD_FLAGS) \
 121                http://smoke.git.nix.is/app/projects/process_add_report/1 \
 122        | grep -v ^Redirecting
 123
 124.PHONY: pre-clean $(T) aggregate-results clean valgrind perf