test-lib.sh: convert $TEST_DIRECTORY to an absolute path
[gitweb.git] / 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