From: Junio C Hamano Date: Wed, 15 Nov 2017 03:14:35 +0000 (+0900) Subject: Merge branch 'cb/t4201-robustify' X-Git-Tag: v2.16.0-rc0~122 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/4fff9c7f30d7fef04be801bb465a47489570af75?ds=inline;hp=-c Merge branch 'cb/t4201-robustify' A test update. * cb/t4201-robustify: t4201: make use of abbreviation in the test more robust --- 4fff9c7f30d7fef04be801bb465a47489570af75 diff --combined t/test-lib.sh index 9b61f16f7a,ee08c03d58..116bd6a70c --- a/t/test-lib.sh +++ b/t/test-lib.sh @@@ -36,19 -36,6 +36,19 @@@ the fi GIT_BUILD_DIR="$TEST_DIRECTORY"/.. +# If we were built with ASAN, it may complain about leaks +# of program-lifetime variables. Disable it by default to lower +# the noise level. This needs to happen at the start of the script, +# before we even do our "did we build git yet" check (since we don't +# want that one to complain to stderr). +: ${ASAN_OPTIONS=detect_leaks=0:abort_on_error=1} +export ASAN_OPTIONS + +# If LSAN is in effect we _do_ want leak checking, but we still +# want to abort so that we notice the problems. +: ${LSAN_OPTIONS=abort_on_error=1} +export LSAN_OPTIONS + ################################################################ # It appears that people try to run tests without building... "$GIT_BUILD_DIR/git" >/dev/null @@@ -104,6 -91,7 +104,6 @@@ unset VISUAL EMAIL LANGUAGE COLUMNS $(" my $ok = join("|", qw( TRACE DEBUG - USE_LOOKUP TEST .*_TEST PROVE @@@ -160,6 -148,9 +160,6 @@@ els } fi -: ${ASAN_OPTIONS=detect_leaks=0} -export ASAN_OPTIONS - # Protect ourselves from common misconfiguration to export # CDPATH into the environment unset CDPATH @@@ -175,9 -166,10 +175,10 @@@ esa # Convenience # - # A regexp to match 5 and 40 hexdigits + # A regexp to match 5, 35 and 40 hexdigits _x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' - _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05" + _x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05" + _x40="$_x35$_x05" # Zero SHA-1 _z40=0000000000000000000000000000000000000000 @@@ -193,7 -185,7 +194,7 @@@ LF= # when case-folding filenames u200c=$(printf '\342\200\214') - export _x05 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB + export _x05 _x35 _x40 _z40 LF u200c EMPTY_TREE EMPTY_BLOB # Each test should start with something like this, after copyright notices: # @@@ -279,7 -271,7 +280,7 @@@ the test -z "$verbose" && verbose_only="$valgrind_only" elif test -n "$valgrind" then - verbose=t + test -z "$verbose_log" && verbose=t fi if test -n "$color" @@@ -634,9 -626,9 +635,9 @@@ test_run_ () trace= # 117 is magic because it is unlikely to match the exit # code of other programs - test_eval_ "(exit 117) && $1" - if test "$?" != 117; then - error "bug in the test script: broken &&-chain: $1" + if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)" + then + error "bug in the test script: broken &&-chain or run-away HERE-DOC: $1" fi trace=$trace_tmp fi @@@ -754,36 -746,26 +755,36 @@@ test_done () fi case "$test_failure" in 0) - # Maybe print SKIP message - if test -n "$skip_all" && test $test_count -gt 0 - then - error "Can't use skip_all after running some tests" - fi - test -z "$skip_all" || skip_all=" # SKIP $skip_all" - if test $test_external_has_tap -eq 0 then if test $test_remaining -gt 0 then say_color pass "# passed all $msg" fi - say "1..$test_count$skip_all" + + # Maybe print SKIP message + test -z "$skip_all" || skip_all="# SKIP $skip_all" + case "$test_count" in + 0) + say "1..$test_count${skip_all:+ $skip_all}" + ;; + *) + test -z "$skip_all" || + say_color warn "$skip_all" + say "1..$test_count" + ;; + esac fi - test -d "$remove_trash" && - cd "$(dirname "$remove_trash")" && - rm -rf "$(basename "$remove_trash")" + if test -z "$debug" + then + test -d "$TRASH_DIRECTORY" || + error "Tests passed but trash directory already removed before test cleanup; aborting" + cd "$TRASH_DIRECTORY/.." && + rm -fr "$TRASH_DIRECTORY" || + error "Tests passed but test cleanup failed; aborting" + fi test_at_end_hook_ exit 0 ;; @@@ -938,6 -920,7 +939,6 @@@ case "$TRASH_DIRECTORY" i /*) ;; # absolute path is good *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;; esac -test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY rm -fr "$TRASH_DIRECTORY" || { GIT_EXIT_OK=t echo >&5 "FATAL: Cannot prepare test area" @@@ -995,6 -978,9 +996,6 @@@ case $uname_s i find () { /usr/bin/find "$@" } - sum () { - md5sum "$@" - } # git sees Windows-style pwd pwd () { builtin pwd -W @@@ -1024,9 -1010,8 +1025,9 @@@ esa ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1 test -z "$NO_PERL" && test_set_prereq PERL +test -z "$NO_PTHREADS" && test_set_prereq PTHREADS test -z "$NO_PYTHON" && test_set_prereq PYTHON -test -n "$USE_LIBPCRE" && test_set_prereq LIBPCRE +test -n "$USE_LIBPCRE1$USE_LIBPCRE2" && test_set_prereq PCRE test -z "$NO_GETTEXT" && test_set_prereq GETTEXT # Can we rely on git's output in the C locale? @@@ -1067,8 -1052,14 +1068,8 @@@ test_i18ngrep () test_lazy_prereq PIPE ' # test whether the filesystem supports FIFOs - case $(uname -s) in - CYGWIN*|MINGW*) - false - ;; - *) - rm -f testfifo && mkfifo testfifo - ;; - esac + test_have_prereq !MINGW,!CYGWIN && + rm -f testfifo && mkfifo testfifo ' test_lazy_prereq SYMLINKS ' @@@ -1164,19 -1155,7 +1165,19 @@@ run_with_limited_cmdline () (ulimit -s 128 && "$@") } -test_lazy_prereq CMDLINE_LIMIT 'run_with_limited_cmdline true' +test_lazy_prereq CMDLINE_LIMIT ' + test_have_prereq !MINGW,!CYGWIN && + run_with_limited_cmdline true +' + +run_with_limited_stack () { + (ulimit -s 128 && "$@") +} + +test_lazy_prereq ULIMIT_STACK_SIZE ' + test_have_prereq !MINGW,!CYGWIN && + run_with_limited_stack true +' build_option () { git version --build-options | @@@ -1186,6 -1165,3 +1187,6 @@@ test_lazy_prereq LONG_IS_64BIT ' test 8 -le "$(build_option sizeof-long)" ' + +test_lazy_prereq TIME_IS_64BIT 'test-date is64bit' +test_lazy_prereq TIME_T_IS_64BIT 'test-date time_t-is64bit'