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

[PATCH 2/3] tests: provide $TRASH_DIRECTORY variable

From
Jeff King <peff@peff.net>
Date
Aug 9, 2009, 08:38 UTC
Message-ID
<20090809083810.GB8250@coredump.intra.peff.net>
In-Reply-To
<20090809083518.GA8147@coredump.intra.peff.net>

Most scripts don't care about the absolute path to the trash directory. The one exception was t4014 script, which pieced together $TEST_DIRECTORY and $test itself to get an absolute directory.

Instead, let's provide a $TRASH_DIRECTORY which specifies the same thing. This keeps the $test variable internal to test-lib.sh and paves the way for trash directories in other locations.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t4014-format-patch.sh |    3 +--
 t/test-lib.sh           |    3 ++-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 922a894..531f5b7 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -493,13 +493,12 @@ test_expect_success 'format-patch from a subdirectory (2)' '
 '
 
 test_expect_success 'format-patch from a subdirectory (3)' '
-	here="$TEST_DIRECTORY/$test" &&
 	rm -f 0* &&
 	filename=$(
 		rm -rf sub &&
 		mkdir -p sub/dir &&
 		cd sub/dir &&
-		git format-patch -1 -o "$here"
+		git format-patch -1 -o "$TRASH_DIRECTORY"
 	) &&
 	basename=$(expr "$filename" : ".*/\(.*\)") &&
 	test -f "$basename"
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 5fdc5d9..e6a7bb1 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -645,7 +645,8 @@ fi
 
 # Test repository
 test="trash directory.$(basename "$0" .sh)"
-test ! -z "$debug" || remove_trash="$TEST_DIRECTORY/$test"
+TRASH_DIRECTORY="$TEST_DIRECTORY/$test"
+test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
 rm -fr "$test" || {
 	GIT_EXIT_OK=t
 	echo >&5 "FATAL: Cannot prepare test area"
-- 
1.6.4.178.g7a987
Previous: Jeff KingNext: Jeff King
Message 3 of 7 in “moving test trash directories”
  1. 0/3 moving test trash directoriesJeff King, Aug 9, 2009
  2. 1/3 tests: use "$TEST_DIRECTORY" instead of ".."Jeff King, Aug 9, 2009
  3. 2/3 tests: provide $TRASH_DIRECTORY variableJeff King, Aug 9, 2009
  4. 3/3 tests: allow user to specify trash directory locationJeff King, Aug 9, 2009
  5. Johannes SixtAug 9, 2009
  6. Johannes SchindelinAug 9, 2009
  7. 4/3 t/Makefile: include config.makJeff King, Aug 9, 2009

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.