[PATCH] test: create TEST_TMPDIR for holding temporary files

Tomi Ollila tomi.ollila at iki.fi
Wed Nov 16 11:09:00 PST 2011


The TEST_TMPDIR if first needed to hold dtach's socket (due
to 108-character limit in socket file names). Later it can be
used to hold other temporary files; directory deleted at exit.
---

I'm not fully satisfied with variable name -- compare to
the use of TEST_DIRECTORY. Anyway it is the best I could
come up with -- to not invent yet one more naming convention.

Sometime in the future we could rework the variable
names to have more consistent format.

 test/test-lib.sh |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 1ea7fa9..4cd0157 100755
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -174,6 +174,7 @@ test_success=0
 
 die () {
 	code=$?
+	rm -rf "$TEST_TMPDIR"
 	if test -n "$GIT_EXIT_OK"
 	then
 		exit $code
@@ -184,6 +185,8 @@ die () {
 }
 
 GIT_EXIT_OK=
+# Note: TEST_TMPDIR *NOT* exported!
+TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX")
 trap 'die' EXIT
 
 test_decode_color () {
--
1.7.7.3



More information about the notmuch mailing list