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