threads / patch / 19395

patchtests: introduce --trash specifying root directory for trash folders

Subject: [PATCH] tests: introduce --trash specifying root directory for trash folders

## tl;dr

One message between May 18, 2009 and May 18, 2009. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Stephen Boyd· May 18, 2009, 07:49 UTC · lore

Normally, a directory named "trash directory.$TEST_NAME" is created for each test in the t directory (where the test resides). This option allows you to specify a different location to create the trash directories.

For example:
    ./some_test.sh --trash /tmp

will create a git repo and run the tests in some_test.sh under /tmp/trash directory.some_test/

Users may want to run tests on a tmpfs or maybe they have a disk they would like to run tests on that differs from the location of the source code. This option allows them to do so without having to do any mounting mumbo-jumbo. ---

 I tried this out on a tmpfs and it didn't seem to give me too much speedup.
 Maybe something like 1%, but I couldn't test it with the 2GB test where it
 might be useful? I'm just throwing this out there as something people
 might like.
 t/README                                 |    6 ++++++
 t/t3404-rebase-interactive.sh            |    2 +-
 t/t3411-rebase-preserve-around-merges.sh |    2 +-
 t/t4014-format-patch.sh                  |    2 +-
 t/t4020-diff-external.sh                 |    2 +-
 t/test-lib.sh                            |    6 ++++--
 6 files changed, 14 insertions(+), 6 deletions(-)
Show changes to 6 files +14 −6

t/README, t/t3404-rebase-interactive.sh, t/t3411-rebase-preserve-around-merges.sh, t/t4014-format-patch.sh, t/t4020-diff-external.sh, t/test-lib.sh

diff --git a/t/README b/t/README
index d8f6c7d..47a8da3 100644
--- a/t/README
+++ b/t/README
@@ -75,6 +75,12 @@ appropriately before running "make".
 	As the names depend on the tests' file names, it is safe to
 	run the tests with this option in parallel.
 
+--trash::
+	Normally a directory named "trash directory.$TEST_NAME" is
+	created for each test in the t directory (where the test
+	resides). This option allows you to specify a different
+	location to create the trash directories.
+
 Skipping Tests
 --------------
 
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index c32ff66..da337c3 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -10,7 +10,7 @@ that the result still makes sense.
 '
 . ./test-lib.sh
 
-. ../lib-rebase.sh
+. $TEST_DIRECTORY/lib-rebase.sh
 
 set_fake_editor
 
diff --git a/t/t3411-rebase-preserve-around-merges.sh b/t/t3411-rebase-preserve-around-merges.sh
index 6533505..2b82c33 100755
--- a/t/t3411-rebase-preserve-around-merges.sh
+++ b/t/t3411-rebase-preserve-around-merges.sh
@@ -10,7 +10,7 @@ a merge to before the merge.
 '
 . ./test-lib.sh
 
-. ../lib-rebase.sh
+. $TEST_DIRECTORY/lib-rebase.sh
 
 set_fake_editor
 
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 922a894..0fd7be7 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -493,7 +493,7 @@ test_expect_success 'format-patch from a subdirectory (2)' '
 '
 
 test_expect_success 'format-patch from a subdirectory (3)' '
-	here="$TEST_DIRECTORY/$test" &&
+	here="$PWD" &&
 	rm -f 0* &&
 	filename=$(
 		rm -rf sub &&
diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index 0720001..3d27a95 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -157,7 +157,7 @@ test_expect_success 'diff --cached' '
 	git update-index --assume-unchanged file &&
 	echo second >file &&
 	git diff --cached >actual &&
-	test_cmp ../t4020/diff.NUL actual
+	test_cmp $TEST_DIRECTORY/t4020/diff.NUL actual
 '
 
 test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index dad1437..022f826 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -114,6 +114,8 @@ do
 		valgrind=t; verbose=t; shift ;;
 	--tee)
 		shift ;; # was handled already
+	--tr|--tra|--tras|--trash)
+		shift; trash_dir=$1; shift;;
 	*)
 		break ;;
 	esac
@@ -637,8 +639,8 @@ fi
 . ../GIT-BUILD-OPTIONS
 
 # Test repository
-test="trash directory.$(basename "$0" .sh)"
-test ! -z "$debug" || remove_trash="$TEST_DIRECTORY/$test"
+test="${trash_dir:-$TEST_DIRECTORY}/trash directory.$(basename "$0" .sh)"
+test ! -z "$debug" || remove_trash=$test
 rm -fr "$test" || {
 	trap - EXIT
 	echo >&5 "FATAL: Cannot prepare test area"
-- 
1.6.3.1.30.g55524

← back to recent threads