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

[PATCH v2 2/4] test-lib: Use "$GIT_BUILD_DIR" instead of "$TEST_DIRECTORY"/../

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Aug 19, 2010, 16:05 UTC
Message-ID
<1282233961-27203-3-git-send-email-avarab@gmail.com>
In-Reply-To
<1282138473-15613-1-git-send-email-avarab@gmail.com>

Change code that used $TEST_DIRECTORY/.. to use $GIT_BUILD_DIR instead, the two are equivalent, but the latter is easier to read.

This required moving the assignment od GIT_BUILD_DIR to earlier in the test-lib.sh file.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

Note that the usage of GIT_BUILD_DIR in the first hunk isn't an error, since it's inside a function GIT_BUILD_DIR will be defined by the time it's used.

 t/test-lib.sh |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 0e460f9..689aa29 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -685,7 +685,7 @@ test_create_repo () {
 	repo="$1"
 	mkdir -p "$repo"
 	cd "$repo" || error "Cannot setup test environment"
-	"$GIT_EXEC_PATH/git-init" "--template=$TEST_DIRECTORY/../templates/blt/" >&3 2>&4 ||
+	"$GIT_EXEC_PATH/git-init" "--template=$GIT_BUILD_DIR/templates/blt/" >&3 2>&4 ||
 	error "cannot run git init -- have you built things yet?"
 	mv .git/hooks .git/hooks-disabled
 	cd "$owd"
@@ -748,6 +748,8 @@ test_done () {
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in 'trash directory' subdirectory.
 TEST_DIRECTORY=$(pwd)
+GIT_BUILD_DIR="$TEST_DIRECTORY"/..
+
 if test -n "$valgrind"
 then
 	make_symlink () {
@@ -774,7 +776,7 @@ then
 		test -x "$1" || return
 
 		base=$(basename "$1")
-		symlink_target=$TEST_DIRECTORY/../$base
+		symlink_target=$GIT_BUILD_DIR/$base
 		# do not override scripts
 		if test -x "$symlink_target" &&
 		    test ! -d "$symlink_target" &&
@@ -793,7 +795,7 @@ then
 	# override all git executables in TEST_DIRECTORY/..
 	GIT_VALGRIND=$TEST_DIRECTORY/valgrind
 	mkdir -p "$GIT_VALGRIND"/bin
-	for file in $TEST_DIRECTORY/../git* $TEST_DIRECTORY/../test-*
+	for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
 	do
 		make_valgrind_symlink $file
 	done
@@ -814,10 +816,10 @@ then
 elif test -n "$GIT_TEST_INSTALLED" ; then
 	GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||
 	error "Cannot run git from $GIT_TEST_INSTALLED."
-	PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH
+	PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
 	GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
 else # normal case, use ../bin-wrappers only unless $with_dashes:
-	git_bin_dir="$TEST_DIRECTORY/../bin-wrappers"
+	git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
 	if ! test -x "$git_bin_dir/git" ; then
 		if test -z "$with_dashes" ; then
 			say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
@@ -825,13 +827,12 @@ else # normal case, use ../bin-wrappers only unless $with_dashes:
 		with_dashes=t
 	fi
 	PATH="$git_bin_dir:$PATH"
-	GIT_EXEC_PATH=$TEST_DIRECTORY/..
+	GIT_EXEC_PATH=$GIT_BUILD_DIR
 	if test -n "$with_dashes" ; then
-		PATH="$TEST_DIRECTORY/..:$PATH"
+		PATH="$GIT_BUILD_DIR:$PATH"
 	fi
 fi
-GIT_BUILD_DIR="$TEST_DIRECTORY"/..
-GIT_TEMPLATE_DIR="$TEST_DIRECTORY"/../templates/blt
+GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
 unset GIT_CONFIG
 GIT_CONFIG_NOSYSTEM=1
 GIT_CONFIG_NOGLOBAL=1
@@ -849,22 +850,22 @@ then
 	fi
 fi
 
-GITPERLLIB="$TEST_DIRECTORY"/../perl/blib/lib:"$TEST_DIRECTORY"/../perl/blib/arch/auto/Git
+GITPERLLIB="$GIT_BUILD_DIR"/perl/blib/lib:"$GIT_BUILD_DIR"/perl/blib/arch/auto/Git
 export GITPERLLIB
-test -d "$TEST_DIRECTORY"/../templates/blt || {
+test -d "$GIT_BUILD_DIR"/templates/blt || {
 	error "You haven't built things yet, have you?"
 }
 
 if test -z "$GIT_TEST_INSTALLED" && test -z "$NO_PYTHON"
 then
-	GITPYTHONLIB="$TEST_DIRECTORY/../git_remote_helpers/build/lib"
+	GITPYTHONLIB="$GIT_BUILD_DIR/git_remote_helpers/build/lib"
 	export GITPYTHONLIB
-	test -d "$TEST_DIRECTORY"/../git_remote_helpers/build || {
+	test -d "$GIT_BUILD_DIR"/git_remote_helpers/build || {
 		error "You haven't built git_remote_helpers yet, have you?"
 	}
 fi
 
-if ! test -x "$TEST_DIRECTORY"/../test-chmtime; then
+if ! test -x "$GIT_BUILD_DIR"/test-chmtime; then
 	echo >&2 'You need to build test-chmtime:'
 	echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
 	exit 1
-- 
1.7.2.1.414.g9bf49
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 7 of 20 in “t/t0000-basic.sh: Don't run a passing TODO unless TEST_PASSING_TODO=1”
  1. t/t0000-basic.sh: Don't run a passing TODO unless TEST_PASSING_TODO=1Ævar Arnfjörð Bjarmason, Aug 17, 2010
  2. Sverre RabbelierAug 17, 2010
  3. Junio C HamanoAug 17, 2010
  4. 0/4 Support for running tests outside t/ + don't run a TODO testÆvar Arnfjörð Bjarmason, Aug 18, 2010
  5. 0/4 Support for running tests outside t/ + don't run a TODO testÆvar Arnfjörð Bjarmason, Aug 19, 2010
  6. 1/4 test-lib: Use $TEST_DIRECTORY or $GIT_BUILD_DIR instead of $(pwd) and ../Ævar Arnfjörð Bjarmason, Aug 19, 2010
  7. 2/4 test-lib: Use "$GIT_BUILD_DIR" instead of "$TEST_DIRECTORY"/../Ævar Arnfjörð Bjarmason, Aug 19, 2010
  8. 3/4 test-lib: Allow overriding of TEST_DIRECTORYÆvar Arnfjörð Bjarmason, Aug 19, 2010
  9. 4/4 t/t0000-basic.sh: Run the passing TODO test inside its own test-libÆvar Arnfjörð Bjarmason, Aug 19, 2010
  10. 0/4 Support for running tests outside t/ + don't run a TODO testÆvar Arnfjörð Bjarmason, Aug 19, 2010
  11. Jeff KingAug 19, 2010
  12. 1/4 test-lib: Use $TEST_DIRECTORY or $GIT_BUILD_DIR instead of $(pwd) and ../Ævar Arnfjörð Bjarmason, Aug 19, 2010
  13. 2/4 test-lib: Use "$GIT_BUILD_DIR" instead of "$TEST_DIRECTORY"/../Ævar Arnfjörð Bjarmason, Aug 19, 2010
  14. 3/4 test-lib: Allow overriding of TEST_DIRECTORYÆvar Arnfjörð Bjarmason, Aug 19, 2010
  15. 4/4 t/t0000-basic.sh: Run the passing TODO test inside its own test-libÆvar Arnfjörð Bjarmason, Aug 19, 2010
  16. 1/4 test-lib: Use $TEST_DIRECTORY or $GIT_BUILD_DIR instead of $(pwd) and ../Ævar Arnfjörð Bjarmason, Aug 18, 2010
  17. 2/4 test-lib: Use "$GIT_BUILD_DIR" instead of "$TEST_DIRECTORY"/../Ævar Arnfjörð Bjarmason, Aug 18, 2010
  18. 3/4 test-lib: Allow overriding of TEST_DIRECTORYÆvar Arnfjörð Bjarmason, Aug 18, 2010
  19. 4/4 t/t0000-basic.sh: Run the passing TODO test inside its own test-libÆvar Arnfjörð Bjarmason, Aug 18, 2010
  20. Sverre RabbelierAug 19, 2010

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.