Skip to content

Commit cdd159b

Browse files
committed
Merge branch 'jc/test-lib-source-build-options-early'
Reorders t/test-lib.sh so that we dot-source GIT-BUILD-OPTIONS that records the shell and Perl the user told us to use with Git a lot early, so that test-lib.sh script itself can use "$PERL_PATH" in one of its early operations. * jc/test-lib-source-build-options-early: test-lib: reorder and include GIT-BUILD-OPTIONS a lot earlier
2 parents 0d94427 + 3c8f12c commit cdd159b

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
@@ -230,7 +250,7 @@ trap 'die' EXIT
230250

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

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

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

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

0 commit comments

Comments
 (0)