[PATCH v2] test: set the realpath of CWD as TRASH_DIRECTORY
- From
Jiang Xin <worldhello.net@gmail.com>
- Date
- Aug 27, 2012, 05:13 UTC
- Message-ID
- <f58965733e604a9fe6ed72384d0307062403b478.1346043214.git.worldhello.net@gmail.com>
- In-Reply-To
- <5030F0BF.2090500@alum.mit.edu>
Some testcases will fail if current work directory is on a symlink.
symlink$ sh ./t4035-diff-quiet.sh
$ sh ./t4035-diff-quiet.sh --root=/symlink
$ TEST_OUTPUT_DIRECTORY=/symlink sh ./t4035-diff-quiet.shThis is because the realpath of ".git" directory will be returned when running the command 'git rev-parse --git-dir' in a subdir of the work tree, and the realpath may not equal to "$TRASH_DIRECTORY".
In this fix, "$TRASH_DIRECTORY" is determined right after the realpath of CWD is resolved.
Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Reported-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jiang Xin <worldhello.net@gmail.com> --- t/test-lib.sh | 9 +++++---- 1 个文件被修改,插入 5 行(+),删除 4 行(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh index 78c42..9a59ca8 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -531,17 +531,17 @@ fi test="trash directory.$(basename "$0" .sh)" test -n "$root" && test="$root/$test" case "$test" in -/*) TRASH_DIRECTORY="$test" ;; - *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$test" ;; +/*) ;; + *) test="$TEST_OUTPUT_DIRECTORY/$test" ;; esac -test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY +test ! -z "$debug" || remove_trash=$test rm -fr "$test" || { GIT_EXIT_OK=t echo >&5 "FATAL: Cannot prepare test area" exit 1 } -HOME="$TRASH_DIRECTORY" +HOME="$test" export HOME if test -z "$TEST_NO_CREATE_REPO"; then @@ -552,6 +552,7 @@ fi # Use -P to resolve symlinks in our working directory so that the cwd # in subprocesses like git equals our $PWD (for pathname comparisons). cd -P "$test" || exit 1 +TRASH_DIRECTORY="$(pwd)" this_test=${0##*/} this_test=${this_test%%-*}
-- 1.7.12.92.gaa91cb5