git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t/test-lib.sh: fix TRASH_DIRECTORY handling

From
John Keeping <john@keeping.me.uk>
Date
Apr 14, 2013, 16:34 UTC
Message-ID
<11cf45ad9779240b588da4b25c8ae5b6cc61b427.1365957201.git.john@keeping.me.uk>

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 <john@keeping.me.uk>
---
 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 debd8b4..f79745c 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -607,7 +607,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
@@ -618,13 +618,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%%-*}
-- 
1.8.2.694.ga76e9c3.dirty
Next: Jeff King
Message 1 of 3 in “t/test-lib.sh: fix TRASH_DIRECTORY handling”
  1. t/test-lib.sh: fix TRASH_DIRECTORY handlingJohn Keeping, Apr 14, 2013
  2. Jeff KingApr 14, 2013
  3. Thomas RastApr 14, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.