Skip to content

Commit 3c8f12c

Browse files
committed
test-lib: reorder and include GIT-BUILD-OPTIONS a lot earlier
This dot-sources GIT-BUILD-OPTIONS a lot earlier in test-lib.sh so that its use of "perl" can use "$PERL_PATH" to choose the version of Perl the user told us is suitable for our use. This is iffy; I didn't check it very carefully, and I would not be surprised if there are subtle breakages. Signed-off-by: Junio C Hamano <[email protected]>
1 parent ad78585 commit 3c8f12c

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

t/test-lib.sh

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ esac
3434
# Keep the original TERM for say_color
3535
ORIGINAL_TERM=$TERM
3636

37+
# Test the binaries we have just built. The tests are kept in
38+
# t/ subdirectory and are run in 'trash directory' subdirectory.
39+
if test -z "$TEST_DIRECTORY"
40+
then
41+
# We allow tests to override this, in case they want to run tests
42+
# outside of t/, e.g. for running tests on the test library
43+
# itself.
44+
TEST_DIRECTORY=$(pwd)
45+
fi
46+
if test -z "$TEST_OUTPUT_DIRECTORY"
47+
then
48+
# Similarly, override this to store the test-results subdir
49+
# elsewhere
50+
TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
51+
fi
52+
GIT_BUILD_DIR="$TEST_DIRECTORY"/..
53+
54+
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
55+
export PERL_PATH SHELL_PATH
56+
3757
# For repeatability, reset the environment to known value.
3858
LANG=C
3959
LC_ALL=C
@@ -46,7 +66,7 @@ EDITOR=:
4666
# /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets
4767
# deriving from the command substitution clustered with the other
4868
# ones.
49-
unset VISUAL EMAIL LANGUAGE COLUMNS $(perl -e '
69+
unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
5070
my @env = keys %ENV;
5171
my $ok = join("|", qw(
5272
TRACE
@@ -229,7 +249,7 @@ trap 'die' EXIT
229249

230250
# The user-facing functions are loaded from a separate file so that
231251
# test_perf subshells can have them too
232-
. "${TEST_DIRECTORY:-.}"/test-lib-functions.sh
252+
. "$TEST_DIRECTORY/test-lib-functions.sh"
233253

234254
# You are not expected to call test_ok_ and test_failure_ directly, use
235255
# the text_expect_* functions instead.
@@ -380,23 +400,6 @@ test_done () {
380400
esac
381401
}
382402

383-
# Test the binaries we have just built. The tests are kept in
384-
# t/ subdirectory and are run in 'trash directory' subdirectory.
385-
if test -z "$TEST_DIRECTORY"
386-
then
387-
# We allow tests to override this, in case they want to run tests
388-
# outside of t/, e.g. for running tests on the test library
389-
# itself.
390-
TEST_DIRECTORY=$(pwd)
391-
fi
392-
if test -z "$TEST_OUTPUT_DIRECTORY"
393-
then
394-
# Similarly, override this to store the test-results subdir
395-
# elsewhere
396-
TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
397-
fi
398-
GIT_BUILD_DIR="$TEST_DIRECTORY"/..
399-
400403
if test -n "$valgrind"
401404
then
402405
make_symlink () {
@@ -492,10 +495,6 @@ GIT_CONFIG_NOSYSTEM=1
492495
GIT_ATTR_NOSYSTEM=1
493496
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
494497

495-
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
496-
497-
export PERL_PATH
498-
499498
if test -z "$GIT_TEST_CMP"
500499
then
501500
if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT"

0 commit comments

Comments
 (0)