3 # Copyright (c) 2005 Junio C Hamano
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.
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.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see http://www.gnu.org/licenses/ .
18 # for git on windows so stdin will not be misdetected as attached to a
22 # if --tee was passed, write the output not only to the terminal, but
23 # additionally to the file test-results/$BASENAME.out, too.
24 case "$GIT_TEST_TEE_STARTED, $* " in
26 # do not redirect again
28 *' --tee '*|
*' --va'*)
30 BASE
=test-results
/$
(basename "$0" .sh
)
31 (GIT_TEST_TEE_STARTED
=done ${SHELL-sh} "$0" "$@" 2>&1;
32 echo $?
> $BASE.
exit) |
tee $BASE.out
33 test "$(cat $BASE.exit)" = 0
38 # Keep the original TERM for say_color
41 # For repeatability, reset the environment to known value.
47 export LANG LC_ALL PAGER TERM TZ
54 my $ok = join("|", qw(
63 my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
64 print join("\n", @vars);
66 GIT_AUTHOR_EMAIL
=author@example.com
67 GIT_AUTHOR_NAME
='A U Thor'
68 GIT_COMMITTER_EMAIL
=committer@example.com
69 GIT_COMMITTER_NAME
='C O Mitter'
71 export GIT_MERGE_VERBOSITY
72 export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
73 export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
76 # Protect ourselves from common misconfiguration to export
77 # CDPATH into the environment
82 case $
(echo $GIT_TRACE |
tr "[A-Z]" "[a-z]") in
84 echo "* warning: Some tests will not work if GIT_TRACE" \
85 "is set as to trace on STDERR ! *"
86 echo "* warning: Please set GIT_TRACE to something" \
87 "other than 1, 2 or true ! *"
93 # A regexp to match 5 and 40 hexdigits
94 _x05
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
95 _x40
="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
98 _z40
=0000000000000000000000000000000000000000
104 # Each test should start with something like this, after copyright notices:
106 # test_description='Description of this test...
107 # This test checks if command xyzzy does the right thing...
110 [ "x$ORIGINAL_TERM" != "xdumb" ] && (
111 TERM
=$ORIGINAL_TERM &&
114 tput bold
>/dev
/null
2>&1 &&
115 tput setaf
1 >/dev
/null
2>&1 &&
116 tput sgr0
>/dev
/null
2>&1
120 while test "$#" -ne 0
123 -d|
--d|
--de|
--deb|
--debu|
--debug)
125 -i|
--i|
--im|
--imm|
--imme|
--immed|
--immedi|
--immedia|
--immediat|
--immediate)
126 immediate
=t
; shift ;;
127 -l|
--l|
--lo|
--lon|
--long|
--long-|
--long-t|
--long-te|
--long-tes|
--long-test|
--long-tests)
128 GIT_TEST_LONG
=t
; export GIT_TEST_LONG
; shift ;;
129 -h|
--h|
--he|
--hel|
--help)
131 -v|
--v|
--ve|
--ver|
--verb|
--verbo|
--verbos|
--verbose)
133 -q|
--q|
--qu|
--qui|
--quie|
--quiet)
134 # Ignore --quiet under a TAP::Harness. Saying how many tests
135 # passed without the ok/not ok details is always an error.
136 test -z "$HARNESS_ACTIVE" && quiet
=t
; shift ;;
138 with_dashes
=t
; shift ;;
141 --va|
--val|
--valg|
--valgr|
--valgri|
--valgrin|
--valgrind)
142 valgrind
=t
; verbose
=t
; shift ;;
144 shift ;; # was handled already
146 root
=$
(expr "z$1" : 'z[^=]*=\(.*\)')
149 echo "error: unknown test option '$1'" >&2; exit 1 ;;
153 if test -n "$color"; then
159 error
) tput bold
; tput setaf
1;; # bold red
160 skip
) tput bold
; tput setaf
2;; # bold green
161 pass
) tput setaf
2;; # green
162 info
) tput setaf
3;; # brown
163 *) test -n "$quiet" && return;;
173 test -z "$1" && test -n "$quiet" && return
180 say_color error
"error: $*"
189 test "${test_description}" != "" ||
190 error
"Test script did not set test_description."
192 if test "$help" = "t"
194 echo "$test_description"
200 if test "$verbose" = "t"
204 exec 4>/dev
/null
3>/dev
/null
213 test_external_has_tap
=0
217 if test -n "$GIT_EXIT_OK"
221 echo >&5 "FATAL: Unexpected exit with code $code"
229 # The semantics of the editor variables are that of invoking
230 # sh -c "$EDITOR \"$@\"" files ...
232 # If our trash directory contains shell metacharacters, they will be
233 # interpreted if we just set $EDITOR directly, so do a little dance with
234 # environment variables to work around this.
236 # In particular, quoting isn't enough, as the path may contain the same quote
241 EDITOR
='"$FAKE_EDITOR"'
245 test_decode_color
() {
248 if (n == 0) return "RESET";
249 if (n == 1) return "BOLD";
250 if (n == 30) return "BLACK";
251 if (n == 31) return "RED";
252 if (n == 32) return "GREEN";
253 if (n == 33) return "YELLOW";
254 if (n == 34) return "BLUE";
255 if (n == 35) return "MAGENTA";
256 if (n == 36) return "CYAN";
257 if (n == 37) return "WHITE";
258 if (n == 40) return "BLACK";
259 if (n == 41) return "BRED";
260 if (n == 42) return "BGREEN";
261 if (n == 43) return "BYELLOW";
262 if (n == 44) return "BBLUE";
263 if (n == 45) return "BMAGENTA";
264 if (n == 46) return "BCYAN";
265 if (n == 47) return "BWHITE";
268 while (match($0, /\033\[[0-9;]*m/) != 0) {
269 printf "%s<", substr($0, 1, RSTART-1);
270 codes = substr($0, RSTART+2, RLENGTH-3);
271 if (length(codes) == 0)
274 n = split(codes, ary, ";");
276 for (i = 1; i <= n; i++) {
277 printf "%s%s", sep, name(ary[i]);
282 $0 = substr($0, RSTART + RLENGTH, length($0) - RSTART - RLENGTH + 1);
306 sed -e 's/$/Q/' |
tr Q
'\015'
310 tr '\015' Q |
sed -e 's/Q$//'
313 # In some bourne shell implementations, the "unset" builtin returns
314 # nonzero status when a variable to be unset was not set in the first
317 # Use sane_unset when that should not be considered an error.
325 if test -z "${test_tick+set}"
329 test_tick
=$
(($test_tick + 60))
331 GIT_COMMITTER_DATE
="$test_tick -0700"
332 GIT_AUTHOR_DATE
="$test_tick -0700"
333 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
336 # Call test_commit with the arguments "<message> [<file> [<contents>]]"
338 # This will commit a file with the given contents and the given commit
339 # message. It will also add a tag with <message> as name.
341 # Both <file> and <contents> default to <message>.
345 echo "${3-$1}" > "$file" &&
348 git commit
-m "$1" &&
352 # Call test_merge with the arguments "<message> <commit>", where <commit>
353 # can be a tag pointing to the commit-to-merge.
357 git merge
-m "$1" "$2" &&
361 # This function helps systems where core.filemode=false is set.
362 # Use it instead of plain 'chmod +x' to set or unset the executable bit
363 # of a file in the working directory and add it to the index.
367 git update-index
--add "--chmod=$@"
370 # Unset a configuration variable, but don't fail if it doesn't exist.
372 git config
--unset-all "$@"
374 case "$config_status" in
375 5) # ok, nothing to unset
379 return $config_status
382 # Set git config, automatically unsetting it after the test is over.
384 test_when_finished
"test_unconfig '$1'" &&
388 test_config_global
() {
389 test_when_finished
"test_unconfig --global '$1'" &&
390 git config
--global "$@"
393 # Use test_set_prereq to tell that a particular prerequisite is available.
394 # The prerequisite can later be checked for in two ways:
396 # - Explicitly using test_have_prereq.
398 # - Implicitly by specifying the prerequisite tag in the calls to
399 # test_expect_{success,failure,code}.
401 # The single parameter is the prerequisite tag (a simple word, in all
402 # capital letters by convention).
405 satisfied
="$satisfied$1 "
409 test_have_prereq
() {
410 # prerequisites can be concatenated with ','
422 total_prereq
=$
(($total_prereq + 1))
425 ok_prereq
=$
(($ok_prereq + 1))
428 # Keep a list of missing prerequisites
429 if test -z "$missing_prereq"
431 missing_prereq
=$prerequisite
433 missing_prereq
="$prerequisite,$missing_prereq"
438 test $total_prereq = $ok_prereq
441 test_declared_prereq
() {
442 case ",$test_prereq," in
450 # You are not expected to call test_ok_ and test_failure_ directly, use
451 # the text_expect_* functions instead.
454 test_success
=$
(($test_success + 1))
455 say_color
"" "ok $test_count - $@"
459 test_failure
=$
(($test_failure + 1))
460 say_color error
"not ok - $test_count $1"
462 echo "$@" |
sed -e 's/^/# /'
463 test "$immediate" = "" ||
{ GIT_EXIT_OK
=t
; exit 1; }
466 test_known_broken_ok_
() {
467 test_fixed
=$
(($test_fixed+1))
468 say_color
"" "ok $test_count - $@ # TODO known breakage"
471 test_known_broken_failure_
() {
472 test_broken
=$
(($test_broken+1))
473 say_color skip
"not ok $test_count - $@ # TODO known breakage"
477 test "$debug" = "" ||
eval "$1"
481 # This is a separate function because some tests use
482 # "return" to end a test_expect_success block early.
483 eval </dev
/null
>&3 2>&4 "$*"
492 if test -z "$immediate" ||
test $eval_ret = 0 ||
test -n "$expecting_failure"
494 test_eval_
"$test_cleanup"
496 if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
503 test_count
=$
(($test_count+1))
505 for skp
in $GIT_SKIP_TESTS
507 case $this_test.
$test_count in
513 if test -z "$to_skip" && test -n "$test_prereq" &&
514 ! test_have_prereq
"$test_prereq"
521 if test "$missing_prereq" != "$test_prereq"
523 of_prereq
=" of $test_prereq"
526 say_color skip
>&3 "skipping test: $@"
527 say_color skip
"ok $test_count # skip $1 (missing $missing_prereq${of_prereq})"
536 test_expect_failure
() {
537 test "$#" = 3 && { test_prereq
=$1; shift; } || test_prereq
=
539 error
"bug in the test script: not 2 or 3 parameters to test-expect-failure"
543 say
>&3 "checking known breakage: $2"
544 if test_run_
"$2" expecting_failure
546 test_known_broken_ok_
"$1"
548 test_known_broken_failure_
"$1"
554 test_expect_success
() {
555 test "$#" = 3 && { test_prereq
=$1; shift; } || test_prereq
=
557 error
"bug in the test script: not 2 or 3 parameters to test-expect-success"
561 say
>&3 "expecting success: $2"
572 # test_external runs external test scripts that provide continuous
573 # test output about their progress, and succeeds/fails on
574 # zero/non-zero exit code. It outputs the test output on stdout even
575 # in non-verbose mode, and announces the external script with "# run
576 # <n>: ..." before running it. When providing relative paths, keep in
577 # mind that all scripts run in "trash directory".
578 # Usage: test_external description command arguments...
579 # Example: test_external 'Perl API' perl ../path/to/test.pl
581 test "$#" = 4 && { test_prereq
=$1; shift; } || test_prereq
=
583 error
>&5 "bug in the test script: not 3 or 4 parameters to test_external"
587 if ! test_skip
"$descr" "$@"
589 # Announce the script to reduce confusion about the
590 # test output that follows.
591 say_color
"" "# run $test_count: $descr ($*)"
592 # Export TEST_DIRECTORY, TRASH_DIRECTORY and GIT_TEST_LONG
593 # to be able to use them in script
594 export TEST_DIRECTORY TRASH_DIRECTORY GIT_TEST_LONG
595 # Run command; redirect its stderr to &4 as in
596 # test_run_, but keep its stdout on our stdout even in
601 if test $test_external_has_tap -eq 0; then
604 say_color
"" "# test_external test $descr was ok"
605 test_success
=$
(($test_success + 1))
608 if test $test_external_has_tap -eq 0; then
609 test_failure_
"$descr" "$@"
611 say_color error
"# test_external test $descr failed: $@"
612 test_failure
=$
(($test_failure + 1))
618 # Like test_external, but in addition tests that the command generated
619 # no output on stderr.
620 test_external_without_stderr
() {
621 # The temporary file has no (and must have no) security
624 stderr
="$tmp/git-external-stderr.$$.tmp"
625 test_external
"$@" 4> "$stderr"
626 [ -f "$stderr" ] || error
"Internal error: $stderr disappeared."
627 descr
="no stderr: $1"
629 say
>&3 "# expecting no stderr from previous command"
630 if [ ! -s "$stderr" ]; then
633 if test $test_external_has_tap -eq 0; then
636 say_color
"" "# test_external_without_stderr test $descr was ok"
637 test_success
=$
(($test_success + 1))
640 if [ "$verbose" = t
]; then
641 output
=`echo; echo "# Stderr is:"; cat "$stderr"`
645 # rm first in case test_failure exits.
647 if test $test_external_has_tap -eq 0; then
648 test_failure_
"$descr" "$@" "$output"
650 say_color error
"# test_external_without_stderr test $descr failed: $@: $output"
651 test_failure
=$
(($test_failure + 1))
656 # debugging-friendly alternatives to "test [-f|-d|-e]"
657 # The commands test the existence or non-existence of $1. $2 can be
658 # given to provide a more precise diagnosis.
659 test_path_is_file
() {
662 echo "File $1 doesn't exist. $*"
667 test_path_is_dir
() {
670 echo "Directory $1 doesn't exist. $*"
675 test_path_is_missing
() {
680 if [ $# -ge 1 ]; then
687 # test_line_count checks that a file has the number of lines it
688 # ought to. For example:
690 # test_expect_success 'produce exactly one line of output' '
691 # do something >output &&
692 # test_line_count = 1 output
695 # is like "test $(wc -l <output) = 1" except that it passes the
696 # output through when the number of lines is wrong.
701 error
"bug in the test script: not 3 parameters to test_line_count"
702 elif ! test $
(wc -l <"$3") "$1" "$2"
704 echo "test_line_count: line count for $3 !$1 $2"
710 # This is not among top-level (test_expect_success | test_expect_failure)
711 # but is a prefix that can be used in the test script, like:
713 # test_expect_success 'complain and die' '
715 # do something else &&
716 # test_must_fail git checkout ../outerspace
719 # Writing this as "! git checkout ../outerspace" is wrong, because
720 # the failure could be due to a segv. We want a controlled failure.
725 if test $exit_code = 0; then
726 echo >&2 "test_must_fail: command succeeded: $*"
728 elif test $exit_code -gt 129 -a $exit_code -le 192; then
729 echo >&2 "test_must_fail: died by signal: $*"
731 elif test $exit_code = 127; then
732 echo >&2 "test_must_fail: command not found: $*"
738 # Similar to test_must_fail, but tolerates success, too. This is
739 # meant to be used in contexts like:
741 # test_expect_success 'some command works without configuration' '
742 # test_might_fail git config --unset all.configuration &&
746 # Writing "git config --unset all.configuration || :" would be wrong,
747 # because we want to notice if it fails due to segv.
752 if test $exit_code -gt 129 -a $exit_code -le 192; then
753 echo >&2 "test_might_fail: died by signal: $*"
755 elif test $exit_code = 127; then
756 echo >&2 "test_might_fail: command not found: $*"
762 # Similar to test_must_fail and test_might_fail, but check that a
763 # given command exited with a given exit code. Meant to be used as:
765 # test_expect_success 'Merge with d/f conflicts' '
766 # test_expect_code 1 git merge "merge msg" B master
769 test_expect_code
() {
774 if test $exit_code = $want_code
779 echo >&2 "test_expect_code: command exited with $exit_code, we wanted $want_code $*"
783 # test_cmp is a helper function to compare actual and expected output.
784 # You can use it like:
786 # test_expect_success 'foo works' '
787 # echo expected >expected &&
789 # test_cmp expected actual
792 # This could be written as either "cmp" or "diff -u", but:
793 # - cmp's output is not nearly as easy to read as diff -u
794 # - not all diff versions understand "-u"
800 # This function can be used to schedule some commands to be run
801 # unconditionally at the end of the test to restore sanity:
803 # test_expect_success 'test core.capslock' '
804 # git config core.capslock true &&
805 # test_when_finished "git config --unset core.capslock" &&
809 # That would be roughly equivalent to
811 # test_expect_success 'test core.capslock' '
812 # git config core.capslock true &&
814 # git config --unset core.capslock
817 # except that the greeting and config --unset must both succeed for
820 # Note that under --immediate mode, no clean-up is done to help diagnose
823 test_when_finished
() {
825 } && (exit \"\$eval_ret\"); eval_ret=\$?; $test_cleanup"
828 # Most tests can use the created repository, but some may need to create more.
829 # Usage: test_create_repo <directory>
830 test_create_repo
() {
832 error
"bug in the test script: not 1 parameter to test-create-repo"
836 cd "$repo" || error
"Cannot setup test environment"
837 "$GIT_EXEC_PATH/git-init" "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
838 error
"cannot run git init -- have you built things yet?"
839 mv .git
/hooks .git
/hooks-disabled
846 if test -z "$HARNESS_ACTIVE"; then
847 test_results_dir
="$TEST_DIRECTORY/test-results"
848 mkdir
-p "$test_results_dir"
849 test_results_path
="$test_results_dir/${0%.sh}-$$.counts"
851 cat >>"$test_results_path" <<-EOF
853 success $test_success
861 if test "$test_fixed" != 0
863 say_color pass
"# fixed $test_fixed known breakage(s)"
865 if test "$test_broken" != 0
867 say_color error
"# still have $test_broken known breakage(s)"
868 msg
="remaining $(($test_count-$test_broken)) test(s)"
870 msg
="$test_count test(s)"
872 case "$test_failure" in
874 # Maybe print SKIP message
875 [ -z "$skip_all" ] || skip_all
=" # SKIP $skip_all"
877 if test $test_external_has_tap -eq 0; then
878 say_color pass
"# passed all $msg"
879 say
"1..$test_count$skip_all"
882 test -d "$remove_trash" &&
883 cd "$(dirname "$remove_trash")" &&
884 rm -rf "$(basename "$remove_trash")"
889 if test $test_external_has_tap -eq 0; then
890 say_color error
"# failed $test_failure among $msg"
899 # Test the binaries we have just built. The tests are kept in
900 # t/ subdirectory and are run in 'trash directory' subdirectory.
901 if test -z "$TEST_DIRECTORY"
903 # We allow tests to override this, in case they want to run tests
904 # outside of t/, e.g. for running tests on the test library
906 TEST_DIRECTORY
=$
(pwd)
908 GIT_BUILD_DIR
="$TEST_DIRECTORY"/..
910 if test -n "$valgrind"
914 test "$1" = "$(readlink "$2")" ||
{
922 while test -d "$2".lock
924 say
"Waiting for lock on $2."
931 make_valgrind_symlink
() {
932 # handle only executables, unless they are shell libraries that
933 # need to be in the exec-path. We will just use "#!" as a
934 # guess for a shell-script, since we have no idea what the user
935 # may have configured as the shell path.
937 test "#!" = "$(head -c 2 <"$1")" ||
940 base
=$
(basename "$1")
941 symlink_target
=$GIT_BUILD_DIR/$base
942 # do not override scripts
943 if test -x "$symlink_target" &&
944 test ! -d "$symlink_target" &&
945 test "#!" != "$(head -c 2 < "$symlink_target")"
947 symlink_target
=..
/valgrind.sh
951 symlink_target
=..
/unprocessed-script
953 # create the link, or replace it if it is out of date
954 make_symlink
"$symlink_target" "$GIT_VALGRIND/bin/$base" ||
exit
957 # override all git executables in TEST_DIRECTORY/..
958 GIT_VALGRIND
=$TEST_DIRECTORY/valgrind
959 mkdir
-p "$GIT_VALGRIND"/bin
960 for file in $GIT_BUILD_DIR/git
* $GIT_BUILD_DIR/test-
*
962 make_valgrind_symlink
$file
964 # special-case the mergetools loadables
965 make_symlink
"$GIT_BUILD_DIR"/mergetools
"$GIT_VALGRIND/bin/mergetools"
970 ls "$path"/git-
* 2> /dev
/null |
973 make_valgrind_symlink
"$file"
977 PATH
=$GIT_VALGRIND/bin
:$PATH
978 GIT_EXEC_PATH
=$GIT_VALGRIND/bin
980 elif test -n "$GIT_TEST_INSTALLED" ; then
981 GIT_EXEC_PATH
=$
($GIT_TEST_INSTALLED/git
--exec-path) ||
982 error
"Cannot run git from $GIT_TEST_INSTALLED."
983 PATH
=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
984 GIT_EXEC_PATH
=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
985 else # normal case, use ../bin-wrappers only unless $with_dashes:
986 git_bin_dir
="$GIT_BUILD_DIR/bin-wrappers"
987 if ! test -x "$git_bin_dir/git" ; then
988 if test -z "$with_dashes" ; then
989 say
"$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
993 PATH
="$git_bin_dir:$PATH"
994 GIT_EXEC_PATH
=$GIT_BUILD_DIR
995 if test -n "$with_dashes" ; then
996 PATH
="$GIT_BUILD_DIR:$PATH"
999 GIT_TEMPLATE_DIR
="$GIT_BUILD_DIR"/templates
/blt
1001 GIT_CONFIG_NOSYSTEM
=1
1003 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
1005 .
"$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
1007 if test -z "$GIT_TEST_CMP"
1009 if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT"
1011 GIT_TEST_CMP
="$DIFF -c"
1013 GIT_TEST_CMP
="$DIFF -u"
1017 GITPERLLIB
="$GIT_BUILD_DIR"/perl
/blib
/lib
:"$GIT_BUILD_DIR"/perl
/blib
/arch
/auto
/Git
1019 test -d "$GIT_BUILD_DIR"/templates
/blt ||
{
1020 error
"You haven't built things yet, have you?"
1023 if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON"
1025 GITPYTHONLIB
="$GIT_BUILD_DIR/git_remote_helpers/build/lib"
1027 test -d "$GIT_BUILD_DIR"/git_remote_helpers
/build ||
{
1028 error
"You haven't built git_remote_helpers yet, have you?"
1032 if ! test -x "$GIT_BUILD_DIR"/test-chmtime
; then
1033 echo >&2 'You need to build test-chmtime:'
1034 echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
1039 test="trash directory.$(basename "$0" .sh)"
1040 test -n "$root" && test="$root/$test"
1042 /*) TRASH_DIRECTORY
="$test" ;;
1043 *) TRASH_DIRECTORY
="$TEST_DIRECTORY/$test" ;;
1045 test ! -z "$debug" || remove_trash
=$TRASH_DIRECTORY
1048 echo >&5 "FATAL: Cannot prepare test area"
1052 HOME
="$TRASH_DIRECTORY"
1055 test_create_repo
"$test"
1056 # Use -P to resolve symlinks in our working directory so that the cwd
1057 # in subprocesses like git equals our $PWD (for pathname comparisons).
1058 cd -P "$test" ||
exit 1
1061 this_test
=${this_test%%-*}
1062 for skp
in $GIT_SKIP_TESTS
1064 case "$this_test" in
1066 say_color skip
>&3 "skipping test $this_test altogether"
1067 skip_all
="skip all tests in $this_test"
1072 # Provide an implementation of the 'yes' utility
1087 # Fix some commands on Windows
1090 # Windows has its own (incompatible) sort and find
1100 # git sees Windows-style pwd
1104 # no POSIX permissions
1105 # backslashes in pathspec are converted to '/'
1106 # exec does not inherit the PID
1107 test_set_prereq MINGW
1108 test_set_prereq SED_STRIPS_CR
1111 test_set_prereq POSIXPERM
1112 test_set_prereq EXECKEEPSPID
1113 test_set_prereq NOT_MINGW
1114 test_set_prereq SED_STRIPS_CR
1117 test_set_prereq POSIXPERM
1118 test_set_prereq BSLASHPSPEC
1119 test_set_prereq EXECKEEPSPID
1120 test_set_prereq NOT_MINGW
1124 test -z "$NO_PERL" && test_set_prereq PERL
1125 test -z "$NO_PYTHON" && test_set_prereq PYTHON
1126 test -n "$USE_LIBPCRE" && test_set_prereq LIBPCRE
1127 test -z "$NO_GETTEXT" && test_set_prereq GETTEXT
1129 # Can we rely on git's output in the C locale?
1130 if test -n "$GETTEXT_POISON"
1132 GIT_GETTEXT_POISON
=YesPlease
1133 export GIT_GETTEXT_POISON
1134 test_set_prereq GETTEXT_POISON
1136 test_set_prereq C_LOCALE_OUTPUT
1139 # Use this instead of test_cmp to compare files that contain expected and
1140 # actual output from git commands that can be translated. When running
1141 # under GETTEXT_POISON this pretends that the command produced expected
1144 test -n "$GETTEXT_POISON" || test_cmp
"$@"
1147 # Use this instead of "grep expected-string actual" to see if the
1148 # output from a git command that can be translated either contains an
1149 # expected string, or does not contain an unwanted one. When running
1150 # under GETTEXT_POISON this pretends that the command produced expected
1153 if test -n "$GETTEXT_POISON"
1156 elif test "x!" = "x$1"
1165 # test whether the filesystem supports symbolic links
1166 ln -s x y
2>/dev
/null
&& test -h y
2>/dev
/null
&& test_set_prereq SYMLINKS
1169 # When the tests are run as root, permission tests will report that
1170 # things are writable when they shouldn't be.
1171 test -w / || test_set_prereq SANITY