Merge branch 'ab/test-lib-pass-trace2-env'
authorJunio C Hamano <gitster@pobox.com>
Thu, 25 Apr 2019 07:41:15 +0000 (16:41 +0900)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Apr 2019 07:41:15 +0000 (16:41 +0900)
Allow tracing of Git executable while running the testsuite.

* ab/test-lib-pass-trace2-env:
test-lib: whitelist GIT_TR2_* in the environment

1  2 
t/test-lib.sh
diff --combined t/test-lib.sh
index 38b157075a79bb7674394f4856a9781e2db22cae,f6318c54c901bb3d1990fc59adcaf02686dc6c75..d18387c255413cfe85b3e25f81e2dc70fcd8b4fa
@@@ -57,13 -57,6 +57,13 @@@ f
  . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
  export PERL_PATH SHELL_PATH
  
 +# Disallow the use of abbreviated options in the test suite by default
 +if test -z "${GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS}"
 +then
 +      GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true
 +      export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS
 +fi
 +
  ################################################################
  # It appears that people try to run tests without building...
  "${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" >/dev/null
@@@ -386,6 -379,7 +386,7 @@@ unset VISUAL EMAIL LANGUAGE COLUMNS $("
        my @env = keys %ENV;
        my $ok = join("|", qw(
                TRACE
+               TR2_
                DEBUG
                TEST
                .*_TEST
@@@ -634,10 -628,6 +635,10 @@@ test_external_has_tap=
  
  die () {
        code=$?
 +      # This is responsible for running the atexit commands even when a
 +      # test script run with '--immediate' fails, or when the user hits
 +      # ctrl-C, i.e. when 'test_done' is not invoked at all.
 +      test_atexit_handler || code=$?
        if test -n "$GIT_EXIT_OK"
        then
                exit $code
  
  GIT_EXIT_OK=
  trap 'die' EXIT
 -trap 'exit $?' INT TERM HUP
 +# Disable '-x' tracing, because with some shells, notably dash, it
 +# prevents running the cleanup commands when a test script run with
 +# '--verbose-log -x' is interrupted.
 +trap '{ code=$?; set +x; } 2>/dev/null; exit $code' INT TERM HUP
  
  # The user-facing functions are loaded from a separate file so that
  # test_perf subshells can have them too
@@@ -1063,28 -1050,9 +1064,28 @@@ write_junit_xml_testcase () 
        junit_have_testcase=t
  }
  
 +test_atexit_cleanup=:
 +test_atexit_handler () {
 +      # In a succeeding test script 'test_atexit_handler' is invoked
 +      # twice: first from 'test_done', then from 'die' in the trap on
 +      # EXIT.
 +      # This condition and resetting 'test_atexit_cleanup' below makes
 +      # sure that the registered cleanup commands are run only once.
 +      test : != "$test_atexit_cleanup" || return 0
 +
 +      setup_malloc_check
 +      test_eval_ "$test_atexit_cleanup"
 +      test_atexit_cleanup=:
 +      teardown_malloc_check
 +}
 +
  test_done () {
        GIT_EXIT_OK=t
  
 +      # Run the atexit commands _before_ the trash directory is
 +      # removed, so the commands can access pidfiles and socket files.
 +      test_atexit_handler
 +
        if test -n "$write_junit_xml" && test -n "$junit_xml_path"
        then
                test -n "$junit_have_testcase" || {