Skip to content

Commit 85176d7

Browse files
felipecgitster
authored andcommitted
test-lib.sh: convert $TEST_DIRECTORY to an absolute path
If $TEST_DIRECTORY is specified in the environment, convert the value to an absolute path to ensure that it remains valid even when 'cd' is used. Signed-off-by: Felipe Contreras <[email protected]> Reviewed-by: Richard Hansen <[email protected]> Signed-off-by: Richard Hansen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c939d24 commit 85176d7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

t/test-lib.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ then
2626
# outside of t/, e.g. for running tests on the test library
2727
# itself.
2828
TEST_DIRECTORY=$(pwd)
29+
else
30+
# ensure that TEST_DIRECTORY is an absolute path so that it
31+
# is valid even if the current working directory is changed
32+
TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
2933
fi
3034
if test -z "$TEST_OUTPUT_DIRECTORY"
3135
then

0 commit comments

Comments
 (0)