Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/test-lib.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / test-lib.sh` 2023 lines ยท 51053 bytes Raw Blame History 1 # Test framework for git. See t/README for usage. 2 # 3 # Copyright (c) 2005 Junio C Hamano 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 2 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see https://www.gnu.org/licenses/ . 17 18 # Enable the use of errexit so that any unexpected failures will cause us to 19 # abort tests, even when outside of a specific test case. 20 # 21 # Note that we only enable this on Bash 5 and newer, or when explicitly 22 # requested by the user via `GIT_TEST_USE_SET_E=true`. This ib secause `set -e` 23 # has wildly different behaviour across shells. The list of default-enabled 24 # shells may be extended going forward. 25 if test -z "$GIT_TEST_USE_SET_E" && test "${BASH_VERSINFO:=0}" -ge 5 26 then 27 GIT_TEST_USE_SET_E=true 28 fi 29 30 # We cannot use `test-tool env-helper` here, as it's not yet available. 31 case "${GIT_TEST_USE_SET_E:-false}" in 32 1|on|true|yes) 33 set -e 34 ;; 35 0|off|false|no) 36 ;; 37 *) 38 echo "GIT_TEST_USE_SET_E requires a boolean" >&2 39 exit 1 40 ;; 41 esac 42 43 # Test the binaries we have just built. The tests are kept in 44 # t/ subdirectory and are run in 'trash directory' subdirectory. 45 if test -z "$TEST_DIRECTORY" 46 then 47 # ensure that TEST_DIRECTORY is an absolute path so that it 48 # is valid even if the current working directory is changed 49 TEST_DIRECTORY=$(pwd) 50 else 51 # The TEST_DIRECTORY will always be the path to the "t" 52 # directory in the git.git checkout. This is overridden by 53 # e.g. t/lib-subtest.sh, but only because its $(pwd) is 54 # different. Those tests still set "$TEST_DIRECTORY" to the 55 # same path. 56 # 57 # See use of "$GIT_BUILD_DIR" and "$TEST_DIRECTORY" below for 58 # hard assumptions about "$GIT_BUILD_DIR/t" existing and being 59 # the "$TEST_DIRECTORY", and e.g. "$TEST_DIRECTORY/helper" 60 # needing to exist. 61 TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1 62 fi 63 GIT_BUILD_DIR="${GIT_BUILD_DIR:-${TEST_DIRECTORY%/t}}" 64 if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR" 65 then 66 echo "PANIC: Running in a $TEST_DIRECTORY that doesn't end in '/t'?" >&2 67 exit 1 68 fi 69 if test -f "$GIT_BUILD_DIR/GIT-BUILD-DIR" 70 then 71 GIT_BUILD_DIR="$(cat "$GIT_BUILD_DIR/GIT-BUILD-DIR")" || exit 1 72 # On Windows, we must convert Windows paths lest they contain a colon 73 case "$(uname -s)" in 74 *MINGW*) 75 GIT_BUILD_DIR="$(cygpath -au "$GIT_BUILD_DIR")" 76 ;; 77 esac 78 fi 79 80 # Prepend a string to a VAR using an arbitrary ":" delimiter, not 81 # adding the delimiter if VAR or VALUE is empty. I.e. a generalized: 82 # 83 # VAR=$1${VAR:+${1:+$2}$VAR} 84 # 85 # Usage (using ":" as the $2 delimiter): 86 # 87 # prepend_var VAR : VALUE 88 prepend_var () { 89 eval "$1=\"$3\${$1:+${3:+$2}\$$1}\"" 90 } 91 92 # If [AL]SAN is in effect we want to abort so that we notice 93 # problems. The GIT_SAN_OPTIONS variable can be used to set common 94 # defaults shared between [AL]SAN_OPTIONS. 95 prepend_var GIT_SAN_OPTIONS : abort_on_error=1 96 prepend_var GIT_SAN_OPTIONS : strip_path_prefix="$GIT_BUILD_DIR/" 97 98 # If we were built with ASAN, it may complain about leaks 99 # of program-lifetime variables. Disable it by default to lower 100 # the noise level. This needs to happen at the start of the script, 101 # before we even do our "did we build git yet" check (since we don't 102 # want that one to complain to stderr). 103 prepend_var ASAN_OPTIONS : $GIT_SAN_OPTIONS 104 prepend_var ASAN_OPTIONS : detect_leaks=0 105 prepend_var ASAN_OPTIONS : strict_string_checks=1 106 export ASAN_OPTIONS 107 108 prepend_var LSAN_OPTIONS : $GIT_SAN_OPTIONS 109 prepend_var LSAN_OPTIONS : exitcode=0 110 prepend_var LSAN_OPTIONS : fast_unwind_on_malloc=0 111 export LSAN_OPTIONS 112 113 prepend_var UBSAN_OPTIONS : $GIT_SAN_OPTIONS 114 export UBSAN_OPTIONS 115 116 # The TEST_OUTPUT_DIRECTORY will be overwritten via GIT-BUILD-OPTIONS. So in 117 # case the caller has manually set up this variable via the environment we must 118 # make sure to not overwrite that value, and thus we save it into 119 # TEST_OUTPUT_DIRECTORY_OVERRIDE here. 120 if test -n "$TEST_OUTPUT_DIRECTORY" && test -z "$TEST_OUTPUT_DIRECTORY_OVERRIDE" 121 then 122 TEST_OUTPUT_DIRECTORY_OVERRIDE=$TEST_OUTPUT_DIRECTORY 123 fi 124 125 if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS 126 then 127 echo >&2 'error: GIT-BUILD-OPTIONS missing (has Git been built?).' 128 exit 1 129 fi 130 . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS 131 export PERL_PATH SHELL_PATH 132 133 if test -z "$TEST_OUTPUT_DIRECTORY" 134 then 135 # Similarly, override this to store the test-results subdir 136 # elsewhere 137 TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY 138 fi 139 140 # In t0000, we need to override test directories of nested testcases. In case 141 # the developer has TEST_OUTPUT_DIRECTORY part of his build options, then we'd 142 # reset this value to instead contain what the developer has specified. We thus 143 # have this knob to allow overriding the directory. 144 if test -n "${TEST_OUTPUT_DIRECTORY_OVERRIDE}" 145 then 146 TEST_OUTPUT_DIRECTORY="${TEST_OUTPUT_DIRECTORY_OVERRIDE}" 147 fi 148 149 # Disallow the use of abbreviated options in the test suite by default 150 if test -z "${GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS}" 151 then 152 GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS=true 153 export GIT_TEST_DISALLOW_ABBREVIATED_OPTIONS 154 fi 155 156 # Explicitly set the default branch name for testing, to squelch hints 157 # from "git init" during the transition period. Should be removed 158 # after we decide to remove ADVICE_DEFAULT_BRANCH_NAME 159 if test -z "$WITH_BREAKING_CHANGES" 160 then 161 : ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=master} 162 else 163 : ${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME:=main} 164 fi 165 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 166 167 168 ################################################################ 169 # It appears that people try to run tests without building... 170 GIT_BINARY="${GIT_TEST_INSTALLED:-$GIT_BUILD_DIR}/git$X" 171 172 if ! "$GIT_BINARY" version >/dev/null 173 then 174 if test -n "$GIT_TEST_INSTALLED" 175 then 176 echo >&2 "error: there is no working Git at '$GIT_TEST_INSTALLED'" 177 else 178 echo >&2 'error: you do not seem to have built git yet.' 179 fi 180 exit 1 181 fi 182 183 store_arg_to= 184 opt_required_arg= 185 # $1: option string 186 # $2: name of the var where the arg will be stored 187 mark_option_requires_arg () { 188 if test -n "$opt_required_arg" 189 then 190 echo "error: options that require args cannot be bundled" \ 191 "together: '$opt_required_arg' and '$1'" >&2 192 exit 1 193 fi 194 opt_required_arg=$1 195 store_arg_to=$2 196 } 197 198 # These functions can be overridden e.g. to output JUnit XML 199 start_test_output () { :; } 200 start_test_case_output () { :; } 201 finalize_test_case_output () { :; } 202 finalize_test_leak_output () { :; } 203 finalize_test_output () { :; } 204 205 parse_option () { 206 local opt="$1" 207 208 case "$opt" in 209 -d|--d|--de|--deb|--debu|--debug) 210 debug=t ;; 211 -i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate) 212 immediate=t ;; 213 -l|--l|--lo|--lon|--long|--long-|--long-t|--long-te|--long-tes|--long-test|--long-tests) 214 GIT_TEST_LONG=true; export GIT_TEST_LONG ;; 215 -r) 216 mark_option_requires_arg "$opt" run_list 217 ;; 218 --run=*) 219 run_list=${opt#--*=} ;; 220 -h|--h|--he|--hel|--help) 221 help=t ;; 222 -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) 223 verbose=t ;; 224 --verbose-only=*) 225 verbose_only=${opt#--*=} 226 ;; 227 -q|--q|--qu|--qui|--quie|--quiet) 228 # Ignore --quiet under a TAP::Harness. Saying how many tests 229 # passed without the ok/not ok details is always an error. 230 test -z "$HARNESS_ACTIVE" && quiet=t ;; 231 --with-dashes) 232 with_dashes=t ;; 233 --no-bin-wrappers) 234 no_bin_wrappers=t ;; 235 --no-color) 236 color= ;; 237 --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind) 238 valgrind=memcheck 239 tee=t 240 ;; 241 --valgrind=*) 242 valgrind=${opt#--*=} 243 tee=t 244 ;; 245 --valgrind-only=*) 246 valgrind_only=${opt#--*=} 247 tee=t 248 ;; 249 --tee) 250 tee=t ;; 251 --root=*) 252 root=${opt#--*=} ;; 253 --chain-lint) 254 GIT_TEST_CHAIN_LINT=1 ;; 255 --no-chain-lint) 256 GIT_TEST_CHAIN_LINT=0 ;; 257 -x) 258 trace=t ;; 259 -V|--verbose-log) 260 verbose_log=t 261 tee=t 262 ;; 263 --write-junit-xml) 264 . "$TEST_DIRECTORY/test-lib-junit.sh" 265 ;; 266 --github-workflow-markup) 267 . "$TEST_DIRECTORY/test-lib-github-workflow-markup.sh" 268 ;; 269 --stress) 270 stress=t ;; 271 --stress=*) 272 echo "error: --stress does not accept an argument: '$opt'" >&2 273 echo "did you mean --stress-jobs=${opt#*=} or --stress-limit=${opt#*=}?" >&2 274 exit 1 275 ;; 276 --stress-jobs=*) 277 stress=t; 278 stress_jobs=${opt#--*=} 279 case "$stress_jobs" in 280 *[!0-9]*|0*|"") 281 echo "error: --stress-jobs= requires the number of jobs to run" >&2 282 exit 1 283 ;; 284 *) # Good. 285 ;; 286 esac 287 ;; 288 --stress-limit=*) 289 stress=t; 290 stress_limit=${opt#--*=} 291 case "$stress_limit" in 292 *[!0-9]*|0*|"") 293 echo "error: --stress-limit= requires the number of repetitions" >&2 294 exit 1 295 ;; 296 *) # Good. 297 ;; 298 esac 299 ;; 300 --invert-exit-code) 301 invert_exit_code=t 302 ;; 303 *) 304 echo "error: unknown test option '$opt'" >&2; exit 1 ;; 305 esac 306 } 307 308 # Parse options while taking care to leave $@ intact, so we will still 309 # have all the original command line options when executing the test 310 # script again for '--tee' and '--verbose-log' later. 311 for opt 312 do 313 if test -n "$store_arg_to" 314 then 315 eval $store_arg_to=\$opt 316 store_arg_to= 317 opt_required_arg= 318 continue 319 fi 320 321 case "$opt" in 322 --*|-?) 323 parse_option "$opt" ;; 324 -?*) 325 # bundled short options must be fed separately to parse_option 326 opt=${opt#-} 327 while test -n "$opt" 328 do 329 extra=${opt#?} 330 this=${opt%$extra} 331 opt=$extra 332 parse_option "-$this" 333 done 334 ;; 335 *) 336 echo "error: unknown test option '$opt'" >&2; exit 1 ;; 337 esac 338 done 339 if test -n "$store_arg_to" 340 then 341 echo "error: $opt_required_arg requires an argument" >&2 342 exit 1 343 fi 344 345 if test -n "$valgrind_only" 346 then 347 test -z "$valgrind" && valgrind=memcheck 348 test -z "$verbose" && verbose_only="$valgrind_only" 349 elif test -n "$valgrind" 350 then 351 test -z "$verbose_log" && verbose=t 352 fi 353 354 if test -n "$stress" 355 then 356 verbose=t 357 trace=t 358 immediate=t 359 fi 360 361 TEST_STRESS_JOB_SFX="${GIT_TEST_STRESS_JOB_NR:+.stress-$GIT_TEST_STRESS_JOB_NR}" 362 TEST_NAME="$(basename "$0" .sh)" 363 TEST_NUMBER="${TEST_NAME%%-*}" 364 TEST_NUMBER="${TEST_NUMBER#t}" 365 TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results" 366 TEST_RESULTS_BASE="$TEST_RESULTS_DIR/$TEST_NAME$TEST_STRESS_JOB_SFX" 367 TEST_RESULTS_SAN_FILE_PFX=trace 368 TEST_RESULTS_SAN_DIR_SFX=leak 369 TEST_RESULTS_SAN_FILE= 370 TEST_RESULTS_SAN_DIR="$TEST_RESULTS_BASE.$TEST_RESULTS_SAN_DIR_SFX" 371 TRASH_DIRECTORY="trash directory.$TEST_NAME$TEST_STRESS_JOB_SFX" 372 test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY" 373 case "$TRASH_DIRECTORY" in 374 /*) ;; # absolute path is good 375 *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;; 376 esac 377 378 # If --stress was passed, run this test repeatedly in several parallel loops. 379 if test "$GIT_TEST_STRESS_STARTED" = "done" 380 then 381 : # Don't stress test again. 382 elif test -n "$stress" 383 then 384 if test -n "$stress_jobs" 385 then 386 job_count=$stress_jobs 387 elif test -n "$GIT_TEST_STRESS_LOAD" 388 then 389 job_count="$GIT_TEST_STRESS_LOAD" 390 elif job_count=$(getconf _NPROCESSORS_ONLN 2>/dev/null) && 391 test -n "$job_count" 392 then 393 job_count=$((2 * $job_count)) 394 else 395 job_count=8 396 fi 397 398 mkdir -p "$TEST_RESULTS_DIR" 399 stressfail="$TEST_RESULTS_BASE.stress-failed" 400 rm -f "$stressfail" 401 402 stress_exit=0 403 trap ' 404 kill $job_pids 2>/dev/null 405 wait 406 stress_exit=1 407 ' TERM INT HUP 408 409 job_pids= 410 job_nr=0 411 while test $job_nr -lt "$job_count" 412 do 413 ( 414 GIT_TEST_STRESS_STARTED=done 415 GIT_TEST_STRESS_JOB_NR=$job_nr 416 export GIT_TEST_STRESS_STARTED GIT_TEST_STRESS_JOB_NR 417 418 trap ' 419 kill $test_pid 2>/dev/null 420 wait 421 exit 1 422 ' TERM INT 423 424 cnt=1 425 while ! test -e "$stressfail" && 426 { test -z "$stress_limit" || 427 test $cnt -le $stress_limit ; } 428 do 429 $TEST_SHELL_PATH "$0" "$@" >"$TEST_RESULTS_BASE.stress-$job_nr.out" 2>&1 & 430 test_pid=$! 431 432 if wait $test_pid 433 then 434 printf "OK %2d.%d\n" $GIT_TEST_STRESS_JOB_NR $cnt 435 else 436 echo $GIT_TEST_STRESS_JOB_NR >>"$stressfail" 437 printf "FAIL %2d.%d\n" $GIT_TEST_STRESS_JOB_NR $cnt 438 fi 439 cnt=$(($cnt + 1)) 440 done 441 ) & 442 job_pids="$job_pids $!" 443 job_nr=$(($job_nr + 1)) 444 done 445 446 wait 447 448 if test -f "$stressfail" 449 then 450 stress_exit=1 451 echo "Log(s) of failed test run(s):" 452 for failed_job_nr in $(sort -n "$stressfail") 453 do 454 echo "Contents of '$TEST_RESULTS_BASE.stress-$failed_job_nr.out':" 455 cat "$TEST_RESULTS_BASE.stress-$failed_job_nr.out" 456 done 457 rm -rf "$TRASH_DIRECTORY.stress-failed" 458 # Move the last one. 459 mv "$TRASH_DIRECTORY.stress-$failed_job_nr" "$TRASH_DIRECTORY.stress-failed" 460 fi 461 462 exit $stress_exit 463 fi 464 465 # if --tee was passed, write the output not only to the terminal, but 466 # additionally to the file test-results/$BASENAME.out, too. 467 if test "$GIT_TEST_TEE_STARTED" = "done" 468 then 469 : # do not redirect again 470 elif test -n "$tee" 471 then 472 mkdir -p "$TEST_RESULTS_DIR" 473 474 # Make this filename available to the sub-process in case it is using 475 # --verbose-log. 476 GIT_TEST_TEE_OUTPUT_FILE=$TEST_RESULTS_BASE.out 477 export GIT_TEST_TEE_OUTPUT_FILE 478 479 # Truncate before calling "tee -a" to get rid of the results 480 # from any previous runs. 481 >"$GIT_TEST_TEE_OUTPUT_FILE" 482 483 ( 484 ret=0 && GIT_TEST_TEE_STARTED=done ${TEST_SHELL_PATH} "$0" "$@" 2>&1 || ret=$? 485 echo "$ret" >"$TEST_RESULTS_BASE.exit" 486 ) | tee -a "$GIT_TEST_TEE_OUTPUT_FILE" 487 test "$(cat "$TEST_RESULTS_BASE.exit")" = 0 488 exit 489 fi 490 491 if test -n "$trace" && test -n "$test_untraceable" 492 then 493 # '-x' tracing requested, but this test script can't be reliably 494 # traced, unless it is run with a Bash version supporting 495 # BASH_XTRACEFD (introduced in Bash v4.1). 496 # 497 # Perform this version check _after_ the test script was 498 # potentially re-executed with $TEST_SHELL_PATH for '--tee' or 499 # '--verbose-log', so the right shell is checked and the 500 # warning is issued only once. 501 if test -n "$BASH_VERSION" && eval ' 502 test ${BASH_VERSINFO[0]} -gt 4 || { 503 test ${BASH_VERSINFO[0]} -eq 4 && 504 test ${BASH_VERSINFO[1]} -ge 1 505 } 506 ' 507 then 508 : Executed by a Bash version supporting BASH_XTRACEFD. Good. 509 else 510 echo >&2 "# warning: ignoring -x; '$0' is untraceable without BASH_XTRACEFD" 511 trace= 512 fi 513 fi 514 if test -n "$trace" && test -z "$verbose_log" 515 then 516 verbose=t 517 fi 518 519 # Since bash 5.0, checkwinsize is enabled by default which does 520 # update the COLUMNS variable every time a non-builtin command 521 # completes, even for non-interactive shells. 522 # Disable that since we are aiming for repeatability. 523 test -n "$BASH_VERSION" && shopt -u checkwinsize 2>/dev/null 524 525 # For repeatability, reset the environment to known value. 526 # TERM is sanitized below, after saving color control sequences. 527 LANG=C 528 LC_ALL=C 529 PAGER=cat 530 TZ=UTC 531 COLUMNS=80 532 export LANG LC_ALL PAGER TZ COLUMNS 533 EDITOR=: 534 535 # A call to "unset" with no arguments causes at least Solaris 10 536 # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets 537 # deriving from the command substitution clustered with the other 538 # ones. 539 unset VISUAL EMAIL LANGUAGE $(env | sed -n \ 540 -e '/^GIT_TRACE/d' \ 541 -e '/^GIT_DEBUG/d' \ 542 -e '/^GIT_TEST/d' \ 543 -e '/^GIT_.*_TEST/d' \ 544 -e '/^GIT_PROVE/d' \ 545 -e '/^GIT_VALGRIND/d' \ 546 -e '/^GIT_UNZIP/d' \ 547 -e '/^GIT_PERF_/d' \ 548 -e '/^GIT_CURL_VERBOSE/d' \ 549 -e '/^GIT_TRACE_CURL/d' \ 550 -e '/^GIT_BUILD_DIR/d' \ 551 -e 's/^\(GIT_[^=]*\)=.*/\1/p' 552 ) 553 unset XDG_CACHE_HOME 554 unset XDG_CONFIG_HOME 555 unset GITPERLLIB 556 unset GIT_TRACE2_PARENT_NAME 557 unset GIT_TRACE2_PARENT_SID 558 TEST_AUTHOR_LOCALNAME=author 559 TEST_AUTHOR_DOMAIN=example.com 560 GIT_AUTHOR_EMAIL=${TEST_AUTHOR_LOCALNAME}@${TEST_AUTHOR_DOMAIN} 561 GIT_AUTHOR_NAME='A U Thor' 562 GIT_AUTHOR_DATE='`1112354055` +0200' 563 TEST_COMMITTER_LOCALNAME=committer 564 TEST_COMMITTER_DOMAIN=example.com 565 GIT_COMMITTER_EMAIL=${TEST_COMMITTER_LOCALNAME}@${TEST_COMMITTER_DOMAIN} 566 GIT_COMMITTER_NAME='C O Mitter' 567 GIT_COMMITTER_DATE='`1112354055` +0200' 568 GIT_MERGE_VERBOSITY=5 569 GIT_MERGE_AUTOEDIT=no 570 export GIT_MERGE_VERBOSITY GIT_MERGE_AUTOEDIT 571 export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME 572 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME 573 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE 574 export EDITOR 575 576 GIT_TEST_BUILTIN_HASH=$("$GIT_BINARY" version --build-options | sed -ne 's/^default-hash: //p') 577 GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-$GIT_TEST_BUILTIN_HASH}" 578 export GIT_DEFAULT_HASH 579 GIT_DEFAULT_REF_STORAGE_FORMAT="${GIT_TEST_DEFAULT_REF_STORAGE_FORMAT:-files}" 580 export GIT_DEFAULT_REF_STORAGE_FORMAT 581 582 # Tests using GIT_TRACE typically don't want : output 583 GIT_TRACE_BARE=1 584 export GIT_TRACE_BARE 585 586 # Some tests scan the GIT_TRACE2_EVENT feed for events, but the 587 # default depth is 2, which frequently causes issues when the 588 # events are wrapped in new regions. Set it to a sufficiently 589 # large depth to avoid custom changes in the test suite. 590 GIT_TRACE2_EVENT_NESTING=100 591 export GIT_TRACE2_EVENT_NESTING 592 593 # Use specific version of the index file format 594 if test -n "${GIT_TEST_INDEX_VERSION:+isset}" 595 then 596 GIT_INDEX_VERSION="$GIT_TEST_INDEX_VERSION" 597 export GIT_INDEX_VERSION 598 fi 599 600 if test -n "$GIT_TEST_PERL_FATAL_WARNINGS" 601 then 602 GIT_PERL_FATAL_WARNINGS=1 603 export GIT_PERL_FATAL_WARNINGS 604 fi 605 606 case $GIT_TEST_FSYNC in 607 '') 608 GIT_TEST_FSYNC=0 609 export GIT_TEST_FSYNC 610 ;; 611 esac 612 613 # Protect ourselves from common misconfiguration to export 614 # CDPATH into the environment 615 unset CDPATH 616 617 unset GREP_OPTIONS 618 unset UNZIP 619 620 case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in 621 1|2|true) 622 GIT_TRACE=4 623 ;; 624 esac 625 626 # Line feed 627 LF=' 628 ' 629 630 # Single quote 631 SQ=\' 632 633 # UTF-8 ZERO WIDTH NON-JOINER, which HFS+ ignores 634 # when case-folding filenames 635 u200c=$(printf '\342\200\214') 636 637 export _x05 _x35 LF u200c EMPTY_TREE EMPTY_BLOB ZERO_OID OID_REGEX 638 639 test "x$TERM" != "xdumb" && ( 640 test -t 1 && 641 tput bold >/dev/null 2>&1 && 642 tput setaf 1 >/dev/null 2>&1 && 643 tput sgr0 >/dev/null 2>&1 644 ) && 645 color=t 646 647 if test -n "$color" 648 then 649 # Save the color control sequences now rather than run tput 650 # each time say_color() is called. This is done for two 651 # reasons: 652 # * TERM will be changed to dumb 653 # * HOME will be changed to a temporary directory and tput 654 # might need to read ~/.terminfo from the original HOME 655 # directory to get the control sequences 656 # Note: This approach assumes the control sequences don't end 657 # in a newline for any terminal of interest (command 658 # substitutions strip trailing newlines). Given that most 659 # (all?) terminals in common use are related to ECMA-48, this 660 # shouldn't be a problem. 661 say_color_error=$(tput bold; tput setaf 1) # bold red 662 say_color_skip=$(tput setaf 4) # blue 663 say_color_warn=$(tput setaf 3) # brown/yellow 664 say_color_pass=$(tput setaf 2) # green 665 say_color_info=$(tput setaf 6) # cyan 666 say_color_reset=$(tput sgr0) 667 say_color_="" # no formatting for normal text 668 say_color () { 669 test -z "$1" && test -n "$quiet" && return 670 eval "say_color_color=\$say_color_$1" 671 shift 672 printf "%s\\n" "$say_color_color$*$say_color_reset" 673 } 674 else 675 say_color() { 676 test -z "$1" && test -n "$quiet" && return 677 shift 678 printf "%s\n" "$*" 679 } 680 fi 681 682 USER_TERM="$TERM" 683 TERM=dumb 684 export TERM USER_TERM 685 686 # What is written by tests to stdout and stderr is sent to different places 687 # depending on the test mode (e.g. /dev/null in non-verbose mode, piped to tee 688 # with --tee option, etc.). We save the original stdin to FD #6 and stdout and 689 # stderr to #5 and #7, so that the test framework can use them (e.g. for 690 # printing errors within the test framework) independently of the test mode. 691 exec 5>&1 692 exec 6<&0 693 exec 7>&2 694 695 _error_exit () { 696 finalize_test_output 697 GIT_EXIT_OK=t 698 exit 1 699 } 700 701 error () { 702 say_color error "error: $*" 703 _error_exit 704 } 705 706 BUG () { 707 error >&7 "bug in the test script: $*" 708 } 709 710 BAIL_OUT () { 711 test $# -ne 1 && BUG "1 param" 712 713 # Do not change "Bail out! " string. It's part of TAP syntax: 714 # https://testanything.org/tap-specification.html 715 local bail_out="Bail out! " 716 local message="$1" 717 718 say_color >&5 error $bail_out "$message" 719 _error_exit 720 } 721 722 say () { 723 say_color info "$*" 724 } 725 726 if test -n "$HARNESS_ACTIVE" 727 then 728 if test "$verbose" = t || test -n "$verbose_only" 729 then 730 BAIL_OUT 'verbose mode forbidden under TAP harness; try --verbose-log' 731 fi 732 fi 733 734 test "${test_description}" != "" || 735 error "Test script did not set test_description." 736 737 if test "$help" = "t" 738 then 739 printf '%s\n' "$test_description" 740 exit 0 741 fi 742 743 if test "$verbose_log" = "t" 744 then 745 exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3 746 elif test "$verbose" = "t" 747 then 748 exec 4>&2 3>&2 749 else 750 exec 4>/dev/null 3>/dev/null 751 fi 752 753 # Send any "-x" output directly to stderr to avoid polluting tests 754 # which capture stderr. We can do this unconditionally since it 755 # has no effect if tracing isn't turned on. 756 # 757 # Note that this sets up the trace fd as soon as we assign the variable, so it 758 # must come after the creation of descriptor 4 above. Likewise, we must never 759 # unset this, as it has the side effect of closing descriptor 4, which we 760 # use to show verbose tests to the user. 761 # 762 # Note also that we don't need or want to export it. The tracing is local to 763 # this shell, and we would not want to influence any shells we exec. 764 BASH_XTRACEFD=4 765 766 test_failure=0 767 test_count=0 768 test_fixed=0 769 test_broken=0 770 test_success=0 771 772 test_missing_prereq= 773 774 test_external_has_tap=0 775 776 die () { 777 code=$? 778 # This is responsible for running the atexit commands even when a 779 # test script run with '--immediate' fails, or when the user hits 780 # ctrl-C, i.e. when 'test_done' is not invoked at all. 781 test_atexit_handler || code=$? 782 if test -n "$GIT_EXIT_OK" 783 then 784 exit $code 785 else 786 echo >&5 "FATAL: Unexpected exit with code $code" 787 exit 1 788 fi 789 } 790 791 GIT_EXIT_OK= 792 trap 'die' EXIT 793 # Disable '-x' tracing, because with some shells, notably dash, it 794 # prevents running the cleanup commands when a test script run with 795 # '--verbose-log -x' is interrupted. 796 trap '{ code=$?; set +x; } 2>/dev/null; exit $code' INT TERM HUP 797 798 # The user-facing functions are loaded from a separate file so that 799 # test_perf subshells can have them too 800 . "$TEST_DIRECTORY/test-lib-functions.sh" 801 802 # You are not expected to call test_ok_ and test_failure_ directly, use 803 # the test_expect_* functions instead. 804 805 test_ok_ () { 806 test_success=$(($test_success + 1)) 807 say_color "" "ok $test_count - $@" 808 finalize_test_case_output ok "$@" 809 } 810 811 _invert_exit_code_failure_end_blurb () { 812 say_color warn "# faked up failures as TODO & now exiting with 0 due to --invert-exit-code" 813 } 814 815 test_failure_ () { 816 failure_label=$1 817 test_failure=$(($test_failure + 1)) 818 local pfx="" 819 if test -n "$invert_exit_code" # && test -n "$HARNESS_ACTIVE" 820 then 821 pfx="# TODO induced breakage (--invert-exit-code):" 822 fi 823 say_color error "not ok $test_count - ${pfx:+$pfx }$1" 824 shift 825 printf '%s\n' "$*" | sed -e 's/^/# /' 826 # Write the annotation before either --immediate exit path below, 827 # both of which call exit and would otherwise skip it. 828 finalize_test_case_output failure "$failure_label" "$@" 829 if test -n "$immediate" 830 then 831 say_color error "1..$test_count" 832 if test -n "$invert_exit_code" 833 then 834 finalize_test_output 835 _invert_exit_code_failure_end_blurb 836 GIT_EXIT_OK=t 837 exit 0 838 fi 839 check_test_results_san_file_ "$test_failure" 840 _error_exit 841 fi 842 } 843 844 test_known_broken_ok_ () { 845 test_fixed=$(($test_fixed+1)) 846 say_color error "ok $test_count - $1 # TODO known breakage vanished" 847 finalize_test_case_output fixed "$1" 848 } 849 850 test_known_broken_failure_ () { 851 test_broken=$(($test_broken+1)) 852 say_color warn "not ok $test_count - $1 # TODO known breakage" 853 finalize_test_case_output broken "$1" 854 } 855 856 test_debug () { 857 test "$debug" = "" || eval "$1" 858 } 859 860 match_pattern_list () { 861 arg="$1" 862 shift 863 test -z "$*" && return 1 864 # We need to use "$*" to get field-splitting, but we want to 865 # disable globbing, since we are matching against an arbitrary 866 # $arg, not what's in the filesystem. Using "set -f" accomplishes 867 # that, but we must do it in a subshell to avoid impacting the 868 # rest of the script. The exit value of the subshell becomes 869 # the function's return value. 870 ( 871 set -f 872 for pattern_ in $* 873 do 874 case "$arg" in 875 $pattern_) 876 exit 0 877 ;; 878 esac 879 done 880 exit 1 881 ) 882 } 883 884 match_test_selector_list () { 885 operation="$1" 886 shift 887 title="$1" 888 shift 889 arg="$1" 890 shift 891 test -z "$1" && return 0 892 893 # Commas are accepted as separators. 894 OLDIFS=$IFS 895 IFS=',' 896 set -- $1 897 IFS=$OLDIFS 898 899 # If the first selector is negative we include by default. 900 include= 901 case "$1" in 902 !*) include=t ;; 903 esac 904 905 for selector 906 do 907 orig_selector=$selector 908 909 positive=t 910 case "$selector" in 911 !*) 912 positive= 913 selector=${selector##?} 914 ;; 915 esac 916 917 test -z "$selector" && continue 918 919 case "$selector" in 920 *-*) 921 if expr "z${selector%%-*}" : "z[0-9]*[^0-9]" >/dev/null 922 then 923 echo "error: $operation: invalid non-numeric in range" \ 924 "start: '$orig_selector'" >&2 925 exit 1 926 fi 927 if expr "z${selector#*-}" : "z[0-9]*[^0-9]" >/dev/null 928 then 929 echo "error: $operation: invalid non-numeric in range" \ 930 "end: '$orig_selector'" >&2 931 exit 1 932 fi 933 ;; 934 *) 935 if expr "z$selector" : "z[0-9]*[^0-9]" >/dev/null 936 then 937 case "$title" in *${selector}*) 938 include=$positive 939 ;; 940 esac 941 continue 942 fi 943 esac 944 945 # Short cut for "obvious" cases 946 test -z "$include" && test -z "$positive" && continue 947 test -n "$include" && test -n "$positive" && continue 948 949 case "$selector" in 950 -*) 951 if test $arg -le ${selector#-} 952 then 953 include=$positive 954 fi 955 ;; 956 *-) 957 if test $arg -ge ${selector%-} 958 then 959 include=$positive 960 fi 961 ;; 962 *-*) 963 if test ${selector%%-*} -le $arg \ 964 && test $arg -le ${selector#*-} 965 then 966 include=$positive 967 fi 968 ;; 969 *) 970 if test $arg -eq $selector 971 then 972 include=$positive 973 fi 974 ;; 975 esac 976 done 977 978 test -n "$include" 979 } 980 981 maybe_teardown_verbose () { 982 test -z "$verbose_only" && return 983 exec 4>/dev/null 3>/dev/null 984 verbose= 985 } 986 987 last_verbose=t 988 maybe_setup_verbose () { 989 test -z "$verbose_only" && return 990 if match_pattern_list $test_count "$verbose_only" 991 then 992 exec 4>&2 3>&2 993 # Emit a delimiting blank line when going from 994 # non-verbose to verbose. Within verbose mode the 995 # delimiter is printed by test_expect_*. The choice 996 # of the initial $last_verbose is such that before 997 # test 1, we do not print it. 998 test -z "$last_verbose" && echo >&3 "" 999 verbose=t 1000 else 1001 exec 4>/dev/null 3>/dev/null 1002 verbose= 1003 fi 1004 last_verbose=$verbose 1005 } 1006 1007 maybe_teardown_valgrind () { 1008 test -z "$GIT_VALGRIND" && return 1009 GIT_VALGRIND_ENABLED= 1010 } 1011 1012 maybe_setup_valgrind () { 1013 test -z "$GIT_VALGRIND" && return 1014 if test -z "$valgrind_only" 1015 then 1016 GIT_VALGRIND_ENABLED=t 1017 return 1018 fi 1019 GIT_VALGRIND_ENABLED= 1020 if match_pattern_list $test_count "$valgrind_only" 1021 then 1022 GIT_VALGRIND_ENABLED=t 1023 fi 1024 } 1025 1026 trace_level_=0 1027 want_trace () { 1028 test "$trace" = t && { 1029 test "$verbose" = t || test "$verbose_log" = t 1030 } 1031 } 1032 1033 # This is a separate function because some tests use 1034 # "return" to end a test_expect_success block early 1035 # (and we want to make sure we run any cleanup like 1036 # "set +x"). 1037 test_eval_inner_ () { 1038 eval "$*" 1039 } 1040 1041 test_eval_ () { 1042 # If "-x" tracing is in effect, then we want to avoid polluting stderr 1043 # with non-test commands. But once in "set -x" mode, we cannot prevent 1044 # the shell from printing the "set +x" to turn it off (nor the saving 1045 # of $? before that). But we can make sure that the output goes to 1046 # /dev/null. 1047 # 1048 # There are a few subtleties here: 1049 # 1050 # - we have to redirect descriptor 4 in addition to 2, to cover 1051 # BASH_XTRACEFD 1052 # 1053 # - the actual eval has to come before the redirection block (since 1054 # it needs to see descriptor 4 to set up its stderr) 1055 # 1056 # - likewise, any error message we print must be outside the block to 1057 # access descriptor 4 1058 # 1059 # - checking $? has to come immediately after the eval, but it must 1060 # be _inside_ the block to avoid polluting the "set -x" output 1061 # 1062 1063 # Do not add anything extra (including LF) after '$*' 1064 test_eval_inner_ &3 2>&4 " 1065 want_trace && trace_level_=$(($trace_level_+1)) && set -x 1066 $*" 1067 { 1068 test_eval_ret_=$? 1069 if want_trace 1070 then 1071 test 1 = $trace_level_ && set +x 1072 trace_level_=$(($trace_level_-1)) 1073 fi 1074 } 2>/dev/null 4>&2 1075 1076 if test "$test_eval_ret_" != 0 && want_trace 1077 then 1078 say_color error >&4 "error: last command exited with \$?=$test_eval_ret_" 1079 fi 1080 return $test_eval_ret_ 1081 } 1082 1083 fail_117 () { 1084 return 117 1085 } 1086 1087 test_run_ () { 1088 test_cleanup=: 1089 expecting_failure=$2 1090 1091 if test "${GIT_TEST_CHAIN_LINT:-1}" != 0; then 1092 # 117 is magic because it is unlikely to match the exit 1093 # code of other programs 1094 test_eval_inner_ "fail_117 && $1" &3 2>&4 1095 if test $? != 117 1096 then 1097 BUG "broken &&-chain: $1" 1098 fi 1099 fi 1100 1101 setup_malloc_check 1102 test_eval_ "$1" 1103 eval_ret=$? 1104 teardown_malloc_check 1105 1106 if test -z "$immediate" || test $eval_ret = 0 || 1107 test -n "$expecting_failure" && test "$test_cleanup" != ":" 1108 then 1109 setup_malloc_check 1110 test_eval_ "$test_cleanup" 1111 teardown_malloc_check 1112 fi 1113 if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE" 1114 then 1115 echo "" 1116 fi 1117 return "$eval_ret" 1118 } 1119 1120 test_start_ () { 1121 test_count=$(($test_count+1)) 1122 maybe_setup_verbose 1123 maybe_setup_valgrind 1124 start_test_case_output "$@" 1125 } 1126 1127 test_finish_ () { 1128 echo >&3 "" 1129 maybe_teardown_valgrind 1130 maybe_teardown_verbose 1131 if test -n "$GIT_TEST_TEE_OFFSET" 1132 then 1133 GIT_TEST_TEE_OFFSET=$(test-tool path-utils file-size \ 1134 "$GIT_TEST_TEE_OUTPUT_FILE") 1135 fi 1136 } 1137 1138 test_skip () { 1139 to_skip= 1140 skipped_reason= 1141 if match_pattern_list $this_test.$test_count "$GIT_SKIP_TESTS" 1142 then 1143 to_skip=t 1144 skipped_reason="GIT_SKIP_TESTS" 1145 fi 1146 if test -z "$to_skip" && test -n "$run_list" && 1147 ! match_test_selector_list '--run' "$1" $test_count "$run_list" 1148 then 1149 to_skip=t 1150 skipped_reason="--run" 1151 fi 1152 if test -z "$to_skip" && test -n "$test_prereq" && 1153 ! test_have_prereq "$test_prereq" 1154 then 1155 to_skip=t 1156 1157 of_prereq= 1158 if test "$missing_prereq" != "$test_prereq" 1159 then 1160 of_prereq=" of $test_prereq" 1161 fi 1162 skipped_reason="missing $missing_prereq${of_prereq}" 1163 1164 # Keep a list of all the missing prereq for result aggregation 1165 if test -z "$missing_prereq" 1166 then 1167 test_missing_prereq=$missing_prereq 1168 else 1169 test_missing_prereq="$test_missing_prereq,$missing_prereq" 1170 fi 1171 fi 1172 1173 case "$to_skip" in 1174 t) 1175 1176 say_color skip "ok $test_count # skip $1 ($skipped_reason)" 1177 : true 1178 finalize_test_case_output skip "$@" 1179 ;; 1180 *) 1181 false 1182 ;; 1183 esac 1184 } 1185 1186 # stub; perf-lib overrides it 1187 test_at_end_hook_ () { 1188 : 1189 } 1190 1191 test_atexit_cleanup=: 1192 test_atexit_handler () { 1193 # In a succeeding test script 'test_atexit_handler' is invoked 1194 # twice: first from 'test_done', then from 'die' in the trap on 1195 # EXIT. 1196 # This condition and resetting 'test_atexit_cleanup' below makes 1197 # sure that the registered cleanup commands are run only once. 1198 test : != "$test_atexit_cleanup" || return 0 1199 1200 setup_malloc_check 1201 test_eval_ "$test_atexit_cleanup" 1202 test_atexit_cleanup=: 1203 teardown_malloc_check 1204 } 1205 1206 check_test_results_san_file_has_entries_ () { 1207 test -z "$TEST_RESULTS_SAN_FILE" && return 1 1208 1209 # Lines marked with DEDUP_TOKEN show unique leaks. We only care that we 1210 # found at least one. 1211 # 1212 # But also suppress any false positives caused by bugs or races in the 1213 # sanitizer itself. 1214 grep -s ^DEDUP_TOKEN "$TEST_RESULTS_SAN_FILE".* | 1215 grep -qv sanitizer::GetThreadStackTopAndBottom 1216 } 1217 1218 check_test_results_san_file_ () { 1219 if ! check_test_results_san_file_has_entries_ 1220 then 1221 return 1222 fi && 1223 say_color >&4 error "$(cat "$TEST_RESULTS_SAN_FILE".*)" && 1224 finalize_test_leak_output && 1225 1226 if test "$test_failure" = 0 1227 then 1228 say >&4 "Our logs revealed a memory leak, exit non-zero!" && 1229 invert_exit_code=t 1230 else 1231 say >&4 "Our logs revealed a memory leak..." 1232 fi 1233 } 1234 1235 test_done () { 1236 # Run the atexit commands _before_ the trash directory is 1237 # removed, so the commands can access pidfiles and socket files. 1238 test_atexit_handler 1239 1240 finalize_test_output 1241 1242 if test -z "$HARNESS_ACTIVE" 1243 then 1244 mkdir -p "$TEST_RESULTS_DIR" 1245 1246 cat >"$TEST_RESULTS_BASE.counts" <<-EOF 1247 total $test_count 1248 success $test_success 1249 fixed $test_fixed 1250 broken $test_broken 1251 failed $test_failure 1252 missing_prereq $test_missing_prereq 1253 1254 EOF 1255 fi 1256 1257 if test "$test_fixed" != 0 1258 then 1259 say_color error "# $test_fixed known breakage(s) vanished; please update test(s)" 1260 fi 1261 if test "$test_broken" != 0 1262 then 1263 say_color warn "# still have $test_broken known breakage(s)" 1264 fi 1265 if test "$test_broken" != 0 || test "$test_fixed" != 0 1266 then 1267 test_remaining=$(( $test_count - $test_broken - $test_fixed )) 1268 msg="remaining $test_remaining test(s)" 1269 else 1270 test_remaining=$test_count 1271 msg="$test_count test(s)" 1272 fi 1273 case "$test_failure" in 1274 0) 1275 if test $test_remaining -gt 0 1276 then 1277 say_color pass "# passed all $msg" 1278 fi 1279 1280 # Maybe print SKIP message 1281 test -z "$skip_all" || skip_all="# SKIP $skip_all" 1282 case "$test_count" in 1283 0) 1284 say "1..$test_count${skip_all:+ $skip_all}" 1285 ;; 1286 *) 1287 test -z "$skip_all" || 1288 say_color warn "$skip_all" 1289 say "1..$test_count" 1290 ;; 1291 esac 1292 1293 if test -n "$stress" && test -n "$invert_exit_code" 1294 then 1295 # We're about to move our "$TRASH_DIRECTORY" 1296 # to "$TRASH_DIRECTORY.stress-failed" if 1297 # --stress is combined with 1298 # --invert-exit-code. 1299 say "with --stress and --invert-exit-code we're not removing '$TRASH_DIRECTORY'" 1300 elif test -z "$debug" && test -n "$remove_trash" 1301 then 1302 test -d "$TRASH_DIRECTORY" || 1303 error "Tests passed but trash directory already removed before test cleanup; aborting" 1304 1305 cd "$TRASH_DIRECTORY/.." && 1306 rm -fr "$TRASH_DIRECTORY" 2>/dev/null || { 1307 # try again in a bit 1308 sleep 5; 1309 rm -fr "$TRASH_DIRECTORY" 2>/dev/null 1310 } || 1311 error "Tests passed but test cleanup failed; aborting" 1312 fi 1313 1314 check_test_results_san_file_ "$test_failure" 1315 1316 if test "$test_fixed" != 0 1317 then 1318 if test -z "$invert_exit_code" 1319 then 1320 GIT_EXIT_OK=t 1321 exit 1 1322 fi 1323 elif test -z "$skip_all" && test -n "$invert_exit_code" 1324 then 1325 say_color warn "# faking up non-zero exit with --invert-exit-code" 1326 GIT_EXIT_OK=t 1327 exit 1 1328 fi 1329 1330 test_at_end_hook_ 1331 1332 GIT_EXIT_OK=t 1333 exit 0 ;; 1334 1335 *) 1336 say_color error "# failed $test_failure among $msg" 1337 say "1..$test_count" 1338 1339 check_test_results_san_file_ "$test_failure" 1340 1341 if test -n "$invert_exit_code" 1342 then 1343 _invert_exit_code_failure_end_blurb 1344 GIT_EXIT_OK=t 1345 exit 0 1346 fi 1347 1348 GIT_EXIT_OK=t 1349 exit 1 ;; 1350 1351 esac 1352 } 1353 1354 if test -n "$valgrind" 1355 then 1356 make_symlink () { 1357 test -h "$2" && 1358 test "$1" = "$(readlink "$2")" || { 1359 # be super paranoid 1360 if mkdir "$2".lock 1361 then 1362 rm -f "$2" && 1363 ln -s "$1" "$2" && 1364 rm -r "$2".lock 1365 else 1366 while test -d "$2".lock 1367 do 1368 say "Waiting for lock on $2." 1369 sleep 1 1370 done 1371 fi 1372 } 1373 } 1374 1375 make_valgrind_symlink () { 1376 # handle only executables, unless they are shell libraries that 1377 # need to be in the exec-path. 1378 test -x "$1" || 1379 test "# " = "$(test_copy_bytes 2 <"$1")" || 1380 return; 1381 1382 base=$(basename "$1") 1383 case "$base" in 1384 test-*) 1385 symlink_target="$GIT_BUILD_DIR/t/helper/$base" 1386 ;; 1387 *) 1388 symlink_target="$GIT_BUILD_DIR/$base" 1389 ;; 1390 esac 1391 # do not override scripts 1392 if test -x "$symlink_target" && 1393 test ! -d "$symlink_target" && 1394 test "#!" != "$(test_copy_bytes 2 <"$symlink_target")" 1395 then 1396 symlink_target=../valgrind.sh 1397 fi 1398 case "$base" in 1399 *.sh|*.perl) 1400 symlink_target=../unprocessed-script 1401 esac 1402 # create the link, or replace it if it is out of date 1403 make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit 1404 } 1405 1406 # override all git executables in TEST_DIRECTORY/.. 1407 GIT_VALGRIND=$TEST_DIRECTORY/valgrind 1408 mkdir -p "$GIT_VALGRIND"/bin 1409 for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/t/helper/test-* 1410 do 1411 make_valgrind_symlink $file 1412 done 1413 # special-case the mergetools loadables 1414 make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools" 1415 OLDIFS=$IFS 1416 IFS=: 1417 for path in $PATH 1418 do 1419 ls "$path"/git-* 2> /dev/null | 1420 while read file 1421 do 1422 make_valgrind_symlink "$file" 1423 done 1424 done 1425 IFS=$OLDIFS 1426 PATH=$GIT_VALGRIND/bin:$PATH 1427 GIT_EXEC_PATH=$GIT_VALGRIND/bin 1428 export GIT_VALGRIND 1429 GIT_VALGRIND_MODE="$valgrind" 1430 export GIT_VALGRIND_MODE 1431 GIT_VALGRIND_ENABLED=t 1432 test -n "$valgrind_only" && GIT_VALGRIND_ENABLED= 1433 export GIT_VALGRIND_ENABLED 1434 elif test -n "$GIT_TEST_INSTALLED" 1435 then 1436 GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) || 1437 error "Cannot run git from $GIT_TEST_INSTALLED." 1438 PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR/t/helper:$PATH 1439 GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH} 1440 else # normal case, use ../bin-wrappers only unless $with_dashes: 1441 if test -n "$no_bin_wrappers" 1442 then 1443 with_dashes=t 1444 else 1445 git_bin_dir="$GIT_BUILD_DIR/bin-wrappers" 1446 if ! test -x "$git_bin_dir/git" 1447 then 1448 if test -z "$with_dashes" 1449 then 1450 say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH" 1451 fi 1452 with_dashes=t 1453 fi 1454 PATH="$git_bin_dir:$PATH" 1455 fi 1456 GIT_EXEC_PATH=$GIT_BUILD_DIR 1457 if test -n "$with_dashes" 1458 then 1459 PATH="$GIT_BUILD_DIR:$GIT_BUILD_DIR/t/helper:$PATH" 1460 fi 1461 fi 1462 GIT_TEMPLATE_DIR="$GIT_TEST_TEMPLATE_DIR" 1463 GIT_CONFIG_NOSYSTEM=1 1464 GIT_ATTR_NOSYSTEM=1 1465 GIT_CEILING_DIRECTORIES="$TRASH_DIRECTORY/.." 1466 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM GIT_CEILING_DIRECTORIES 1467 1468 # Add libc MALLOC and MALLOC_PERTURB test only if we are not executing 1469 # the test with valgrind and have not compiled with conflict SANITIZE 1470 # options. 1471 if test -n "$valgrind" || 1472 test -n "$SANITIZE_ADDRESS" || 1473 test -n "$SANITIZE_LEAK" || 1474 test -n "$TEST_NO_MALLOC_CHECK" 1475 then 1476 setup_malloc_check () { 1477 : nothing 1478 } 1479 teardown_malloc_check () { 1480 : nothing 1481 } 1482 else 1483 _USE_GLIBC_TUNABLES= 1484 _USE_GLIBC_PRELOAD=libc_malloc_debug.so.0 1485 if _GLIBC_VERSION=$(getconf GNU_LIBC_VERSION 2>/dev/null) && 1486 _GLIBC_VERSION=${_GLIBC_VERSION#"glibc "} && 1487 expr 2.34 \<= "$_GLIBC_VERSION" >/dev/null && 1488 stderr=$(LD_PRELOAD=$_USE_GLIBC_PRELOAD git version 2>&1 >/dev/null) && 1489 test -z "$stderr" 1490 then 1491 _USE_GLIBC_TUNABLES=YesPlease 1492 fi 1493 setup_malloc_check () { 1494 local g 1495 local t 1496 MALLOC_CHECK_=3 MALLOC_PERTURB_=165 1497 export MALLOC_CHECK_ MALLOC_PERTURB_ 1498 if test -n "$_USE_GLIBC_TUNABLES" 1499 then 1500 g= 1501 LD_PRELOAD=$_USE_GLIBC_PRELOAD 1502 for t in \ 1503 glibc.malloc.check=1 \ 1504 glibc.malloc.perturb=165 1505 do 1506 g="${g#:}:$t" 1507 done 1508 GLIBC_TUNABLES=$g 1509 export LD_PRELOAD GLIBC_TUNABLES 1510 fi 1511 } 1512 teardown_malloc_check () { 1513 unset MALLOC_CHECK_ MALLOC_PERTURB_ 1514 unset LD_PRELOAD GLIBC_TUNABLES 1515 } 1516 fi 1517 1518 if test -z "$GIT_TEST_CMP" 1519 then 1520 if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT" 1521 then 1522 GIT_TEST_CMP="$DIFF -c" 1523 else 1524 GIT_TEST_CMP="$DIFF -u" 1525 fi 1526 fi 1527 1528 GITPERLLIB="$GIT_TEST_GITPERLLIB" 1529 export GITPERLLIB 1530 test -d "$GIT_TEMPLATE_DIR" || { 1531 BAIL_OUT "You haven't built things yet, have you?" 1532 } 1533 1534 if ! test -x "$GIT_BUILD_DIR"/t/helper/test-tool$X 1535 then 1536 BAIL_OUT 'You need to build test-tool; Run "make t/helper/test-tool" in the source (toplevel) directory' 1537 fi 1538 1539 if test -n "$HARNESS_ACTIVE" 1540 then 1541 say "TAP version 13" 1542 say "pragma +strict" 1543 fi 1544 1545 # Are we running this test at all? 1546 remove_trash= 1547 this_test=${0##*/} 1548 this_test=${this_test%%-*} 1549 if match_pattern_list "$this_test" "$GIT_SKIP_TESTS" 1550 then 1551 say_color info >&3 "skipping test $this_test altogether" 1552 skip_all="skip all tests in $this_test" 1553 test_done 1554 fi 1555 1556 if test -n "$SANITIZE_LEAK" 1557 then 1558 rm -rf "$TEST_RESULTS_SAN_DIR" 1559 if ! mkdir -p "$TEST_RESULTS_SAN_DIR" 1560 then 1561 BAIL_OUT "cannot create $TEST_RESULTS_SAN_DIR" 1562 fi && 1563 TEST_RESULTS_SAN_FILE="$TEST_RESULTS_SAN_DIR/$TEST_RESULTS_SAN_FILE_PFX" 1564 1565 # Don't litter *.leak dirs if there was nothing to report 1566 test_atexit "rmdir \"$TEST_RESULTS_SAN_DIR\" 2>/dev/null || :" 1567 1568 prepend_var LSAN_OPTIONS : dedup_token_length=9999 1569 prepend_var LSAN_OPTIONS : log_exe_name=1 1570 prepend_var LSAN_OPTIONS : log_path="'$TEST_RESULTS_SAN_FILE'" 1571 export LSAN_OPTIONS 1572 fi 1573 1574 if test -z "$PERL_PATH" 1575 then 1576 case "${GIT_TEST_CHAIN_LINT:-unset}" in 1577 unset) 1578 GIT_TEST_CHAIN_LINT=0 1579 ;; 1580 0) 1581 # The user has explicitly disabled the chain linter, so we 1582 # don't have anything to worry about. 1583 ;; 1584 *) 1585 BAIL_OUT 'You need Perl for the chain linter' 1586 ;; 1587 esac 1588 fi 1589 1590 if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 && 1591 test "${GIT_TEST_EXT_CHAIN_LINT:-1}" != 0 1592 then 1593 "$PERL_PATH" "$TEST_DIRECTORY/chainlint.pl" "$0" || 1594 BUG "lint error (see 'LINT' annotations above)" 1595 fi 1596 1597 # Last-minute variable setup 1598 USER_HOME="$HOME" 1599 HOME="$TRASH_DIRECTORY" 1600 GNUPGHOME="$HOME/gnupg-home-not-used" 1601 export HOME GNUPGHOME USER_HOME 1602 1603 # "rm -rf" existing trash directory, even if a previous run left it 1604 # with bad permissions. 1605 remove_trash_directory () { 1606 dir="$1" 1607 if ! rm -rf "$dir" 2>/dev/null 1608 then 1609 chmod -R u+rwx "$dir" 1610 rm -rf "$dir" 1611 fi 1612 ! test -d "$dir" 1613 } 1614 1615 # Test repository 1616 remove_trash_directory "$TRASH_DIRECTORY" || { 1617 BAIL_OUT 'cannot prepare test area' 1618 } 1619 1620 remove_trash=t 1621 if test -z "$TEST_NO_CREATE_REPO" 1622 then 1623 git init \ 1624 ${TEST_CREATE_REPO_NO_TEMPLATE:+--template=} \ 1625 "$TRASH_DIRECTORY" >&3 2>&4 || 1626 error "cannot run git init" 1627 else 1628 mkdir -p "$TRASH_DIRECTORY" 1629 fi 1630 1631 # Use -P to resolve symlinks in our working directory so that the cwd 1632 # in subprocesses like git equals our $PWD (for pathname comparisons). 1633 cd -P "$TRASH_DIRECTORY" || BAIL_OUT "cannot cd -P to \"$TRASH_DIRECTORY\"" 1634 TRASH_DIRECTORY=$(pwd) 1635 HOME="$TRASH_DIRECTORY" 1636 1637 if test -n "$WITH_BREAKING_CHANGES" 1638 then 1639 git config --global safe.bareRepository all && 1640 # Only write to .git/info/exclude when the directory exists 1641 # (i.e. when git init created the repo). If we mkdir -p it 1642 # ourselves, tests that expect to create .git/info/ themselves 1643 # (e.g. t0008) would fail. 1644 if test -d .git/info 1645 then 1646 echo "/.gitconfig" >>.git/info/exclude 1647 fi 1648 fi 1649 1650 start_test_output "$0" 1651 1652 # Convenience 1653 # A regexp to match 5 and 35 hexdigits 1654 _x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' 1655 _x35="$_x05$_x05$_x05$_x05$_x05$_x05$_x05" 1656 1657 test_oid_init 1658 1659 ZERO_OID=$(test_oid zero) 1660 OID_REGEX=$(echo $ZERO_OID | sed -e 's/0/[0-9a-f]/g') 1661 OIDPATH_REGEX=$(test_oid_to_path $ZERO_OID | sed -e 's/0/[0-9a-f]/g') 1662 EMPTY_TREE=$(test_oid empty_tree) 1663 EMPTY_BLOB=$(test_oid empty_blob) 1664 1665 # Provide an implementation of the 'yes' utility; the upper bound 1666 # limit is there to help Windows that cannot stop this loop from 1667 # wasting cycles when the downstream stops reading, so do not be 1668 # tempted to turn it into an infinite loop. cf. `6129c930` ("test-lib: 1669 # limit the output of the yes utility", 2016-02-02) 1670 yes () { 1671 if test $# = 0 1672 then 1673 y=y 1674 else 1675 y="$*" 1676 fi 1677 1678 i=0 1679 while test $i -lt 99 1680 do 1681 echo "$y" 1682 i=$(($i+1)) 1683 done 1684 } 1685 1686 # The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and 1687 # thus needs to be set up really early, and set an internal variable 1688 # for convenience so the hot test_set_prereq() codepath doesn't need 1689 # to call "test-tool env-helper" (via test_bool_env). Only do that work 1690 # if needed by seeing if GIT_TEST_FAIL_PREREQS is set at all. 1691 GIT_TEST_FAIL_PREREQS_INTERNAL= 1692 if test -n "$GIT_TEST_FAIL_PREREQS" 1693 then 1694 if test_bool_env GIT_TEST_FAIL_PREREQS false 1695 then 1696 GIT_TEST_FAIL_PREREQS_INTERNAL=true 1697 test_set_prereq FAIL_PREREQS 1698 fi 1699 else 1700 test_lazy_prereq FAIL_PREREQS ' 1701 test_bool_env GIT_TEST_FAIL_PREREQS false 1702 ' 1703 fi 1704 1705 # Fix some commands on Windows, and other OS-specific things 1706 uname_s=$(uname -s) 1707 case $uname_s in 1708 Darwin) 1709 test_set_prereq MACOS 1710 test_set_prereq POSIXPERM 1711 test_set_prereq BSLASHPSPEC 1712 test_set_prereq EXECKEEPSPID 1713 ;; 1714 *MINGW*) 1715 # Windows has its own (incompatible) sort and find 1716 sort () { 1717 /usr/bin/sort "$@" 1718 } 1719 find () { 1720 /usr/bin/find "$@" 1721 } 1722 # git sees Windows-style pwd 1723 pwd () { 1724 builtin pwd -W 1725 } 1726 # no POSIX permissions 1727 # backslashes in pathspec are converted to '/' 1728 # exec does not inherit the PID 1729 test_set_prereq MINGW 1730 test_set_prereq NATIVE_CRLF 1731 test_set_prereq SED_STRIPS_CR 1732 test_set_prereq GREP_STRIPS_CR 1733 test_set_prereq WINDOWS 1734 GIT_TEST_CMP="GIT_DIR=/dev/null git diff --no-index --ignore-cr-at-eol --" 1735 ;; 1736 *CYGWIN*) 1737 test_set_prereq POSIXPERM 1738 test_set_prereq EXECKEEPSPID 1739 test_set_prereq CYGWIN 1740 test_set_prereq SED_STRIPS_CR 1741 test_set_prereq GREP_STRIPS_CR 1742 test_set_prereq WINDOWS 1743 ;; 1744 *) 1745 test_set_prereq POSIXPERM 1746 test_set_prereq BSLASHPSPEC 1747 test_set_prereq EXECKEEPSPID 1748 ;; 1749 esac 1750 1751 # Detect arches where a few things don't work 1752 uname_m=$(uname -m) 1753 case $uname_m in 1754 parisc* | hppa*) 1755 test_set_prereq HPPA 1756 ;; 1757 esac 1758 1759 case "$GIT_DEFAULT_REF_STORAGE_FORMAT" in 1760 files) 1761 test_set_prereq REFFILES;; 1762 reftable) 1763 test_set_prereq REFTABLE;; 1764 *) 1765 echo 2>&1 "error: unknown ref storage format $GIT_DEFAULT_REF_STORAGE_FORMAT" 1766 exit 1 1767 ;; 1768 esac 1769 1770 ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1 1771 test -z "$NO_CURL" && test_set_prereq LIBCURL 1772 test -z "$NO_GITWEB" && test_set_prereq GITWEB 1773 test -z "$NO_PERL" && test_set_prereq PERL 1774 test -z "$NO_PTHREADS" && test_set_prereq PTHREADS 1775 test -z "$NO_PYTHON" && test_set_prereq PYTHON 1776 test -n "$USE_LIBPCRE2" && test_set_prereq PCRE 1777 test -n "$USE_LIBPCRE2" && test_set_prereq LIBPCRE2 1778 test -z "$NO_GETTEXT" && test_set_prereq GETTEXT 1779 test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK 1780 test -n "$GIT_VALGRIND_ENABLED" && test_set_prereq VALGRIND 1781 test -n "$PERL_PATH" && test_set_prereq PERL_TEST_HELPERS 1782 1783 test_lazy_prereq ICONV ' 1784 # We require Git to be built with iconv support, and we require the 1785 # iconv binary to exist. 1786 # 1787 # NEEDSWORK: We might eventually want to split this up into two 1788 # prerequisites: one for NO_ICONV, and one for the iconv(1) binary, as 1789 # some tests only depend on either of these. 1790 test -z "$NO_ICONV" && 1791 iconv -f utf8 -t utf8 /dev/null && test -h y 1815 ' 1816 1817 test_lazy_prereq FILEMODE ' 1818 test "$(git config --bool core.filemode)" = true 1819 ' 1820 1821 test_lazy_prereq CASE_INSENSITIVE_FS ' 1822 echo good >CamelCase && 1823 echo bad >camelcase && 1824 test "$(cat CamelCase)" != good 1825 ' 1826 1827 test_lazy_prereq FUNNYNAMES ' 1828 test_have_prereq !MINGW && 1829 touch -- \ 1830 "FUNNYNAMES tab embedded" \ 1831 "FUNNYNAMES \"quote embedded\"" \ 1832 "FUNNYNAMES newline 1833 embedded" 2>/dev/null && 1834 rm -- \ 1835 "FUNNYNAMES tab embedded" \ 1836 "FUNNYNAMES \"quote embedded\"" \ 1837 "FUNNYNAMES newline 1838 embedded" 2>/dev/null 1839 ' 1840 1841 test_lazy_prereq UTF8_NFD_TO_NFC ' 1842 # check whether FS converts nfd unicode to nfc 1843 auml=$(printf "\303\244") 1844 aumlcdiar=$(printf "\141\314\210") 1845 >"$auml" && 1846 test -f "$aumlcdiar" 1847 ' 1848 1849 test_lazy_prereq AUTOIDENT ' 1850 sane_unset GIT_AUTHOR_NAME && 1851 sane_unset GIT_AUTHOR_EMAIL && 1852 git var GIT_AUTHOR_IDENT 1853 ' 1854 1855 test_lazy_prereq EXPENSIVE ' 1856 test_bool_env GIT_TEST_LONG false 1857 ' 1858 1859 test_lazy_prereq EXPENSIVE_ON_WINDOWS ' 1860 test_have_prereq EXPENSIVE || test_have_prereq !MINGW,!CYGWIN 1861 ' 1862 1863 test_lazy_prereq USR_BIN_TIME ' 1864 test -x /usr/bin/time 1865 ' 1866 1867 test_lazy_prereq NOT_ROOT ' 1868 uid=$(id -u) && 1869 test "$uid" != 0 1870 ' 1871 1872 test_lazy_prereq JGIT ' 1873 jgit --version 1874 ' 1875 1876 # SANITY is about "can you correctly predict what the filesystem would 1877 # do by only looking at the permission bits of the files and 1878 # directories?" A typical example of !SANITY is running the test 1879 # suite as root, where a test may expect "chmod -r file && cat file" 1880 # to fail because file is supposed to be unreadable after a successful 1881 # chmod. In an environment (i.e. combination of what filesystem is 1882 # being used and who is running the tests) that lacks SANITY, you may 1883 # be able to delete or create a file when the containing directory 1884 # doesn't have write permissions, or access a file even if the 1885 # containing directory doesn't have read or execute permissions. 1886 1887 test_lazy_prereq SANITY ' 1888 mkdir SANETESTD.1 SANETESTD.2 && 1889 1890 chmod +w SANETESTD.1 SANETESTD.2 && 1891 >SANETESTD.1/x 2>SANETESTD.2/x && 1892 chmod -w SANETESTD.1 && 1893 chmod -r SANETESTD.1/x && 1894 chmod -rx SANETESTD.2 || 1895 BUG "cannot prepare SANETESTD" 1896 1897 ! test -r SANETESTD.1/x && 1898 ! rm SANETESTD.1/x && ! test -f SANETESTD.2/x 1899 status=$? 1900 1901 chmod +rwx SANETESTD.1 SANETESTD.2 && 1902 rm -rf SANETESTD.1 SANETESTD.2 || 1903 BUG "cannot clean SANETESTD" 1904 return $status 1905 ' 1906 1907 test FreeBSD != $uname_s || GIT_UNZIP=${GIT_UNZIP:-/usr/local/bin/unzip} 1908 GIT_UNZIP=${GIT_UNZIP:-unzip} 1909 test_lazy_prereq UNZIP ' 1910 "$GIT_UNZIP" -v 1911 test $? -ne 127 1912 ' 1913 1914 run_with_limited_cmdline () { 1915 (ulimit -s 128 && "$@") 1916 } 1917 1918 test_lazy_prereq CMDLINE_LIMIT ' 1919 test_have_prereq !HPPA,!MINGW,!CYGWIN && 1920 run_with_limited_cmdline true 1921 ' 1922 1923 run_with_limited_stack () { 1924 (ulimit -s 128 && "$@") 1925 } 1926 1927 test_lazy_prereq ULIMIT_STACK_SIZE ' 1928 test_have_prereq !HPPA,!MINGW,!CYGWIN && 1929 run_with_limited_stack true 1930 ' 1931 1932 run_with_limited_open_files () { 1933 (ulimit -n 32 && "$@") 1934 } 1935 1936 test_lazy_prereq ULIMIT_FILE_DESCRIPTORS ' 1937 test_have_prereq !MINGW,!CYGWIN && 1938 run_with_limited_open_files true 1939 ' 1940 1941 build_option () { 1942 git version --build-options | 1943 sed -ne "s/^$1: //p" 1944 } 1945 1946 test_lazy_prereq SIZE_T_IS_64BIT ' 1947 test 8 -eq "$(build_option sizeof-size_t)" 1948 ' 1949 1950 test_lazy_prereq LONG_IS_64BIT ' 1951 test 8 -le "$(build_option sizeof-long)" 1952 ' 1953 1954 test_lazy_prereq RUST ' 1955 test "$(build_option rust)" = enabled 1956 ' 1957 1958 test_lazy_prereq TIME_IS_64BIT 'test-tool date is64bit' 1959 test_lazy_prereq TIME_T_IS_64BIT 'test-tool date time_t-is64bit' 1960 1961 test_lazy_prereq CURL ' 1962 curl --version 1963 ' 1964 1965 test_lazy_prereq WITH_BREAKING_CHANGES ' 1966 test -n "$WITH_BREAKING_CHANGES" 1967 ' 1968 1969 test_lazy_prereq WITHOUT_BREAKING_CHANGES ' 1970 # Signal that this prereq should not be used. 1971 exit 125 1972 ' 1973 1974 # SHA1 is a test if the hash algorithm in use is SHA-1. This is both for tests 1975 # which will not work with other hash algorithms and tests that work but don't 1976 # test anything meaningful (e.g. special values which cause short collisions). 1977 test_lazy_prereq SHA1 ' 1978 case "$GIT_DEFAULT_HASH" in 1979 sha1) true ;; 1980 "") test $(git hash-object /dev/null) = `e69de29bb2d1d6434b8b29ae775ad8c2e48c5391` ;; 1981 *) false ;; 1982 esac 1983 ' 1984 1985 test_lazy_prereq DEFAULT_HASH_ALGORITHM ' 1986 test "$GIT_TEST_BUILTIN_HASH" = "$GIT_DEFAULT_HASH" 1987 ' 1988 1989 test_lazy_prereq DEFAULT_REPO_FORMAT ' 1990 test_have_prereq SHA1,REFFILES 1991 ' 1992 # BROKEN_OBJECTS is a test whether we can write deliberately broken objects and 1993 # expect them to work. When running using SHA-256 mode with SHA-1 1994 # compatibility, we cannot write such objects because there's no SHA-1 1995 # compatibility value for a nonexistent object. 1996 test_lazy_prereq BROKEN_OBJECTS ' 1997 ! test_have_prereq COMPAT_HASH 1998 ' 1999 2000 # COMPAT_HASH is a test if we're operating in a repository with SHA-256 with 2001 # SHA-1 compatibility. 2002 test_lazy_prereq COMPAT_HASH ' 2003 test -n "$test_repo_compat_hash_algo" 2004 ' 2005 2006 # Ensure that no test accidentally triggers a Git command 2007 # that runs the actual maintenance scheduler, affecting a user's 2008 # system permanently. 2009 # Tests that verify the scheduler integration must set this locally 2010 # to avoid errors. 2011 GIT_TEST_MAINT_SCHEDULER="none:exit 1" 2012 export GIT_TEST_MAINT_SCHEDULER 2013 2014 # Ensure that tests cannot race with background maintenance by default. 2015 GIT_TEST_MAINT_AUTO_DETACH="false" 2016 export GIT_TEST_MAINT_AUTO_DETACH 2017 2018 # Does this platform support `git fsmonitor--daemon` 2019 # 2020 test_lazy_prereq FSMONITOR_DAEMON ' 2021 git version --build-options >output && 2022 grep "feature: fsmonitor--daemon" output 2023 '