|
19 | 19 | # t/ subdirectory and are run in 'trash directory' subdirectory.
|
20 | 20 | if test -z "$TEST_DIRECTORY"
|
21 | 21 | then
|
22 |
| - # We allow tests to override this, in case they want to run tests |
23 |
| - # outside of t/, e.g. for running tests on the test library |
24 |
| - # itself. |
25 |
| - TEST_DIRECTORY=$(pwd) |
26 |
| -else |
27 | 22 | # ensure that TEST_DIRECTORY is an absolute path so that it
|
28 | 23 | # is valid even if the current working directory is changed
|
| 24 | + TEST_DIRECTORY=$(pwd) |
| 25 | +else |
| 26 | + # The TEST_DIRECTORY will always be the path to the "t" |
| 27 | + # directory in the git.git checkout. This is overridden by |
| 28 | + # e.g. t/lib-subtest.sh, but only because its $(pwd) is |
| 29 | + # different. Those tests still set "$TEST_DIRECTORY" to the |
| 30 | + # same path. |
| 31 | + # |
| 32 | + # See use of "$GIT_BUILD_DIR" and "$TEST_DIRECTORY" below for |
| 33 | + # hard assumptions about "$GIT_BUILD_DIR/t" existing and being |
| 34 | + # the "$TEST_DIRECTORY", and e.g. "$TEST_DIRECTORY/helper" |
| 35 | + # needing to exist. |
29 | 36 | TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
|
30 | 37 | fi
|
31 | 38 | if test -z "$TEST_OUTPUT_DIRECTORY"
|
|
34 | 41 | # elsewhere
|
35 | 42 | TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
|
36 | 43 | fi
|
37 |
| -GIT_BUILD_DIR="$TEST_DIRECTORY"/.. |
| 44 | +GIT_BUILD_DIR="${TEST_DIRECTORY%/t}" |
| 45 | +if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR" |
| 46 | +then |
| 47 | + echo "PANIC: Running in a $TEST_DIRECTORY that doesn't end in '/t'?" >&2 |
| 48 | + exit 1 |
| 49 | +fi |
| 50 | + |
| 51 | +# Prepend a string to a VAR using an arbitrary ":" delimiter, not |
| 52 | +# adding the delimiter if VAR or VALUE is empty. I.e. a generalized: |
| 53 | +# |
| 54 | +# VAR=$1${VAR:+${1:+$2}$VAR} |
| 55 | +# |
| 56 | +# Usage (using ":" as the $2 delimiter): |
| 57 | +# |
| 58 | +# prepend_var VAR : VALUE |
| 59 | +prepend_var () { |
| 60 | + eval "$1=$3\${$1:+${3:+$2}\$$1}" |
| 61 | +} |
| 62 | + |
| 63 | +# If [AL]SAN is in effect we want to abort so that we notice |
| 64 | +# problems. The GIT_SAN_OPTIONS variable can be used to set common |
| 65 | +# defaults shared between [AL]SAN_OPTIONS. |
| 66 | +prepend_var GIT_SAN_OPTIONS : abort_on_error=1 |
| 67 | +prepend_var GIT_SAN_OPTIONS : strip_path_prefix=\"$GIT_BUILD_DIR/\" |
38 | 68 |
|
39 | 69 | # If we were built with ASAN, it may complain about leaks
|
40 | 70 | # of program-lifetime variables. Disable it by default to lower
|
41 | 71 | # the noise level. This needs to happen at the start of the script,
|
42 | 72 | # before we even do our "did we build git yet" check (since we don't
|
43 | 73 | # want that one to complain to stderr).
|
44 |
| -: ${ASAN_OPTIONS=detect_leaks=0:abort_on_error=1} |
| 74 | +prepend_var ASAN_OPTIONS : $GIT_SAN_OPTIONS |
| 75 | +prepend_var ASAN_OPTIONS : detect_leaks=0 |
45 | 76 | export ASAN_OPTIONS
|
46 | 77 |
|
47 |
| -# If LSAN is in effect we _do_ want leak checking, but we still |
48 |
| -# want to abort so that we notice the problems. |
49 |
| -: ${LSAN_OPTIONS=abort_on_error=1} |
| 78 | +prepend_var LSAN_OPTIONS : $GIT_SAN_OPTIONS |
| 79 | +prepend_var LSAN_OPTIONS : fast_unwind_on_malloc=0 |
50 | 80 | export LSAN_OPTIONS
|
51 | 81 |
|
52 | 82 | if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
|
|
0 commit comments