1 # Test framework from Git with modifications.
3 # Modifications Copyright (C) 2016,2017,2021 Kyle J. McKay
7 # * Many "GIT_..." variables removed -- some were kept as TESTLIB_..." instead
8 # (Except "GIT_PATH" is new and is the full path to a "git" executable)
10 # * IMPORTANT: test-lib-main.sh SHOULD NOT EXECUTE ANY CODE! A new
11 # function "test_lib_main_init" has been added that will be called
12 # and MUST contain any lines of code to be executed. This will ALWAYS
13 # be the LAST function defined in this file for easy locatability.
15 # * Added cmd_path, _?fatal, whats_the_dir, vcmp, getcmd, say_tap, say_color_tap,
16 # fail_, test_possibly_broken_ok_ and test_possibly_broken_failure_ functions
18 # * Anything related to valgrind or perf has been stripped out
20 # * Many other minor changes
22 # Copyright (C) 2005 Junio C Hamano
24 # This program is free software: you can redistribute it and/or modify
25 # it under the terms of the GNU General Public License as published by
26 # the Free Software Foundation, either version 2 of the License, or
27 # (at your option) any later version.
29 # This program is distributed in the hope that it will be useful,
30 # but WITHOUT ANY WARRANTY; without even the implied warranty of
31 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 # GNU General Public License for more details.
34 # You should have received a copy of the GNU General Public License
35 # along with this program. If not, see https://www.gnu.org/licenses/ .
38 ## IMPORTANT: THIS FILE MUST NOT CONTAIN ANYTHING OTHER THAN FUNCTION
39 ## DEFINITIONS!!! INITIALIZATION GOES IN THE LAST FUNCTION
40 ## DEFINED IN THIS FILE "test_lib_main_init" AS REQUIRED!
44 { "unset" -f command unset unalias "$1"; } >/dev
/null
2>&1 ||
:
45 { "unalias" -a ||
unalias -m "*"; } >/dev
/null
2>&1 ||
:
50 printf '%s\n' "$*" >&2
54 fatal
() { _fatal
"$@"; }
56 # usage: cmdget <varname> <cmd> [<arg>...]
57 # return code is that of <cmd> [<arg...]
58 # <varname> is set to VERBATIM <cmd> output (except NULs may not be handled)
60 [ -n "$1" ] ||
return 1
61 eval "$1=" >/dev
/null
2>&1 ||
return 1
62 [ -n "$2" ] ||
return 1
66 _getcmd_result
="$(ec=0; ("$@
") || ec=$?; echo Z; exit $ec)" || _getcmd_ec
=$?
67 eval "$_getcmd_vn=\"\${_getcmd_result%Z}\""
71 # usage: whats_the_dir [-P | -L] [--] path-to-something varname
72 # determine path-to-something's directory and store it into varname
73 # without "-P" or "-L" a relative dirname may be returned
75 # determine "$1"'s directory and store it into the var name passed as "$2"
76 if [ "z$1" = "z-P" ] ||
[ "z$1" = "z-L" ]; then
77 if [ "z$2" = "z--" ]; then
82 elif [ "z$1" = "z--" ]; then
85 case "$1" in *"/"*);;*) set -- "./$1" "$2" "$3"; esac
87 set -- "$(readlink "$1")" "$2" "$3" "$1"
88 case "$1" in "/"*);;*)
89 set -- "${4%/*}/$1" "$2" "$3"
92 set -- "${1%/*}" "$2" "$3"
93 if [ "z$3" != "z" ] && [ -d "$1" ] &&
94 ! case "$1" in [!/]*|
*"/./"*|
*"/."|
*"/../"*|
*"/..") ! :; esac; then
95 [ "z$3" = "z-P" ] ||
set -- "$1" "$2"
96 if [ "z$3" = "z" ] && { [ "z$1" = "z." ] ||
[ "z$1" = "z$PWD" ]; }; then
99 set -- "$(cd "$1" && pwd $3)" "$2"
106 # Compare $1 to $3 each of which must match ^[^0-9]*\d*(\.\d*)*.*$
107 # where only the "\d*" parts in the regex participate in the comparison
108 # Since EVERY string matches that regex this function is easy to use
109 # An empty string ('') for $1 or $3 or any "\d*" part is treated as 0
110 # $2 is a compare op '<', '<=', '=', '==', '!=', '>=', '>'
111 # Return code is 0 for true, 1 for false (or unknown compare op)
112 # There is NO difference in behavior between '=' and '=='
113 # Note that "vcmp 1.8 == 1.8.0.0.0.0" correctly returns 0
114 set -- "$1" "$2" "$3" "${1%%[0-9]*}" "${3%%[0-9]*}"
115 set -- "${1#"$4"}" "$2" "${3#"$5"}"
116 set -- "${1%%[!0-9.]*}" "$2" "${3%%[!0-9.]*}"
120 [ "z$vcmp_a_" != "z" ] ||
[ "z$vcmp_b_" != "z" ]
122 if [ "${vcmp_a_:-0}" -lt "${vcmp_b_:-0}" ]; then
123 unset_ vcmp_a_ vcmp_b_
124 case "$2" in "<"|
"<="|
"!=") return 0; esac
126 elif [ "${vcmp_a_:-0}" -gt "${vcmp_b_:-0}" ]; then
127 unset_ vcmp_a_ vcmp_b_
128 case "$2" in ">"|
">="|
"!=") return 0; esac
131 vcmp_a_
="${1#$vcmp_a_}"
132 vcmp_b_
="${3#$vcmp_b_}"
133 set -- "${vcmp_a_#.}" "$2" "${vcmp_b_#.}"
135 unset_ vcmp_a_ vcmp_b_
136 case "$2" in "="|
"=="|
"<="|
">=") return 0; esac
143 say_color error
"${LF}error: $*" >&7
144 printf '%s\n' "Bail out! ${0##*/}:${callerlno:+$callerlno:} error: $*" >&5
145 test_results_dir
="${TEST_OUTPUT_DIRECTORY:-.}/test-results"
146 mkdir
-p "$test_results_dir"
147 printf '%s\n' "Bail out! ${0##*/}:${callerlno:+$callerlno:} error: $*" >>"$test_results_dir/bailout"
149 [ -z "$TESTLIB_TEST_PARENT_INT_ON_ERROR" ] ||
{
152 -$TESTLIB_TEST_PARENT_INT_ON_ERROR -$PPID \
153 $TESTLIB_TEST_PARENT_INT_ON_ERROR $PPID 0 ||
:
161 alias error
='error_lno "$LINENO"' >/dev
/null
2>&1 ||
:
168 say_color_tap info
"$@"
172 code
=${EXITCODE_:-$?}
173 if test -n "$TESTLIB_EXIT_OK"
178 msg
="${msg:+($code) }$msg"
179 [ -n "$msg" ] || msg
=" Unexpected exit with code $code"
180 echo >&5 "FATAL:$msg"
186 # You are not expected to call test_ok_ and test_failure_ directly, use
187 # the test_expect_* functions instead.
190 test_success
=$
(($test_success + 1))
191 say_color_tap
"" "ok $test_count - $@"
195 test_failure
=$
(($test_failure + 1))
198 say_color_tap error
"not ok $test_count - $1"
199 if test z
"${TESTLIB_TEST_TAP_ONLY:-0}" != z
"0"; then
201 say_color_tap
"" "# failed: ${0##*/}${tlno:+:$tlno}: $test_count - $1"
203 ttit
="$test_count - $1"
205 printf '%s\n' "$(printf '%s\n' "failed
: ${0##*/}${tlno:+:$tlno}: $ttit$LF$
*")" |
227 test "$immediate" = "" ||
{ TESTLIB_EXIT_OK
=t
; exit 1; }
230 test_known_broken_ok_
() {
231 test_fixed
=$
(($test_fixed + 1))
232 say_color_tap warn
"ok $test_count - $@ # TODO known breakage vanished"
235 test_known_broken_failure_
() {
236 test_broken
=$
(($test_broken + 1))
237 say_color_tap warn
"not ok $test_count - $@ # TODO known breakage"
240 test_possibly_broken_ok_
() {
241 test_success
=$
(($test_success + 1))
242 say_color_tap
"" "ok $test_count - $@"
245 test_possibly_broken_failure_
() {
246 test_broken
=$
(($test_broken + 1))
247 say_color_tap warn
"not ok $test_count - $@ # TODO tolerated breakage"
251 test "$debug" = "" ||
test $# -eq 0 ||
test -z "$*" ||
{ "$@"; } >&7 2>&1
254 match_pattern_list
() {
257 test -z "$*" && return 1
268 match_test_selector_list
() {
273 test -z "$1" && return 0
275 # Both commas and whitespace are accepted as separators.
281 # If the first selector is negative we include by default.
289 orig_selector
=$selector
295 selector
=${selector##?}
299 test -z "$selector" && continue
303 if x_
="${selector%%-*}" && test "z$x_" != "z${x_#*[!0-9]}"
305 echo "error: $title: invalid non-numeric in range" \
306 "start: '$orig_selector'" >&2
309 if x_
="${selector#*-}" && test "z$x_" != "z${x_#*[!0-9]}"
311 echo "error: $title: invalid non-numeric in range" \
312 "end: '$orig_selector'" >&2
318 if test "z$selector" != "z${selector#*[!0-9]}"
320 echo "error: $title: invalid non-numeric in test" \
321 "selector: '$orig_selector'" >&2
326 # Short cut for "obvious" cases
327 test -z "$include" && test -z "$positive" && continue
328 test -n "$include" && test -n "$positive" && continue
332 if test $arg -le ${selector#-}
338 if test $arg -ge ${selector%-}
344 if test ${selector%%-*} -le $arg \
345 && test $arg -le ${selector#*-}
351 if test $arg -eq $selector
362 maybe_teardown_verbose
() {
363 test -z "$verbose_list" && return
364 exec 4>/dev
/null
3>/dev
/null
368 maybe_setup_verbose
() {
369 test -z "$verbose_list" && return
370 if match_test_selector_list
'--verbose-only' $test_count "$verbose_list"
372 if test "$verbose_log" = "t"
374 exec 3>>"$TESTLIB_TEST_TEE_OUTPUT_FILE" 4>&3
378 # Emit a delimiting blank line when going from
379 # non-verbose to verbose. Within verbose mode the
380 # delimiter is printed by test_expect_*. The choice
381 # of the initial $last_verbose is such that before
382 # test 1, we do not print it.
383 test -z "$last_verbose" && echo >&3 ""
386 exec 4>/dev
/null
3>/dev
/null
389 last_verbose
=$verbose
401 test "$trace" = t
&& test "$verbose" = t
404 # This is a separate function because some tests use
405 # "return" to end a test_expect_success block early
406 # (and we want to make sure we run any cleanup like
409 # Do not add anything extra (including LF) after '$*'
412 test_subshell_active_=t
413 ! want_trace || ! set -x && ! :
417 # Same thing as test_eval_inner_ but without the subshell
418 test_eval_inner_no_subshell_
() {
419 # Do not add anything extra (including LF) after '$*'
421 ! want_trace || ! set -x && ! :
426 # We run this block with stderr redirected to avoid extra cruft
427 # during a "-x" trace. Once in "set -x" mode, we cannot prevent
428 # the shell from printing the "set +x" to turn it off (nor the saving
429 # of $? before that). But we can make sure that the output goes to
432 # The test itself is run with stderr put back to &4 (so either to
433 # /dev/null, or to the original stderr if --verbose was used).
437 if test "${test_eval_ss_:-0}" = "0"
439 test_eval_inner_no_subshell_
"$@" </dev
/null
>&3 2>&4
441 test_eval_inner_
"$@" </dev
/null
>&3 2>&4
447 if test "$test_eval_ret_" != 0
449 say_color error
>&4 "error: last command exited with \$?=$test_eval_ret_"
453 return $test_eval_ret_
456 # Calls the real test_eval_ss_ with !"$TESTLIB_TEST_NO_SUBSHELL" as first arg
458 if test -n "$TESTLIB_TEST_NO_SUBSHELL"
460 test_eval_ss_
"0" "$@"
462 test_eval_ss_
"1" "$@"
466 # If "$1" = "-" read the script from stdin but ONLY if stdin is NOT a tty
467 # Store the test script in test_script_
471 ! test -t 0 || error
"test script is '-' but STDIN is a tty"
472 test_script_
="$(cat)"
473 test -n "$test_script_" || error
"test script is '-' but STDIN is empty"
474 test_script_
="$LF$test_script_$LF"
480 # protects against use of "return" in test_when_finished scripts
486 test z
"$2" = "z" ||
set +e
491 test_cleanup
="$TRASHTMP_DIRECTORY/test_when_finished_${test_count:-0}.sh"
492 ! test -e "$test_cleanup" ||
{
493 rm -f "$test_cleanup" &&
494 ! test -e "$test_cleanup" ||
495 error
"FATAL: Cannot prepare test area"
497 test_subshell_active_
=
501 if test "${TESTLIB_TEST_CHAIN_LINT:-1}" != 0; then
502 # turn off tracing for this test-eval, as it simply creates
503 # confusing noise in the "-x" output
507 # 117 is magic because it is unlikely to match the exit
508 # code of other programs
509 test_eval_ss_
"1" "fail_ 117 && $1${LF}fail_ \$? 1"
510 if test "$?" != 117; then
511 error
"bug in the test script: broken &&-chain: $1"
520 if test -z "$immediate" ||
test $eval_ret = 0 ||
521 test -n "$expecting_failure" && test -s "$test_cleanup"
523 test_eval_ss_
"0" 'test_do_script_ "$test_cleanup" && (exit $eval_ret); eval_ret=$?'
525 if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
533 test_count
=$
(($test_count+1))
538 test z
"$to_skip" = z
"q" ||
echo >&3 ""
539 maybe_teardown_verbose
545 if match_pattern_list
$this_test.
$test_count $TESTLIB_SKIP_TESTS
548 skipped_reason
="TESTLIB_SKIP_TESTS"
550 if test -z "$to_skip" && test -n "$run_list" &&
551 ! match_test_selector_list
'--run' $test_count "$run_list"
554 skipped_reason
="--run"
556 if test -z "$to_skip" && test -n "$test_prereq" &&
557 ! test_have_prereq
"$test_prereq"
562 if test "$missing_prereq" != "$test_prereq_fmt"
564 of_prereq
=" of $test_prereq_fmt"
566 skipped_reason
="missing $missing_prereq${of_prereq}"
571 if test z
"$runquiet" = z ||
test z
"$skipped_reason" != z
"--run"; then
572 say_color skip
>&3 "skipping test: $@"
573 say_color_tap skip
"ok $test_count # skip $1 ($skipped_reason)"
585 # stub; runs at end of each successful test
586 test_at_end_hook_
() {
590 # returns 1 if counts do not match
591 # $1 is extra message, if any
592 test_done_write_plan_
() {
593 if test $test_external_has_tap -eq 0
596 test -z "$test_called_test_plan" &&
599 test z
"$test_count" != z
"0"
602 say_color_tap warn
"# please add test_plan call"
604 test -n "$test_wrote_plan_count" || say_tap
"1..$test_count$1"
606 if test -n "$test_wrote_plan_count" && test "$test_wrote_plan_count" -ne "$test_count"
608 say_color_tap error
"# $this_test plan count of $test_wrote_plan_count does not match run count of $test_count"
617 if test -z "$HARNESS_ACTIVE"
619 test_results_dir
="${TEST_OUTPUT_DIRECTORY:-.}/test-results"
620 mkdir
-p "$test_results_dir"
622 test_results_path
="$test_results_dir/${base%.sh}.counts"
624 cat >"$test_results_path" <<-EOF
626 success $test_success
634 if test "$test_fixed" != 0
636 say_color_tap error
"# $this_test $test_fixed known breakage(s) vanished; please update test(s)"
638 if test "$test_broken" != 0
640 say_color_tap warn
"# $this_test still have $test_broken known breakage(s)"
642 if test "$test_broken" != 0 ||
test "$test_fixed" != 0
644 test_remaining
=$
(( $test_count - $test_broken - $test_fixed ))
645 msg
="remaining $test_remaining test(s)"
647 test_remaining
=$test_count
648 msg
="$test_count test(s)"
650 case "$test_failure" in
652 # Maybe print SKIP message
653 if test -n "$skip_all" && test $test_count -gt 0
655 error
"Can't use skip_all after running some tests"
657 test -z "$skip_all" || skip_all
=" # SKIP $skip_all"
659 if test $test_external_has_tap -eq 0
661 if test $test_remaining -gt 0
663 say_color_tap pass
"# $this_test passed all $msg"
666 test_done_write_plan_
"$skip_all" ||
exit 1
668 test -n "$remove_trash" &&
669 test -d "$remove_trash" &&
670 cd "${remove_trash%/*}" &&
671 test_done_td_
="${remove_trash##*/}" &&
672 test -e "$test_done_td_" &&
673 { rm -rf "$test_done_td_" ||
:; } >/dev
/null
2>&1 &&
675 ! test -e "$test_done_td_" ||
{
676 chmod -R u
+rw
"$test_done_td_" &&
677 rm -rf "$test_done_td_"
680 test -n "$remove_trashtmp" &&
681 test -d "$remove_trashtmp" &&
682 cd "${remove_trashtmp%/*}" &&
683 test_done_td_
="${remove_trashtmp##*/}" &&
684 test -e "$test_done_td_" &&
685 { rm -rf "$test_done_td_" ||
:; } >/dev
/null
2>&1 &&
687 ! test -e "$test_done_td_" ||
{
688 chmod -R u
+rw
"$test_done_td_" &&
689 rm -rf "$test_done_td_"
698 if test $test_external_has_tap -eq 0
700 say_color_tap error
"# $this_test failed $test_failure among $msg"
702 test_done_write_plan_ ||
:
704 test -z "$HARNESS_ACTIVE" ||
exit 0
711 test z
"$test_called_test_plan" = z || fatal
"test_plan may not be called more than once"
712 test_called_test_plan
=1
713 test z
"$*" != z
"?" ||
return 0
714 test -n "$1" && test "z$1" = "z${1#*[!0-9]}" || fatal
"invalid test_plan argument: $1"
715 test "$1" -eq 0 ||
test z
"$1" = z
"$*" || fatal
"invalid test_plan arguments: $*"
716 if test "$1" -eq 0; then
719 skip_all
="${msg:-skip all tests in $this_test}"
722 if test z
"$runquiet" = z
; then
723 test $test_external_has_tap -ne 0 || say_tap
"1..$1"
724 test_wrote_plan_count
="$1"
728 # Provide an implementation of the 'yes' utility
745 run_with_limited_cmdline
() {
746 (ulimit -s 128 && "$@")
749 # internal use function
750 test_ensure_temp_dir_
() {
751 test z
"$TRASHTMP_DIRECTORY" != z ||
752 fatal
"${1:+$1 called but }TRASHTMP_DIRECTORY is not set yet"
753 test -d "$TRASHTMP_DIRECTORY" ||
{
754 mkdir
"$TRASHTMP_DIRECTORY" &&
755 test -d "$TRASHTMP_DIRECTORY"
756 } || fatal
"could not create temp directory \"$TRASHTMP_DIRECTORY\""
758 test -d "$TRASHTMP_DIRECTORY/$2" ||
{
759 mkdir
"$TRASHTMP_DIRECTORY/$2" &&
760 test -d "$TRASHTMP_DIRECTORY/$2"
761 } || fatal
"could not create temp subdirectory \"$TRASHTMP_DIRECTORY/$2\""
764 # test_get_temp [-d] [<name>]
765 # creates a new temporary file (or directory with -d) in the
766 # temporary directory $TRASHTMP_DIRECTORY with pattern prefix NAME
768 test_ensure_temp_dir_
"test_get_temp"
769 test z
"$1" != z
"-d" ||
set -- "$2" "$1"
770 mktemp
$2 "$TRASHTMP_DIRECTORY/${1:+$1.}XXXXXX"
775 ## Note that the following functions have bodies that are NOT indented
776 ## to assist with readability
780 test_lib_main_init_tee
() {
781 # Begin test_lib_main_init_tee
784 # if --tee was passed, write the output not only to the terminal, but
785 # additionally to the file test-results/$BASENAME.out, too.
786 case "$TESTLIB_TEST_TEE_STARTED, $* " in
788 # do not redirect again
790 *' --tee '*|
*' --verbose-log '*)
791 mkdir
-p "$TEST_OUTPUT_DIRECTORY/test-results"
792 BASE
="$TEST_OUTPUT_DIRECTORY/test-results/${0##*/}"
795 # Make this filename available to the sub-process in case it is using
797 TESTLIB_TEST_TEE_OUTPUT_FILE
=$BASE.out
798 export TESTLIB_TEST_TEE_OUTPUT_FILE
800 # Truncate before calling "tee -a" to get rid of the results
801 # from any previous runs.
802 >"$TESTLIB_TEST_TEE_OUTPUT_FILE"
805 (ec
=0; TESTLIB_TEST_TEE_STARTED
=done ${SHELL_PATH} "$0" "$@" 2>&1 || ec
=$?
806 echo $ec >"$BASE.exit") |
tee -a "$TESTLIB_TEST_TEE_OUTPUT_FILE"
807 exitcode
="$(cat "$BASE.
exit" 2>/dev/null)" ||
:
813 # End test_lib_main_init_tee
817 test_lib_main_init_funcs
() {
818 # Begin test_lib_main_init_funcs
821 [ -z "$test_lib_main_init_funcs_done" ] ||
return 0
823 if test z
"$color" != z
826 test z
"$1" != z ||
test z
"${TESTLIB_TEST_TAP_ONLY:-0}" = z
"0" ||
return 0
828 test -z "$1" && test -n "$quiet" && test -z "$verbose" && return
829 eval "say_color_color=\$say_color_$1"
833 if test -n "$HARNESS_ACTIVE"
835 case "$_sms" in '#'*)
840 printf '%s\n' "$_sfc$say_color_color$_sms$say_color_reset"
844 test z
"$1" != z ||
test z
"${TESTLIB_TEST_TAP_ONLY:-0}" = z
"0" ||
return 0
846 test -z "$1" && test -n "$quiet" && test -z "$verbose" && return
853 say_color
() { say_color_
"" "$@"; }
855 # Just like say_color except if HARNESS_ACTIVE it's ALWAYS output and WITHOUT color
857 if test -n "$HARNESS_ACTIVE"
867 # Fix some commands on Windows
868 case "${UNAME_S:=$(uname -s)}" in
870 # Windows has its own (incompatible) sort and find
880 # git sees Windows-style pwd
887 test_lib_main_init_funcs_done
=1
890 # End test_lib_main_init_funcs
894 # This function is called with all the test args and must perform all
895 # initialization that involves variables and is not specific to "$0"
896 # or "$test_description" in any way. This function may only be called
897 # once per run of the entire test suite.
898 test_lib_main_init_generic
() {
899 # Begin test_lib_main_init_generic
901 [ -n "$TESTLIB_DIRECTORY" ] || whats_the_dir
-L -- "${TEST_DIRECTORY:-.}/test-lib.sh" TESTLIB_DIRECTORY
902 [ -f "$TESTLIB_DIRECTORY/test-lib.sh" ] && [ -f "$TESTLIB_DIRECTORY/test-lib-main.sh" ] &&
903 [ -f "$TESTLIB_DIRECTORY/test-lib-functions.sh" ] &&
904 [ -f "$TESTLIB_DIRECTORY/test-lib-functions-tg.sh" ] ||
905 fatal
"error: invalid TESTLIB_DIRECTORY: $TESTLIB_DIRECTORY"
906 export TESTLIB_DIRECTORY
908 ! [ -f "$TESTLIB_DIRECTORY/../TG-BUILD-SETTINGS" ] || .
"$TESTLIB_DIRECTORY/../TG-BUILD-SETTINGS"
909 ! [ -f "$TESTLIB_DIRECTORY/TG-TEST-SETTINGS" ] || .
"$TESTLIB_DIRECTORY/TG-TEST-SETTINGS"
911 : "${SHELL_PATH:=/bin/sh}"
914 case "$AWK_PATH" in */*);;*) AWK_PATH
="/usr/bin/$AWK_PATH"; esac
915 [ "$GIT_PATH" = "/${GIT_PATH#?}" ] || GIT_PATH
="$(cmd_path "${GIT_PATH:-git}")"
917 [ "$SHELL_PATH" = "/${SHELL_PATH#?}" ] || fatal
"SHELL_PATH must be absolute: $SHELL_PATH"
918 [ "$AWK_PATH" = "/${AWK_PATH#?}" ] || fatal
"AWK_PATH must be absolute: $AWK_PATH"
920 # Test the binaries we have just built. The tests are kept in
921 # t/ subdirectory and are run in 'trash directory' subdirectory.
922 if test -z "$TEST_DIRECTORY"
924 # We allow tests to override this, in case they want to run tests
925 # outside of t/, e.g. for running tests on the test library
927 TEST_DIRECTORY
="$TESTLIB_DIRECTORY"
929 # ensure that TEST_DIRECTORY is an absolute path so that it
930 # is valid even if the current working directory is changed
931 TEST_DIRECTORY
="$(cd "$TEST_DIRECTORY" && pwd)" ||
exit 1
933 if test -z "$TEST_HELPER_DIRECTORY" && test -d "$TEST_DIRECTORY/helper"
935 TEST_HELPER_DIRECTORY
="$TEST_DIRECTORY/helper"
937 if test -z "$TEST_OUTPUT_DIRECTORY"
939 # Similarly, override this to store the test-results subdir
941 TEST_OUTPUT_DIRECTORY
="$TEST_DIRECTORY"
943 [ -d "$TESTLIB_DIRECTORY"/empty
] ||
{
944 mkdir
"$TESTLIB_DIRECTORY/empty" ||
:
945 chmod a-w
"$TESTLIB_DIRECTORY/empty" ||
:
946 test -d "$TESTLIB_DIRECTORY"/empty ||
947 fatal
"error: could not make empty directory: '$TESTLIB_DIRECTORY/empty'"
949 GIT_IN_PATH
="$(cmd_path git)" ||
:
950 if test x
"$GIT_IN_PATH" = x
"$GIT_PATH"
952 if [ -e "$TESTLIB_DIRECTORY/git/git" ]
954 rm -f "$TESTLIB_DIRECTORY/git/git"
955 ! test -e "$TESTLIB_DIRECTORY/git/git" ||
956 fatal
"error: could not make git shim go away: '$TESTLIB_DIRECTORY/git/git'"
959 case "$GIT_PATH" in *"'"*)
960 fatal
"error: GIT_PATH may not contain any single quote (') characters: $GIT_PATH"
962 case "$SHELL_PATH" in *" "*|
*'"'*|
*"'"*)
963 fatal
"error: SHELL_PATH may not contain any single/double quotes or spaces: $SHELL_PATH"
965 [ -d "$TESTLIB_DIRECTORY"/git
] ||
{
966 mkdir
-p "$TESTLIB_DIRECTORY/git" ||
:
967 test -d "$TESTLIB_DIRECTORY"/git
&&
968 test -w "$TESTLIB_DIRECTORY"/git ||
969 fatal
"error: could not make git directory: '$TESTLIB_DIRECTORY/git'"
971 git_shim_script
="#!$SHELL_PATH"'
972 exec '"'$GIT_PATH'"' "$@"'
974 ! test -x "$TESTLIB_DIRECTORY/git/git" ||
975 ! test x
"$git_shim_script" = x
"$(cat "$TESTLIB_DIRECTORY/git
/git
")"
977 printf '%s\n' "$git_shim_script" >"$TESTLIB_DIRECTORY/git/git.$$" &&
978 chmod a
+rx
"$TESTLIB_DIRECTORY/git/git.$$" &&
979 mv -f "$TESTLIB_DIRECTORY/git/git.$$" "$TESTLIB_DIRECTORY/git/git" &&
980 test -x "$TESTLIB_DIRECTORY/git/git" &&
981 test x
"$git_shim_script" = x
"$(cat "$TESTLIB_DIRECTORY/git
/git
")" ||
982 fatal
"error: could not make git shim: '$TESTLIB_DIRECTORY/git/git'"
985 EMPTY_DIRECTORY
="$TESTLIB_DIRECTORY/empty"
986 export TEST_DIRECTORY TEST_HELPER_DIRECTORY TEST_OUTPUT_DIRECTORY EMPTY_DIRECTORY
987 GIT_CEILING_DIRECTORIES
="$TESTLIB_DIRECTORY"
988 [ "$TESTLIB_DIRECTORY" = "$TEST_DIRECTORY" ] ||
989 GIT_CEILING_DIRECTORIES
="$TEST_DIRECTORY:$GIT_CEILING_DIRECTORIES"
990 [ "$TESTLIB_DIRECTORY" = "$TEST_OUTPUT_DIRECTORY" ] ||
991 GIT_CEILING_DIRECTORIES
="$TEST_OUTPUT_DIRECTORY:$GIT_CEILING_DIRECTORIES"
992 export GIT_CEILING_DIRECTORIES
994 ################################################################
995 # It appears that people try to run tests with missing git...
996 git_version
="$("$GIT_PATH" --version 2>&1)" ||
997 fatal
'error: you do not seem to have git available?'
998 [ "$GIT_PATH" = "/${GIT_PATH#?}" ] || fatal
"GIT_PATH must be absolute: $GIT_PATH"
999 case "$git_version" in [Gg
][Ii
][Tt
]\
[Vv
][Ee
][Rr
][Ss
][Ii
][Oo
][Nn
]\
[0-9]*);;*)
1000 fatal
"error: git --version returned bogus value: $git_version"
1003 ! vcmp
"$git_version" '>=' "2.9" || test_auh
="--allow-unrelated-histories"
1005 ! vcmp
"$git_version" '>=' "2.29" || test_git229_plus
=1
1007 test_lib_main_init_tee
"$@"
1009 # For repeatability, reset the environment to known value.
1010 # TERM is sanitized below, after saving color control sequences.
1015 export LANG LC_ALL PAGER TZ
1017 # A call to "unset" with no arguments causes at least Solaris 10
1018 # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets
1019 # deriving from the command substitution clustered with the other
1021 unset_ VISUAL EMAIL LANGUAGE COLUMNS $
("${AWK_PATH:-awk}" '
1037 CEILING_DIRECTORIES \
1040 for (i in ok) reok = reok ok[i] "|"
1041 reok = substr(reok, 1, length(reok) - 1) ")"
1042 for (e in ENVIRON) {
1043 if (e ~ /^GIT_/ && e !~ reok) print e
1047 unset_ XDG_CONFIG_HOME
1049 GIT_AUTHOR_NAME
='Te s t (Author)'
1050 GIT_AUTHOR_EMAIL
=test@example.net
1051 GIT_COMMITTER_NAME
='Fra mewor k (Committer)'
1052 GIT_COMMITTER_EMAIL
=framework@example.org
1053 GIT_MERGE_VERBOSITY
=5
1054 GIT_MERGE_AUTOEDIT
=no
1055 GIT_TEMPLATE_DIR
="$EMPTY_DIRECTORY"
1056 GIT_CONFIG_NOSYSTEM
=1
1058 export PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
1059 export GIT_MERGE_VERBOSITY GIT_MERGE_AUTOEDIT
1060 export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
1061 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
1064 # Tests using GIT_TRACE typically don't want <timestamp> <file>:<line> output
1066 export GIT_TRACE_BARE
1068 # Protect ourselves from common misconfiguration to export
1069 # CDPATH into the environment
1075 case "$GIT_TRACE" in 1|
2|
[Tt
][Rr
][Uu
][Ee
])
1082 # A regexp to match 5 and 40 hexdigits
1083 _x05
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
1084 _x40
="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
1090 # UTF-8 ZERO WIDTH NON-JOINER, which HFS+ ignores
1091 # when case-folding filenames
1092 u200c
="$(printf '\342\200\214')"
1094 export _x05 _x40 LF u200c
1097 while test "$#" -ne 0
1100 -d|
--d|
--de|
--deb|
--debu|
--debug)
1102 -i|
--i|
--im|
--imm|
--imme|
--immed|
--immedi|
--immedia|
--immediat|
--immediate)
1103 immediate
=t
; shift ;;
1104 -l|
--l|
--lo|
--lon|
--long|
--long-|
--long-t|
--long-te|
--long-tes|
--long-test|
--long-tests|\
1105 --ex|
--exp|
--expe|
--expen|
--expens|
--expensi|
--expensiv|
--expensive)
1106 TESTLIB_TEST_LONG
=t
; export TESTLIB_TEST_LONG
; shift ;;
1108 shift; test "$#" -ne 0 ||
{
1109 echo 'error: -r requires an argument' >&2;
1112 run_list
=$1; shift ;;
1114 run_list
=${1#--*=}; shift ;;
1115 -h|
--h|
--he|
--hel|
--help)
1118 shift; test "$#" -ne 0 ||
{
1119 echo 'error: --hash requires an argument' >&2;
1122 hash_opt
="$1"; shift ;;
1124 hash_opt
="${1#--*=}"; shift ;;
1125 -v|
--v|
--ve|
--ver|
--verb|
--verbo|
--verbos|
--verbose)
1128 verbose_list
=${1#--*=}
1130 -q|
--q|
--qu|
--qui|
--quie|
--quiet)
1135 TESTLIB_TEST_TAP_ONLY
=1; shift;;
1137 TESTLIB_TEST_TAP_ONLY
=0; shift;;
1139 color
="--color"; shift ;;
1143 shift ;; # was handled already
1148 TESTLIB_TEST_CHAIN_LINT
=1
1151 TESTLIB_TEST_CHAIN_LINT
=0
1153 -x|
--x|
--xt|
--xtr|
--xtra|
--xtrac|
--xtrace)
1161 echo "error: unknown test option '$1'" >&2; exit 1 ;;
1165 hash_opt_orig
="$hash_opt"
1166 : "${hash_opt:=$TESTLIB_GIT_DEFAULT_HASH}"
1167 : "${hash_opt:=sha1}"
1168 test z
"$hash_opt" = zsha1 ||
test z
"$hash_opt" = zsha256 ||
{
1169 echo "error: unknown Git hash algorithm value '$hash_opt'" >&2
1172 test $hash_opt = sha1 ||
test -n "$test_git229_plus" ||
{
1173 echo "error: Git hash algorithm sha256 requires Git 2.29.0 or later" \
1174 "but found $git_version" >&2
1177 test_hash_algo
="$hash_opt"
1178 GIT_DEFAULT_HASH
="$test_hash_algo" && export GIT_DEFAULT_HASH
1179 if test -n "$hash_opt_orig"; then
1180 TESTLIB_GIT_DEFAULT_HASH
="$hash_opt" && export TESTLIB_GIT_DEFAULT_HASH
1183 test z
"$run_list" = z ||
test z
"$quiet" != z || quiet
=T
1184 test z
"$quiet" != z
"0" || quiet
=
1185 test z
"$quiet" = z ||
test z
"$run_list" = z ||
test z
"$HARNESS_ACTIVE" != z || runquiet
=t
1186 test z
"$quiet" != z
"T" || quiet
=
1188 test "x${color+set}" != "xset" &&
1189 test "x$TERM" != "xdumb" && (
1190 { test -n "$TESTLIB_FORCETTY" ||
test -t 1; } &&
1191 tput bold
>/dev
/null
2>&1 &&
1192 tput setaf
1 >/dev
/null
2>&1 &&
1193 tput sgr0
>/dev
/null
2>&1
1196 if test z
"$color" != z
1198 # Save the color control sequences now rather than run tput
1199 # each time say_color() is called. This is done for two
1201 # * TERM will be changed to dumb
1202 # * HOME will be changed to a temporary directory and tput
1203 # might need to read ~/.terminfo from the original HOME
1204 # directory to get the control sequences
1205 getcmd say_color_error
eval 'tput setaf 1' # red
1206 getcmd say_color_skip
eval 'tput bold; tput setaf 5' # bold blue
1207 getcmd say_color_warn
eval 'tput setaf 3' # brown/yellow
1208 getcmd say_color_pass
eval 'tput setaf 2' # green
1209 getcmd say_color_info
eval 'tput setaf 6' # cyan
1210 getcmd say_color_reset
eval 'tput sgr0'
1211 say_color_
="" # no formatting for normal text
1223 test_external_has_tap
=0
1225 # The user-facing functions are loaded from a separate file
1226 .
"$TESTLIB_DIRECTORY/test-lib-functions-tg.sh"
1227 .
"$TESTLIB_DIRECTORY/test-lib-functions.sh"
1228 test_lib_functions_init
1229 test_lib_functions_tg_init
1232 : "${TESTLIB_SHELL_HAS_SHOPT=$(command -v shopt)}"
1236 [ ! -x "$TESTLIB_DIRECTORY/git/git" ] || PATH
="$TESTLIB_DIRECTORY/git:$PATH"
1237 [ -n "$TEST_HELPER_DIRECTORY" ] && [ -d "$TEST_HELPER_DIRECTORY" ] && PATH
="$TEST_HELPER_DIRECTORY:$PATH" ||
:
1238 if [ -n "$TG_TEST_INSTALLED" ]; then
1239 TG_TEST_FULL_PATH
="$(cmd_path tg)" && [ -n "$TG_TEST_FULL_PATH" ] ||
1240 fatal
'error: TG_TEST_INSTALLED set but no tg found in $PATH!'
1242 tg_bin_dir
="$(cd "$TESTLIB_DIRECTORY/..
/bin-wrappers
" 2>/dev/null && pwd -P || :)"
1243 [ -x "$tg_bin_dir/tg" ] ||
1244 fatal
'error: no ../bin-wrappers/tg executable found!'
1245 PATH
="$tg_bin_dir:$PATH"
1246 TG_TEST_FULL_PATH
="$tg_bin_dir/tg"
1247 test -f "$TESTLIB_DIRECTORY/TG-TEST-SETTINGS" ||
1248 echo 'warning: no TG-TEST-SETTINGS file found (run `make settings`)' >&2
1250 export TG_TEST_FULL_PATH
1251 tg_version
="$(tg --version)" ||
1252 fatal
'error: tg --version failed!'
1253 case "$tg_version" in [Tt
][Oo
][Pp
][Gg
][Ii
][Tt
]\
[Vv
][Ee
][Rr
][Ss
][Ii
][Oo
][Nn
]\
[0-9]*);;*)
1254 fatal
"error: tg --version returned bogus value: $tg_version"
1256 # GIT_CEILING_DIRECTORIES has already been set and exported
1257 tg__top_bases
="$(cd "$EMPTY_DIRECTORY" && tg --top-bases)" ||
1258 fatal
'error: tg --top-bases failed!'
1259 case "$tg__top_bases" in
1260 "refs/top-bases") tg__top_bases
="refs";;
1261 "refs/heads/{top-bases}") tg__top_bases
="heads";;
1262 *) fatal
"error: tg --top-bases returned unknown value: $tg__top_bases";;
1265 vcmp
"$git_version" '>=' "$GIT_MINIMUM_VERSION" ||
1266 fatal
"git version >= $GIT_MINIMUM_VERSION required but found \"$git_version\" instead"
1268 if test -z "$TESTLIB_TEST_CMP"
1270 if test -n "$TESTLIB_TEST_CMP_USE_COPIED_CONTEXT"
1272 TESTLIB_TEST_CMP
="$DIFF -c"
1274 TESTLIB_TEST_CMP
="$DIFF -u"
1278 # Fix some commands on Windows
1279 case "${UNAME_S:=$(uname -s)}" in
1281 # no POSIX permissions
1282 # backslashes in pathspec are converted to '/'
1283 # exec does not inherit the PID
1284 test_set_prereq MINGW
1285 test_set_prereq NATIVE_CRLF
1286 test_set_prereq SED_STRIPS_CR
1287 test_set_prereq GREP_STRIPS_CR
1288 TESTLIB_TEST_CMP
=mingw_test_cmp
1291 test_set_prereq POSIXPERM
1292 test_set_prereq EXECKEEPSPID
1293 test_set_prereq CYGWIN
1294 test_set_prereq SED_STRIPS_CR
1295 test_set_prereq GREP_STRIPS_CR
1298 test_set_prereq POSIXPERM
1299 test_set_prereq BSLASHPSPEC
1300 test_set_prereq EXECKEEPSPID
1304 ( COLUMNS
=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
1306 test_lib_main_init_funcs
1308 test_lazy_prereq PIPE
'
1309 # test whether the filesystem supports FIFOs
1310 case "${UNAME_S:=$(uname -s)}" in
1315 rm -f testfifo && mkfifo testfifo
1320 test_lazy_prereq SYMLINKS
'
1321 # test whether the filesystem supports symbolic links
1322 ln -s x y && test -h y
1325 test_lazy_prereq FILEMODE
'
1326 test_ensure_git_dir_ &&
1327 test "$(git config --bool core.filemode)" = true
1330 test_lazy_prereq CASE_INSENSITIVE_FS
'
1331 echo good >CamelCase &&
1332 echo bad >camelcase &&
1333 test "$(cat CamelCase)" != good
1336 test_lazy_prereq UTF8_NFD_TO_NFC
'
1337 # check whether FS converts nfd unicode to nfc
1338 auml="$(printf "\303\244")"
1339 aumlcdiar="$(printf "\141\314\210")"
1349 test_lazy_prereq AUTOIDENT
'
1350 test_ensure_git_dir_ &&
1351 sane_unset GIT_AUTHOR_NAME &&
1352 sane_unset GIT_AUTHOR_EMAIL &&
1353 git var GIT_AUTHOR_IDENT
1356 test_lazy_prereq EXPENSIVE
'
1357 test -n "$TESTLIB_TEST_LONG"
1360 test_lazy_prereq GITSHA256
'
1361 test -n "$test_git229_plus"
1364 test_lazy_prereq USR_BIN_TIME
'
1365 test -x /usr/bin/time
1368 test_lazy_prereq NOT_ROOT
'
1373 # SANITY is about "can you correctly predict what the filesystem would
1374 # do by only looking at the permission bits of the files and
1375 # directories?" A typical example of !SANITY is running the test
1376 # suite as root, where a test may expect "chmod -r file && cat file"
1377 # to fail because file is supposed to be unreadable after a successful
1378 # chmod. In an environment (i.e. combination of what filesystem is
1379 # being used and who is running the tests) that lacks SANITY, you may
1380 # be able to delete or create a file when the containing directory
1381 # doesn't have write permissions, or access a file even if the
1382 # containing directory doesn't have read or execute permissions.
1384 test_lazy_prereq SANITY
'
1385 mkdir SANETESTD.1 SANETESTD.2 &&
1387 chmod +w SANETESTD.1 SANETESTD.2 &&
1388 >SANETESTD.1/x 2>SANETESTD.2/x &&
1389 chmod -w SANETESTD.1 &&
1390 chmod -r SANETESTD.1/x &&
1391 chmod -rx SANETESTD.2 ||
1392 error "bug in test sript: cannot prepare SANETESTD"
1394 ! test -r SANETESTD.1/x &&
1395 ! rm SANETESTD.1/x && ! test -f SANETESTD.2/x
1398 chmod +rwx SANETESTD.1 SANETESTD.2 &&
1399 rm -rf SANETESTD.1 SANETESTD.2 ||
1400 error "bug in test sript: cannot clean SANETESTD"
1404 test_lazy_prereq CMDLINE_LIMIT
'run_with_limited_cmdline true'
1407 # End test_lib_main_init_generic
1411 # This function is guaranteed to always be called for every single test.
1412 # Only put things in this function that MUST be done per-test, function
1413 # definitions and sourcing other files generally DO NOT QUALIFY (there can
1415 test_lib_main_init_specific
() {
1416 # Begin test_lib_main_init_specific
1419 # original stdin is on 6, stdout on 5 and stderr on 7
1422 test_lib_main_init_funcs
1424 if test -n "$HARNESS_ACTIVE"
1426 if test "$verbose" = t ||
test -n "$verbose_list" && test -z "$verbose_log$TESTLIB_OVERRIDE"
1428 printf 'Bail out! %s\n' \
1429 'verbose mode forbidden under TAP harness; use --verbose-log'
1434 test z
"${TESTLIB_TEST_TAP_ONLY:-0}" = z
"0" ||
test -z "$verbose$verbose_list" ||
1435 test -n "$verbose_log$TESTLIB_OVERRIDE" ||
{
1436 if test z
"$TESTLIB_TEST_TAP_ONLY" = z
"-1"; then
1437 unset_ TESTLIB_TEST_TAP_ONLY
1438 say_color
"" "# auto-deactivating TESTLIB_TEST_TAP_ONLY=-1 in verbose mode"
1440 printf 'Bail out! %s\n' \
1441 'verbose mode forbidden with TESTLIB_TEST_TAP_ONLY; use --verbose-log'
1446 test "${test_description}" != "" ||
1447 error
"Test script did not set test_description."
1449 if test "$help" = "t"
1451 printf '%s\n' "$(printf '%s\n' "$test_description")" |
1466 if test "$verbose_log" = "t"
1468 exec 3>>"$TESTLIB_TEST_TEE_OUTPUT_FILE" 4>&3
1469 elif test "$verbose" = "t"
1473 exec 4>/dev
/null
3>/dev
/null
1476 # Send any "-x" output directly to stderr to avoid polluting tests
1477 # which capture stderr. We can do this unconditionally since it
1478 # has no effect if tracing isn't turned on.
1480 # Note that this sets up the trace fd as soon as we assign the variable, so it
1481 # must come after the creation of descriptor 4 above. Likewise, we must never
1482 # unset this, as it has the side effect of closing descriptor 4, which we
1483 # use to show verbose tests to the user.
1485 # Note also that we don't need or want to export it. The tracing is local to
1486 # this shell, and we would not want to influence any shells we exec.
1491 trap 'trapexit_ 129' HUP
1492 trap 'trapexit_ 130' INT
1493 trap 'trapexit_ 131' QUIT
1494 trap 'trapexit_ 134' ABRT
1495 trap 'trapexit_ 141' PIPE
1496 trap 'trapexit_ 143' TERM
1497 trap 'TESTLIB_EXIT_OK=t; trapexit_ 1' USR1
1500 TRASH_DIRECTORY
="${0%.sh}"
1501 test z
"${TRASH_DIRECTORY##*/}" != z
"sh" || TRASH_DIRECTORY
="xsh"
1502 TRASH_DIRECTORY
="trash directory.${TRASH_DIRECTORY##*/}"
1503 TRASHTMP_DIRECTORY
="${0%.sh}"
1504 test z
"${TRASHTMP_DIRECTORY##*/}" != z
"sh" || TRASHTMP_DIRECTORY
="xsh"
1505 TRASHTMP_DIRECTORY
="trash tmp directory.${TRASHTMP_DIRECTORY##*/}"
1506 test -n "$root" && TRASH_DIRECTORY
="$root/$TRASH_DIRECTORY"
1507 test -n "$root" && TRASHTMP_DIRECTORY
="$root/$TRASHTMP_DIRECTORY"
1508 test -n "$root" && GIT_CEILING_DIRECTORIES
="$root:$GIT_CEILING_DIRECTORIES"
1509 case "$TRASH_DIRECTORY" in
1510 /*) ;; # absolute path is good
1511 *) TRASH_DIRECTORY
="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY"
1512 TRASHTMP_DIRECTORY
="$TEST_OUTPUT_DIRECTORY/$TRASHTMP_DIRECTORY" ;;
1514 test ! -z "$debug" || remove_trash
="$TRASH_DIRECTORY"
1515 test ! -z "$debug" || remove_trashtmp
="$TRASHTMP_DIRECTORY"
1516 ! test -e "$TRASH_DIRECTORY" ||
{
1517 { rm -rf "$TRASH_DIRECTORY" ||
:; } >/dev
/null
2>&1 &&
1518 ! test -e "$TRASH_DIRECTORY" ||
{
1519 chmod -R u
+rw
"$TRASH_DIRECTORY" &&
1520 rm -rf "$TRASH_DIRECTORY" &&
1521 ! test -e "$TRASH_DIRECTORY"
1524 ! test -e "$TRASHTMP_DIRECTORY" ||
{
1525 { rm -rf "$TRASHTMP_DIRECTORY" ||
:; } >/dev
/null
2>&1 &&
1526 ! test -e "$TRASHTMP_DIRECTORY" ||
{
1527 chmod -R u
+rw
"$TRASHTMP_DIRECTORY" &&
1528 rm -rf "$TRASHTMP_DIRECTORY" &&
1529 ! test -e "$TRASHTMP_DIRECTORY"
1533 echo >&5 "FATAL: Cannot prepare test area"
1537 HOME
="$TRASH_DIRECTORY"
1538 GNUPGHOME
="$HOME/gnupg-home-not-used"
1539 export HOME GNUPGHOME
1541 if test -z "$TEST_NO_CREATE_REPO"
1543 test_create_repo
"$TRASH_DIRECTORY"
1545 mkdir
-p "$TRASH_DIRECTORY"
1547 # $TRASHTMP_DIRECTORY is created on-demand only
1549 # Use -P to resolve symlinks in our working directory so that the cwd
1550 # in subprocesses like tg equals our $PWD (for pathname comparisons).
1551 cd -P "$TRASH_DIRECTORY" ||
exit 1
1554 this_test
=${this_test%%-*}
1555 test_called_test_plan
=
1556 test_wrote_plan_count
=
1557 test_last_subtest_ok
=1
1558 if match_pattern_list
"$this_test" $TESTLIB_SKIP_TESTS
1560 say_color info
>&3 "skipping test $this_test altogether"
1561 skip_all
="skip all tests in $this_test"
1565 if test z
"${TESTLIB_SHELL_HAS_SHOPT=$(command -v shopt)}" = z
"shopt"
1567 shopt -s expand_aliases
>/dev
/null
2>&1 ||
:
1570 # End test_lib_main_init_specific
1575 # THIS SHOULD ALWAYS BE THE LAST FUNCTION DEFINED IN THIS FILE
1577 # Any client that sources this file should immediately execute this function
1578 # afterwards with the command line arguments
1580 # THERE SHOULD NOT BE ANY DIRECTLY EXECUTED LINES OF CODE IN THIS FILE
1582 test_lib_main_init
() {
1584 test_lib_main_init_generic
"$@"
1585 test_lib_main_init_specific
"$@"