From 38b074de80759c95fec20b0dbc30614caccdfd24 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Sun, 14 Apr 2013 17:34:56 +0100 Subject: [PATCH 1/2] t/test-lib.sh: fix TRASH_DIRECTORY handling After the location of $TRASH_DIRECTORY is adjusted by $TEST_OUTPUT_DIRECTORY, we go on to use the $test variable to make the trash directory and cd into it. This means that when $TEST_OUTPUT_DIRECTORY is not "." and an absolute --root has not been specified, we do not remove the trash directory once the tests are complete (remove_trash is set to $TRASH_DIRECTORY). Fix this by always referring to the trash directory as $TRASH_DIRECTORY. Signed-off-by: John Keeping Acked-by: Jeff King Acked-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/test-lib.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 8d76cf23d4..c5121f4983 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -599,7 +599,7 @@ case "$test" in *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$test" ;; esac test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY -rm -fr "$test" || { +rm -fr "$TRASH_DIRECTORY" || { GIT_EXIT_OK=t echo >&5 "FATAL: Cannot prepare test area" exit 1 @@ -610,13 +610,13 @@ export HOME if test -z "$TEST_NO_CREATE_REPO" then - test_create_repo "$test" + test_create_repo "$TRASH_DIRECTORY" else - mkdir -p "$test" + mkdir -p "$TRASH_DIRECTORY" 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 +cd -P "$TRASH_DIRECTORY" || exit 1 this_test=${0##*/} this_test=${this_test%%-*} From 002d4ce8aa40644698721d59691d38f1df702f4b Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sun, 14 Apr 2013 15:38:21 -0400 Subject: [PATCH 2/2] t/test-lib.sh: drop "$test" variable The $test variable is used as an interim buffer for constructing $TRASH_DIRECTORY, and is almost compatible with it (the exception being that $test has not been converted to an absolute path). Let's get rid of it entirely so that later code does not accidentally use it, thinking the two are interchangeable. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/test-lib.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index c5121f4983..657b0bd862 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -592,11 +592,11 @@ then fi # Test repository -test="trash directory.$(basename "$0" .sh)" -test -n "$root" && test="$root/$test" -case "$test" in -/*) TRASH_DIRECTORY="$test" ;; - *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$test" ;; +TRASH_DIRECTORY="trash directory.$(basename "$0" .sh)" +test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY" +case "$TRASH_DIRECTORY" in +/*) ;; # absolute path is good + *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;; esac test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY rm -fr "$TRASH_DIRECTORY" || {