Skip to content

Commit 6cec5c6

Browse files
avargitster
authored andcommitted
test-lib: Use "$GIT_BUILD_DIR" instead of "$TEST_DIRECTORY"/../
Change code that used $TEST_DIRECTORY/.. to use $GIT_BUILD_DIR instead, the two are equivalent, but the latter is easier to read. This required moving the assignment od GIT_BUILD_DIR to earlier in the test-lib.sh file. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent aed604c commit 6cec5c6

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

t/test-lib.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ test_create_repo () {
648648
repo="$1"
649649
mkdir -p "$repo"
650650
cd "$repo" || error "Cannot setup test environment"
651-
"$GIT_EXEC_PATH/git-init" "--template=$TEST_DIRECTORY/../templates/blt/" >&3 2>&4 ||
651+
"$GIT_EXEC_PATH/git-init" "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
652652
error "cannot run git init -- have you built things yet?"
653653
mv .git/hooks .git/hooks-disabled
654654
cd "$owd"
@@ -711,6 +711,8 @@ test_done () {
711711
# Test the binaries we have just built. The tests are kept in
712712
# t/ subdirectory and are run in 'trash directory' subdirectory.
713713
TEST_DIRECTORY=$(pwd)
714+
GIT_BUILD_DIR="$TEST_DIRECTORY"/..
715+
714716
if test -n "$valgrind"
715717
then
716718
make_symlink () {
@@ -737,7 +739,7 @@ then
737739
test -x "$1" || return
738740

739741
base=$(basename "$1")
740-
symlink_target=$TEST_DIRECTORY/../$base
742+
symlink_target=$GIT_BUILD_DIR/$base
741743
# do not override scripts
742744
if test -x "$symlink_target" &&
743745
test ! -d "$symlink_target" &&
@@ -756,7 +758,7 @@ then
756758
# override all git executables in TEST_DIRECTORY/..
757759
GIT_VALGRIND=$TEST_DIRECTORY/valgrind
758760
mkdir -p "$GIT_VALGRIND"/bin
759-
for file in $TEST_DIRECTORY/../git* $TEST_DIRECTORY/../test-*
761+
for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
760762
do
761763
make_valgrind_symlink $file
762764
done
@@ -777,24 +779,23 @@ then
777779
elif test -n "$GIT_TEST_INSTALLED" ; then
778780
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
779781
error "Cannot run git from $GIT_TEST_INSTALLED."
780-
PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH
782+
PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
781783
GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
782784
else # normal case, use ../bin-wrappers only unless $with_dashes:
783-
git_bin_dir="$TEST_DIRECTORY/../bin-wrappers"
785+
git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
784786
if ! test -x "$git_bin_dir/git" ; then
785787
if test -z "$with_dashes" ; then
786788
say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
787789
fi
788790
with_dashes=t
789791
fi
790792
PATH="$git_bin_dir:$PATH"
791-
GIT_EXEC_PATH=$TEST_DIRECTORY/..
793+
GIT_EXEC_PATH=$GIT_BUILD_DIR
792794
if test -n "$with_dashes" ; then
793-
PATH="$TEST_DIRECTORY/..:$PATH"
795+
PATH="$GIT_BUILD_DIR:$PATH"
794796
fi
795797
fi
796-
GIT_BUILD_DIR="$TEST_DIRECTORY"/..
797-
GIT_TEMPLATE_DIR="$TEST_DIRECTORY"/../templates/blt
798+
GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
798799
unset GIT_CONFIG
799800
GIT_CONFIG_NOSYSTEM=1
800801
GIT_CONFIG_NOGLOBAL=1
@@ -812,22 +813,22 @@ then
812813
fi
813814
fi
814815

815-
GITPERLLIB="$TEST_DIRECTORY"/../perl/blib/lib:"$TEST_DIRECTORY"/../perl/blib/arch/auto/Git
816+
GITPERLLIB="$GIT_BUILD_DIR"/perl/blib/lib:"$GIT_BUILD_DIR"/perl/blib/arch/auto/Git
816817
export GITPERLLIB
817-
test -d "$TEST_DIRECTORY"/../templates/blt || {
818+
test -d "$GIT_BUILD_DIR"/templates/blt || {
818819
error "You haven't built things yet, have you?"
819820
}
820821

821822
if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON"
822823
then
823-
GITPYTHONLIB="$TEST_DIRECTORY/../git_remote_helpers/build/lib"
824+
GITPYTHONLIB="$GIT_BUILD_DIR/git_remote_helpers/build/lib"
824825
export GITPYTHONLIB
825-
test -d "$TEST_DIRECTORY"/../git_remote_helpers/build || {
826+
test -d "$GIT_BUILD_DIR"/git_remote_helpers/build || {
826827
error "You haven't built git_remote_helpers yet, have you?"
827828
}
828829
fi
829830

830-
if ! test -x "$TEST_DIRECTORY"/../test-chmtime; then
831+
if ! test -x "$GIT_BUILD_DIR"/test-chmtime; then
831832
echo >&2 'You need to build test-chmtime:'
832833
echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
833834
exit 1

0 commit comments

Comments
 (0)