Skip to content

Commit e4597aa

Browse files
Matthew Ogilviegitster
Matthew Ogilvie
authored andcommitted
run test suite without dashed git-commands in PATH
Only put bin-wrappers in the PATH (not GIT_EXEC_PATH), to emulate the default installed user environment, and ensure all the programs run correctly in such an environment. This is now the default, although it can be overridden with a --with-dashes test option when running tests. Signed-off-by: Matthew Ogilvie <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ea92519 commit e4597aa

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

t/README

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ appropriately before running "make".
7575
As the names depend on the tests' file names, it is safe to
7676
run the tests with this option in parallel.
7777

78+
--with-dashes::
79+
By default tests are run without dashed forms of
80+
commands (like git-commit) in the PATH (it only uses
81+
wrappers from ../bin-wrappers). Use this option to include
82+
the build directory (..) in the PATH, which contains all
83+
the dashed forms of commands. This option is currently
84+
implied by other options like --valgrind and
85+
GIT_TEST_INSTALLED.
86+
7887
You can also set the GIT_TEST_INSTALLED environment variable to
7988
the bindir of an existing git installation to test that installation.
8089
You still need to have built this git sandbox, from which various

t/test-lib.sh

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ do
105105
verbose=t; shift ;;
106106
-q|--q|--qu|--qui|--quie|--quiet)
107107
quiet=t; shift ;;
108+
--with-dashes)
109+
with_dashes=t; shift ;;
108110
--no-color)
109111
color=; shift ;;
110112
--no-python)
@@ -551,19 +553,8 @@ test_done () {
551553
# Test the binaries we have just built. The tests are kept in
552554
# t/ subdirectory and are run in 'trash directory' subdirectory.
553555
TEST_DIRECTORY=$(pwd)
554-
if test -z "$valgrind"
556+
if test -n "$valgrind"
555557
then
556-
if test -z "$GIT_TEST_INSTALLED"
557-
then
558-
PATH=$TEST_DIRECTORY/..:$PATH
559-
GIT_EXEC_PATH=$TEST_DIRECTORY/..
560-
else
561-
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
562-
error "Cannot run git from $GIT_TEST_INSTALLED."
563-
PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH
564-
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
565-
fi
566-
else
567558
make_symlink () {
568559
test -h "$2" &&
569560
test "$1" = "$(readlink "$2")" || {
@@ -625,6 +616,24 @@ else
625616
PATH=$GIT_VALGRIND/bin:$PATH
626617
GIT_EXEC_PATH=$GIT_VALGRIND/bin
627618
export GIT_VALGRIND
619+
elif test -n "$GIT_TEST_INSTALLED" ; then
620+
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
621+
error "Cannot run git from $GIT_TEST_INSTALLED."
622+
PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH
623+
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
624+
else # normal case, use ../bin-wrappers only unless $with_dashes:
625+
git_bin_dir="$TEST_DIRECTORY/../bin-wrappers"
626+
if ! test -x "$git_bin_dir/git" ; then
627+
if test -z "$with_dashes" ; then
628+
say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
629+
fi
630+
with_dashes=t
631+
fi
632+
PATH="$git_bin_dir:$PATH"
633+
GIT_EXEC_PATH=$TEST_DIRECTORY/..
634+
if test -n "$with_dashes" ; then
635+
PATH="$TEST_DIRECTORY/..:$PATH"
636+
fi
628637
fi
629638
GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
630639
unset GIT_CONFIG

0 commit comments

Comments
 (0)