Re: [PATCH v2] test: set the realpath of CWD as TRASH_DIRECTORY
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 27, 2012, 16:15 UTC
- Message-ID
- <7vk3wktiph.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <f58965733e604a9fe6ed72384d0307062403b478.1346043214.git.worldhello.net@gmail.com>
Jiang Xin <worldhello.net@gmail.com> writes:
Show 17 quoted lines
> 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.sh > > This 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> > ---
I think this is in line with what was discussed in the other thread Michael brought this up. Thanks for following it through.
Michael, this looks good to me; anything I missed?
Show 34 quoted lines
> 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%%-*}