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 <gitster@pobox.com>

Junio C Hamano committed Jun 24, 2012 at 22:01 UTC 3c8f12c96ca09af2a0a9df9fbb9ffd25985ff597
1 file changed +22 -23
t/test-lib.sh
+22 -23
@@ -34,6 +34,26 @@ esac
34 # Keep the original TERM for say_color
35 ORIGINAL_TERM=$TERM
36
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 +
57 # For repeatability, reset the environment to known value.
58 LANG=C
59 LC_ALL=C
@@ -46,7 +66,7 @@ EDITOR=:
66 # /usr/xpg4/bin/sh and /bin/ksh to bail out. So keep the unsets
67 # deriving from the command substitution clustered with the other
68 # ones.
49 -unset VISUAL EMAIL LANGUAGE COLUMNS $(perl -e '
69 +unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
70 my @env = keys %ENV;
71 my $ok = join("|", qw(
72 TRACE
@@ -229,7 +249,7 @@ trap 'die' EXIT
249
250 # The user-facing functions are loaded from a separate file so that
251 # test_perf subshells can have them too
232 -. "${TEST_DIRECTORY:-.}"/test-lib-functions.sh
252 +. "$TEST_DIRECTORY/test-lib-functions.sh"
253
254 # You are not expected to call test_ok_ and test_failure_ directly, use
255 # the text_expect_* functions instead.
@@ -380,23 +400,6 @@ test_done () {
400 esac
401 }
402
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 -
403 if test -n "$valgrind"
404 then
405 make_symlink () {
@@ -492,10 +495,6 @@ GIT_CONFIG_NOSYSTEM=1
495 GIT_ATTR_NOSYSTEM=1
496 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
497
495 -. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
496 -
497 -export PERL_PATH
498 -
498 if test -z "$GIT_TEST_CMP"
499 then
500 if test -n "$GIT_TEST_CMP_USE_COPIED_CONTEXT"