t / Makefileon commit sha1-file.c: mark more strings for translation (259328b)
   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)
  11TEST_SHELL_PATH ?= $(SHELL_PATH)
  12PERL_PATH ?= /usr/bin/perl
  13TAR ?= $(TAR)
  14RM ?= rm -f
  15PROVE ?= prove
  16DEFAULT_TEST_TARGET ?= test
  17TEST_LINT ?= test-lint
  18
  19ifdef TEST_OUTPUT_DIRECTORY
  20TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
  21else
  22TEST_RESULTS_DIRECTORY = test-results
  23endif
  24
  25# Shell quote;
  26SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  27TEST_SHELL_PATH_SQ = $(subst ','\'',$(TEST_SHELL_PATH))
  28PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
  29TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
  30
  31T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
  32TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
  33THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
  34
  35all: $(DEFAULT_TEST_TARGET)
  36
  37test: pre-clean $(TEST_LINT)
  38        $(MAKE) aggregate-results-and-cleanup
  39
  40failed:
  41        @failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
  42                grep -l '^failed [1-9]' *.counts | \
  43                sed -n 's/\.counts$$/.sh/p') && \
  44        test -z "$$failed" || $(MAKE) $$failed
  45
  46prove: pre-clean $(TEST_LINT)
  47        @echo "*** prove ***"; $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
  48        $(MAKE) clean-except-prove-cache
  49
  50$(T):
  51        @echo "*** $@ ***"; '$(TEST_SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
  52
  53pre-clean:
  54        $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
  55
  56clean-except-prove-cache:
  57        $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
  58        $(RM) -r valgrind/bin
  59
  60clean: clean-except-prove-cache
  61        $(RM) .prove
  62
  63test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
  64        test-lint-filenames
  65
  66test-lint-duplicates:
  67        @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
  68                test -z "$$dups" || { \
  69                echo >&2 "duplicate test numbers:" $$dups; exit 1; }
  70
  71test-lint-executable:
  72        @bad=`for i in $(T); do test -x "$$i" || echo $$i; done` && \
  73                test -z "$$bad" || { \
  74                echo >&2 "non-executable tests:" $$bad; exit 1; }
  75
  76test-lint-shell-syntax:
  77        @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS)
  78
  79test-lint-filenames:
  80        @# We do *not* pass a glob to ls-files but use grep instead, to catch
  81        @# non-ASCII characters (which are quoted within double-quotes)
  82        @bad="$$(git -c core.quotepath=true ls-files 2>/dev/null | \
  83                        grep '["*:<>?\\|]')"; \
  84                test -z "$$bad" || { \
  85                echo >&2 "non-portable file name(s): $$bad"; exit 1; }
  86
  87aggregate-results-and-cleanup: $(T)
  88        $(MAKE) aggregate-results
  89        $(MAKE) clean
  90
  91aggregate-results:
  92        for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
  93                echo "$$f"; \
  94        done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
  95
  96gitweb-test:
  97        $(MAKE) $(TGITWEB)
  98
  99valgrind:
 100        $(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind"
 101
 102perf:
 103        $(MAKE) -C perf/ all
 104
 105.PHONY: pre-clean $(T) aggregate-results clean valgrind perf