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 <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>

Felipe Contreras committed Nov 17, 2013 at 23:12 UTC 85176d725134446ca2b8585d85f8fbd2daf45515
1 file changed +4
t/test-lib.sh
+4
@@ -26,6 +26,10 @@ then
26 # outside of t/, e.g. for running tests on the test library
27 # itself.
28 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
33 fi
34 if test -z "$TEST_OUTPUT_DIRECTORY"
35 then