t / Makefileon commit Merge branch 'master' of git://github.com/git-l10n/git-po (2cd14f6)
   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))
  20
  21T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
  22TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
  23TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
  24
  25all: $(DEFAULT_TEST_TARGET)
  26
  27test: pre-clean $(TEST_LINT)
  28        $(MAKE) aggregate-results-and-cleanup
  29
  30prove: 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
  37pre-clean:
  38        $(RM) -r test-results
  39
  40clean-except-prove-cache:
  41        $(RM) -r 'trash directory'.* test-results
  42        $(RM) -r valgrind/bin
  43
  44clean: clean-except-prove-cache
  45        $(RM) .prove
  46
  47test-lint: test-lint-duplicates test-lint-executable
  48
  49test-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
  54test-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
  59aggregate-results-and-cleanup: $(T)
  60        $(MAKE) aggregate-results
  61        $(MAKE) clean
  62
  63aggregate-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
  69full-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
  73gitweb-test:
  74        $(MAKE) $(TGITWEB)
  75
  76valgrind:
  77        $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
  78
  79perf:
  80        $(MAKE) -C perf/ all
  81
  82# Smoke testing targets
  83-include ../GIT-VERSION-FILE
  84uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo unknown')
  85uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo unknown')
  86
  87test-results:
  88        mkdir -p test-results
  89
  90test-results/git-smoke.tar.gz: test-results
  91        $(PERL_PATH) ./harness \
  92                --archive="test-results/git-smoke.tar.gz" \
  93                $(T)
  94
  95smoke: test-results/git-smoke.tar.gz
  96
  97SMOKE_UPLOAD_FLAGS =
  98ifdef SMOKE_USERNAME
  99        SMOKE_UPLOAD_FLAGS += -F username="$(SMOKE_USERNAME)" -F password="$(SMOKE_PASSWORD)"
 100endif
 101ifdef SMOKE_COMMENT
 102        SMOKE_UPLOAD_FLAGS += -F comments="$(SMOKE_COMMENT)"
 103endif
 104ifdef SMOKE_TAGS
 105        SMOKE_UPLOAD_FLAGS += -F tags="$(SMOKE_TAGS)"
 106endif
 107
 108smoke_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