Merge branch 'jk/test-output'
authorJunio C Hamano <gitster@pobox.com>
Wed, 29 May 2013 21:29:11 +0000 (14:29 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 May 2013 21:29:11 +0000 (14:29 -0700)
When TEST_OUTPUT_DIRECTORY setting is used, it was handled somewhat
inconsistently between the test framework and t/Makefile, and logic
to summarize the results looked at a wrong place.

* jk/test-output:
t/Makefile: don't define TEST_RESULTS_DIRECTORY recursively
test output: respect $TEST_OUTPUT_DIRECTORY
t/Makefile: fix result handling with TEST_OUTPUT_DIRECTORY

1  2 
Makefile
t/Makefile
t/test-lib.sh
diff --combined Makefile
index 7e44b67599daeae05526ea0d876233b7014cbc83,ef5be0ff70fd316527922138945f818499614c09..1a31f65bfdf0740f431ddb397aba64dae96cede2
+++ b/Makefile
@@@ -358,39 -358,33 +358,39 @@@ STRIP ?= stri
  # Among the variables below, these:
  #   gitexecdir
  #   template_dir
 -#   mandir
 -#   infodir
 -#   htmldir
  #   sysconfdir
  # can be specified as a relative path some/where/else;
  # this is interpreted as relative to $(prefix) and "git" at
  # runtime figures out where they are based on the path to the executable.
 +# Additionally, the following will be treated as relative by "git" if they
 +# begin with "$(prefix)/":
 +#   mandir
 +#   infodir
 +#   htmldir
  # This can help installing the suite in a relocatable way.
  
  prefix = $(HOME)
  bindir_relative = bin
  bindir = $(prefix)/$(bindir_relative)
 -mandir = share/man
 -infodir = share/info
 +mandir = $(prefix)/share/man
 +infodir = $(prefix)/share/info
  gitexecdir = libexec/git-core
  mergetoolsdir = $(gitexecdir)/mergetools
  sharedir = $(prefix)/share
  gitwebdir = $(sharedir)/gitweb
  localedir = $(sharedir)/locale
  template_dir = share/git-core/templates
 -htmldir = share/doc/git-doc
 +htmldir = $(prefix)/share/doc/git-doc
  ETC_GITCONFIG = $(sysconfdir)/gitconfig
  ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
  lib = lib
  # DESTDIR =
  pathsep = :
  
 +mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))
 +infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))
 +htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
 +
  export prefix bindir sharedir sysconfdir gitwebdir localedir
  
  CC = cc
@@@ -460,7 -454,6 +460,7 @@@ SCRIPT_SH += git-mergetool.s
  SCRIPT_SH += git-pull.sh
  SCRIPT_SH += git-quiltimport.sh
  SCRIPT_SH += git-rebase.sh
 +SCRIPT_SH += git-remote-testgit.sh
  SCRIPT_SH += git-repack.sh
  SCRIPT_SH += git-request-pull.sh
  SCRIPT_SH += git-stash.sh
@@@ -685,6 -678,7 +685,6 @@@ LIB_H += notes-cache.
  LIB_H += notes-merge.h
  LIB_H += notes.h
  LIB_H += object.h
 -LIB_H += pack-refs.h
  LIB_H += pack-revindex.h
  LIB_H += pack.h
  LIB_H += parse-options.h
@@@ -817,6 -811,7 +817,6 @@@ LIB_OBJS += notes-cache.
  LIB_OBJS += notes-merge.o
  LIB_OBJS += object.o
  LIB_OBJS += pack-check.o
 -LIB_OBJS += pack-refs.o
  LIB_OBJS += pack-revindex.o
  LIB_OBJS += pack-write.o
  LIB_OBJS += pager.o
@@@ -1544,12 -1539,12 +1544,12 @@@ ETC_GITATTRIBUTES_SQ = $(subst ','\'',$
  DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
  bindir_SQ = $(subst ','\'',$(bindir))
  bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
 -mandir_SQ = $(subst ','\'',$(mandir))
 -infodir_SQ = $(subst ','\'',$(infodir))
 +mandir_relative_SQ = $(subst ','\'',$(mandir_relative))
 +infodir_relative_SQ = $(subst ','\'',$(infodir_relative))
  localedir_SQ = $(subst ','\'',$(localedir))
  gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
  template_dir_SQ = $(subst ','\'',$(template_dir))
 -htmldir_SQ = $(subst ','\'',$(htmldir))
 +htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
  prefix_SQ = $(subst ','\'',$(prefix))
  gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
  
@@@ -1681,9 -1676,9 +1681,9 @@@ strip: $(PROGRAMS) git$
  
  git.sp git.s git.o: GIT-PREFIX
  git.sp git.s git.o: EXTRA_CPPFLAGS = \
 -      '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
 -      '-DGIT_MAN_PATH="$(mandir_SQ)"' \
 -      '-DGIT_INFO_PATH="$(infodir_SQ)"'
 +      '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \
 +      '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \
 +      '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
  
  git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
@@@ -1693,9 -1688,9 +1693,9 @@@ help.sp help.s help.o: common-cmds.
  
  builtin/help.sp builtin/help.s builtin/help.o: common-cmds.h GIT-PREFIX
  builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
 -      '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
 -      '-DGIT_MAN_PATH="$(mandir_SQ)"' \
 -      '-DGIT_INFO_PATH="$(infodir_SQ)"'
 +      '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \
 +      '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \
 +      '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
  
  version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
  version.sp version.s version.o: EXTRA_CPPFLAGS = \
@@@ -2003,7 -1998,6 +2003,7 @@@ endi
  ifdef USE_NED_ALLOCATOR
  compat/nedmalloc/nedmalloc.sp compat/nedmalloc/nedmalloc.o: EXTRA_CPPFLAGS = \
        -DNDEBUG -DOVERRIDE_STRDUP -DREPLACE_SYSTEM_ALLOCATOR
 +compat/nedmalloc/nedmalloc.sp: SPARSE_FLAGS += -Wno-non-pointer-null
  endif
  
  git-%$X: %.o GIT-LDFLAGS $(GITLIBS)
@@@ -2159,6 -2153,9 +2159,9 @@@ GIT-BUILD-OPTIONS: FORC
        @echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
        @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
        @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@
+ ifdef TEST_OUTPUT_DIRECTORY
+       @echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@
+ endif
  ifdef GIT_TEST_OPTS
        @echo GIT_TEST_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_OPTS)))'\' >>$@
  endif
diff --combined t/Makefile
index 44ca7d32dc7b1165712ad24784e14b34f3bf0c51,ebb73719cb791d96d29eed239c15d32dbdb2bd77..2373a04f7aecab62b8575f8564020b10fb874843
@@@ -15,9 -15,16 +15,16 @@@ PROVE ?= prov
  DEFAULT_TEST_TARGET ?= test
  TEST_LINT ?= test-lint-duplicates test-lint-executable
  
+ ifdef TEST_OUTPUT_DIRECTORY
+ TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
+ else
+ TEST_RESULTS_DIRECTORY = test-results
+ endif
  # Shell quote;
  SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
  PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
+ TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
  
  T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
  TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
@@@ -36,10 -43,10 +43,10 @@@ $(T)
        @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
  
  pre-clean:
-       $(RM) -r test-results
+       $(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
  
  clean-except-prove-cache:
-       $(RM) -r 'trash directory'.* test-results
+       $(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
        $(RM) -r valgrind/bin
  
  clean: clean-except-prove-cache
@@@ -65,7 -72,7 +72,7 @@@ aggregate-results-and-cleanup: $(T
        $(MAKE) clean
  
  aggregate-results:
-       for f in test-results/t*-*.counts; do \
+       for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
                echo "$$f"; \
        done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
  
@@@ -83,4 -90,42 +90,4 @@@ valgrind
  perf:
        $(MAKE) -C perf/ all
  
 -# Smoke testing targets
 --include ../GIT-VERSION-FILE
 -uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo unknown')
 -uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo unknown')
 -
 -test-results:
 -      mkdir -p test-results
 -
 -test-results/git-smoke.tar.gz: test-results
 -      '$(PERL_PATH_SQ)' ./harness \
 -              --archive="test-results/git-smoke.tar.gz" \
 -              $(T)
 -
 -smoke: test-results/git-smoke.tar.gz
 -
 -SMOKE_UPLOAD_FLAGS =
 -ifdef SMOKE_USERNAME
 -      SMOKE_UPLOAD_FLAGS += -F username="$(SMOKE_USERNAME)" -F password="$(SMOKE_PASSWORD)"
 -endif
 -ifdef SMOKE_COMMENT
 -      SMOKE_UPLOAD_FLAGS += -F comments="$(SMOKE_COMMENT)"
 -endif
 -ifdef SMOKE_TAGS
 -      SMOKE_UPLOAD_FLAGS += -F tags="$(SMOKE_TAGS)"
 -endif
 -
 -smoke_report: smoke
 -      curl \
 -              -H "Expect: " \
 -              -F project=Git \
 -              -F architecture="$(uname_M)" \
 -              -F platform="$(uname_S)" \
 -              -F revision="$(GIT_VERSION)" \
 -              -F report_file=@test-results/git-smoke.tar.gz \
 -              $(SMOKE_UPLOAD_FLAGS) \
 -              http://smoke.git.nix.is/app/projects/process_add_report/1 \
 -      | grep -v ^Redirecting
 -
  .PHONY: pre-clean $(T) aggregate-results clean valgrind perf
diff --combined t/test-lib.sh
index ca6bdef63d2ee9389729e5118f22461c887dc5ed,e7d169cc2aa0b128cb4872da8929d699bea1eb4b..eff3a653d14fc27d4e058fb06fa1a5d98c2978ae
@@@ -54,8 -54,8 +54,8 @@@ done,*
        # do not redirect again
        ;;
  *' --tee '*|*' --va'*)
-       mkdir -p test-results
-       BASE=test-results/$(basename "$0" .sh)
+       mkdir -p "$TEST_OUTPUT_DIRECTORY/test-results"
+       BASE="$TEST_OUTPUT_DIRECTORY/test-results/$(basename "$0" .sh)"
        (GIT_TEST_TEE_STARTED=done ${SHELL_PATH} "$0" "$@" 2>&1;
         echo $? > $BASE.exit) | tee $BASE.out
        test "$(cat $BASE.exit)" = 0
        --no-color)
                color=; shift ;;
        --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)
 -              valgrind=t; verbose=t; shift ;;
 +              valgrind=memcheck
 +              shift ;;
 +      --valgrind=*)
 +              valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)')
 +              shift ;;
        --tee)
                shift ;; # was handled already
        --root=*)
        esac
  done
  
 +test -n "$valgrind" && verbose=t
 +
  if test -n "$color"
  then
        say_color () {
@@@ -536,8 -530,6 +536,8 @@@ the
        PATH=$GIT_VALGRIND/bin:$PATH
        GIT_EXEC_PATH=$GIT_VALGRIND/bin
        export GIT_VALGRIND
 +      GIT_VALGRIND_MODE="$valgrind"
 +      export GIT_VALGRIND_MODE
  elif test -n "$GIT_TEST_INSTALLED"
  then
        GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||