Merge branch 'nd/test-helpers'
authorJunio C Hamano <gitster@pobox.com>
Mon, 25 Jul 2016 21:13:42 +0000 (14:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Jul 2016 21:13:42 +0000 (14:13 -0700)
Build clean-up.

* nd/test-helpers:
t/test-lib.sh: fix running tests with --valgrind
Makefile: use VCSSVN_LIB to refer to svn library
Makefile: drop extra dependencies for test helpers

1  2 
Makefile
t/test-lib.sh
diff --combined Makefile
index 1978cb8d40b578648c05fbcfd783f9dbf2178abb,cc90c62bcd10e13599bd1ff6db3f1f382c938002..6a13386c27336b0f3054389674872a2c842f3290
+++ b/Makefile
@@@ -351,12 -351,12 +351,12 @@@ all:
  # Define GMTIME_UNRELIABLE_ERRORS if your gmtime() function does not
  # return NULL when it receives a bogus time_t.
  #
 -# Define HAVE_CLOCK_GETTIME if your platform has clock_gettime in librt.
 +# Define HAVE_CLOCK_GETTIME if your platform has clock_gettime.
  #
 -# Define HAVE_CLOCK_MONOTONIC if your platform has CLOCK_MONOTONIC in librt.
 +# Define HAVE_CLOCK_MONOTONIC if your platform has CLOCK_MONOTONIC.
  #
 -# Define NO_HMAC_CTX_CLEANUP if your OpenSSL is version 0.9.6b or earlier to
 -# cleanup the HMAC context with the older HMAC_cleanup function.
 +# Define NEEDS_LIBRT if your platform requires linking with librt (glibc version
 +# before 2.17) for clock_gettime and CLOCK_MONOTONIC.
  #
  # Define USE_PARENS_AROUND_GETTEXT_N to "yes" if your compiler happily
  # compiles the following initialization:
@@@ -378,7 -378,13 +378,7 @@@ GIT-VERSION-FILE: FORC
  # CFLAGS and LDFLAGS are for the users to override from the command line.
  
  CFLAGS = -g -O2 -Wall
 -LDFLAGS =
 -ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
 -ALL_LDFLAGS = $(LDFLAGS)
 -STRIP ?= strip
 -
 -ifdef DEVELOPER
 -CFLAGS += -Werror \
 +DEVELOPER_CFLAGS = -Werror \
        -Wdeclaration-after-statement \
        -Wno-format-zero-length \
        -Wold-style-definition \
        -Wstrict-prototypes \
        -Wunused \
        -Wvla
 -endif
 +LDFLAGS =
 +ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
 +ALL_LDFLAGS = $(LDFLAGS)
 +STRIP ?= strip
  
  # Create as necessary, replace existing, make ranlib unneeded.
  ARFLAGS = rcs
@@@ -440,6 -443,7 +440,6 @@@ DIFF = dif
  TAR = tar
  FIND = find
  INSTALL = install
 -RPMBUILD = rpmbuild
  TCL_PATH = tclsh
  TCLTK_PATH = wish
  XGETTEXT = xgettext
@@@ -721,7 -725,6 +721,7 @@@ LIB_OBJS += diff-lib.
  LIB_OBJS += diff-no-index.o
  LIB_OBJS += diff.o
  LIB_OBJS += dir.o
 +LIB_OBJS += dir-iterator.o
  LIB_OBJS += editor.o
  LIB_OBJS += entry.o
  LIB_OBJS += environment.o
@@@ -786,7 -789,6 +786,7 @@@ LIB_OBJS += read-cache.
  LIB_OBJS += reflog-walk.o
  LIB_OBJS += refs.o
  LIB_OBJS += refs/files-backend.o
 +LIB_OBJS += refs/iterator.o
  LIB_OBJS += ref-filter.o
  LIB_OBJS += remote.o
  LIB_OBJS += replace_object.o
@@@ -944,7 -946,7 +944,7 @@@ BUILTIN_OBJS += builtin/verify-tag.
  BUILTIN_OBJS += builtin/worktree.o
  BUILTIN_OBJS += builtin/write-tree.o
  
 -GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 +GITLIBS = common-main.o $(LIB_FILE) $(XDIFF_LIB)
  EXTLIBS =
  
  GIT_USER_AGENT = git/$(GIT_VERSION)
@@@ -953,10 -955,6 +953,10 @@@ include config.mak.unam
  -include config.mak.autogen
  -include config.mak
  
 +ifdef DEVELOPER
 +CFLAGS += $(DEVELOPER_CFLAGS)
 +endif
 +
  ifndef sysconfdir
  ifeq ($(prefix),/usr)
  sysconfdir = /etc
@@@ -1140,6 -1138,9 +1140,6 @@@ ifndef NO_OPENSS
        ifdef NEEDS_CRYPTO_WITH_SSL
                OPENSSL_LIBSSL += -lcrypto
        endif
 -      ifdef NO_HMAC_CTX_CLEANUP
 -              BASIC_CFLAGS += -DNO_HMAC_CTX_CLEANUP
 -      endif
  else
        BASIC_CFLAGS += -DNO_OPENSSL
        BLK_SHA1 = 1
@@@ -1470,16 -1471,13 +1470,16 @@@ endi
  
  ifdef HAVE_CLOCK_GETTIME
        BASIC_CFLAGS += -DHAVE_CLOCK_GETTIME
 -      EXTLIBS += -lrt
  endif
  
  ifdef HAVE_CLOCK_MONOTONIC
        BASIC_CFLAGS += -DHAVE_CLOCK_MONOTONIC
  endif
  
 +ifdef NEEDS_LIBRT
 +      EXTLIBS += -lrt
 +endif
 +
  ifdef HAVE_BSD_SYSCTL
        BASIC_CFLAGS += -DHAVE_BSD_SYSCTL
  endif
@@@ -1580,15 -1578,7 +1580,15 @@@ TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_
  DIFF_SQ = $(subst ','\'',$(DIFF))
  PERLLIB_EXTRA_SQ = $(subst ','\'',$(PERLLIB_EXTRA))
  
 -LIBS = $(GITLIBS) $(EXTLIBS)
 +# We must filter out any object files from $(GITLIBS),
 +# as it is typically used like:
 +#
 +#   foo: foo.o $(GITLIBS)
 +#     $(CC) $(filter %.o,$^) $(LIBS)
 +#
 +# where we use it as a dependency. Since we also pull object files
 +# from the dependency list, that would make each entry appear twice.
 +LIBS = $(filter-out %.o, $(GITLIBS)) $(EXTLIBS)
  
  BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
        $(COMPAT_CFLAGS)
@@@ -1724,8 -1714,8 +1724,8 @@@ git.sp git.s git.o: EXTRA_CPPFLAGS = 
        '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
  
  git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
 -      $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) git.o \
 -              $(BUILTIN_OBJS) $(LIBS)
 +      $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
 +              $(filter %.o,$^) $(LIBS)
  
  help.sp help.s help.o: common-cmds.h
  
@@@ -1918,7 -1908,6 +1918,7 @@@ TEST_OBJS := $(patsubst %$X,%.o,$(TEST_
  OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
        $(XDIFF_OBJS) \
        $(VCSSVN_OBJS) \
 +      common-main.o \
        git.o
  ifndef NO_CURL
        OBJECTS += http.o http-walker.o remote-curl.o
@@@ -2081,9 -2070,6 +2081,9 @@@ XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) -
  XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
  LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
  LOCALIZED_SH = $(SCRIPT_SH)
 +LOCALIZED_SH += git-parse-remote.sh
 +LOCALIZED_SH += git-rebase--interactive.sh
 +LOCALIZED_SH += git-sh-setup.sh
  LOCALIZED_PERL = $(SCRIPT_PERL)
  
  ifdef XGETTEXT_INCLUDE_TESTS
@@@ -2245,17 -2231,9 +2245,9 @@@ perf: al
  
  .PHONY: test perf
  
- t/helper/test-ctype$X: ctype.o
+ t/helper/test-line-buffer$X: $(VCSSVN_LIB)
  
- t/helper/test-date$X: date.o ctype.o
- t/helper/test-delta$X: diff-delta.o patch-delta.o
- t/helper/test-line-buffer$X: vcs-svn/lib.a
- t/helper/test-parse-options$X: parse-options.o parse-options-cb.o
- t/helper/test-svn-fe$X: vcs-svn/lib.a
+ t/helper/test-svn-fe$X: $(VCSSVN_LIB)
  
  .PRECIOUS: $(TEST_OBJS)
  
@@@ -2410,25 -2388,31 +2402,25 @@@ quick-install-html
  
  ### Maintainer's dist rules
  
 -git.spec: git.spec.in GIT-VERSION-FILE
 -      sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+
 -      mv $@+ $@
 -
  GIT_TARNAME = git-$(GIT_VERSION)
 -dist: git.spec git-archive$(X) configure
 +dist: git-archive$(X) configure
        ./git-archive --format=tar \
                --prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
        @mkdir -p $(GIT_TARNAME)
 -      @cp git.spec configure $(GIT_TARNAME)
 +      @cp configure $(GIT_TARNAME)
        @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
        @$(MAKE) -C git-gui TARDIR=../$(GIT_TARNAME)/git-gui dist-version
        $(TAR) rf $(GIT_TARNAME).tar \
 -              $(GIT_TARNAME)/git.spec \
                $(GIT_TARNAME)/configure \
                $(GIT_TARNAME)/version \
                $(GIT_TARNAME)/git-gui/version
        @$(RM) -r $(GIT_TARNAME)
        gzip -f -9 $(GIT_TARNAME).tar
  
 -rpm: dist
 -      $(RPMBUILD) \
 -              --define "_source_filedigest_algorithm md5" \
 -              --define "_binary_filedigest_algorithm md5" \
 -              -ta $(GIT_TARNAME).tar.gz
 +rpm::
 +      @echo >&2 "Use distro packaged sources to run rpmbuild"
 +      @false
 +.PHONY: rpm
  
  htmldocs = git-htmldocs-$(GIT_VERSION)
  manpages = git-manpages-$(GIT_VERSION)
@@@ -2504,7 -2488,6 +2496,7 @@@ ALL_COMMANDS += git-gui git-citoo
  
  .PHONY: check-docs
  check-docs::
 +      $(MAKE) -C Documentation lint-docs
        @(for v in $(ALL_COMMANDS); \
        do \
                case "$$v" in \
diff --combined t/test-lib.sh
index 11201e9cf8320a0f90e4848d8bfe4ccd2ba92c88,0c966f3eaa09e7b523b77240ea35b5b06ec4b316..3f8b98b2c54e1afdb0da42fe3de9fa5ab3f59df3
                }
                run_list=$1; shift ;;
        --run=*)
 -              run_list=$(expr "z$1" : 'z[^=]*=\(.*\)'); shift ;;
 +              run_list=${1#--*=}; shift ;;
        -h|--h|--he|--hel|--help)
                help=t; shift ;;
        -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
                verbose=t; shift ;;
        --verbose-only=*)
 -              verbose_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
 +              verbose_only=${1#--*=}
                shift ;;
        -q|--q|--qu|--qui|--quie|--quiet)
                # Ignore --quiet under a TAP::Harness. Saying how many tests
                valgrind=memcheck
                shift ;;
        --valgrind=*)
 -              valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)')
 +              valgrind=${1#--*=}
                shift ;;
        --valgrind-only=*)
 -              valgrind_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
 +              valgrind_only=${1#--*=}
                shift ;;
        --tee)
                shift ;; # was handled already
        --root=*)
 -              root=$(expr "z$1" : 'z[^=]*=\(.*\)')
 +              root=${1#--*=}
                shift ;;
        --chain-lint)
                GIT_TEST_CHAIN_LINT=1
@@@ -322,19 -322,6 +322,19 @@@ els
        exec 4>/dev/null 3>/dev/null
  fi
  
 +# Send any "-x" output directly to stderr to avoid polluting tests
 +# which capture stderr. We can do this unconditionally since it
 +# has no effect if tracing isn't turned on.
 +#
 +# Note that this sets up the trace fd as soon as we assign the variable, so it
 +# must come after the creation of descriptor 4 above. Likewise, we must never
 +# unset this, as it has the side effect of closing descriptor 4, which we
 +# use to show verbose tests to the user.
 +#
 +# Note also that we don't need or want to export it. The tracing is local to
 +# this shell, and we would not want to influence any shells we exec.
 +BASH_XTRACEFD=4
 +
  test_failure=0
  test_count=0
  test_fixed=0
@@@ -798,7 -785,7 +798,7 @@@ the
        # override all git executables in TEST_DIRECTORY/..
        GIT_VALGRIND=$TEST_DIRECTORY/valgrind
        mkdir -p "$GIT_VALGRIND"/bin
-       for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
+       for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/t/helper/test-*
        do
                make_valgrind_symlink $file
        done
@@@ -1111,12 -1098,3 +1111,12 @@@ run_with_limited_cmdline () 
  }
  
  test_lazy_prereq CMDLINE_LIMIT 'run_with_limited_cmdline true'
 +
 +build_option () {
 +      git version --build-options |
 +      sed -ne "s/^$1: //p"
 +}
 +
 +test_lazy_prereq LONG_IS_64BIT '
 +      test 8 -le "$(build_option sizeof-long)"
 +'