]> git.ipfire.org Git - thirdparty/git.git/commitdiff
test-lib.sh: convert $TEST_DIRECTORY to an absolute path
authorFelipe Contreras <felipe.contreras@gmail.com>
Mon, 18 Nov 2013 04:12:43 +0000 (23:12 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 Nov 2013 21:45:56 +0000 (13:45 -0800)
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 <felipe.contreras@gmail.com>
Reviewed-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Richard Hansen <rhansen@bbn.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh

index b25249ec4cc2844f5cd7491dd5fcc88c884ff450..d303e6c943ab94e15e65fb8a51cbe871cf9ef544 100644 (file)
@@ -26,6 +26,10 @@ then
        # outside of t/, e.g. for running tests on the test library
        # itself.
        TEST_DIRECTORY=$(pwd)
+else
+       # ensure that TEST_DIRECTORY is an absolute path so that it
+       # is valid even if the current working directory is changed
+       TEST_DIRECTORY=$(cd "$TEST_DIRECTORY" && pwd) || exit 1
 fi
 if test -z "$TEST_OUTPUT_DIRECTORY"
 then