Skip to content

Commit b9638d7

Browse files
avargitster
authored andcommitted
test-lib: make $GIT_BUILD_DIR an absolute path
Change the GIT_BUILD_DIR from a path like "/path/to/build/t/.." to "/path/to/build". The "TEST_DIRECTORY" here is already made an absolute path a few lines above this. We could simply do $(cd "$TEST_DIRECTORY"/.." && pwd) here, but as noted in the preceding commit the "$TEST_DIRECTORY" can't be anything except the path containing this test-lib.sh file at this point, so we can more cheaply and equally strip the "/t" off the end. This change will be helpful to LSAN_OPTIONS which will want to strip the build directory path from filenames, which we couldn't do if we had a "/.." in there. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9dbf20e commit b9638d7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

t/test-lib.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ then
4141
# elsewhere
4242
TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
4343
fi
44-
GIT_BUILD_DIR="$TEST_DIRECTORY"/..
45-
if test "$TEST_DIRECTORY" = "${TEST_DIRECTORY%/t}"
44+
GIT_BUILD_DIR="${TEST_DIRECTORY%/t}"
45+
if test "$TEST_DIRECTORY" = "$GIT_BUILD_DIR"
4646
then
4747
echo "PANIC: Running in a $TEST_DIRECTORY that doesn't end in '/t'?" >&2
4848
exit 1
@@ -64,6 +64,7 @@ prepend_var () {
6464
# problems. The GIT_SAN_OPTIONS variable can be used to set common
6565
# defaults shared between [AL]SAN_OPTIONS.
6666
prepend_var GIT_SAN_OPTIONS : abort_on_error=1
67+
prepend_var GIT_SAN_OPTIONS : strip_path_prefix=\"$GIT_BUILD_DIR/\"
6768

6869
# If we were built with ASAN, it may complain about leaks
6970
# of program-lifetime variables. Disable it by default to lower

0 commit comments

Comments
 (0)