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

[PATCH 4/4] run test suite without dashed git-commands in PATH

From
MOMatthew Ogilvie <mmogilvi_git@miniinfo.net>
Date
Nov 28, 2009, 18:38 UTC
Message-ID
<1259433537-3963-5-git-send-email-mmogilvi_git@miniinfo.net>
In-Reply-To
<1259433537-3963-4-git-send-email-mmogilvi_git@miniinfo.net>

Only put test-bin in the PATH (do not put GIT_EXEC_PATH in the PATH), to emulate the default installed user environment, and ensure all the programs run correctly in such an environment. This is now the default, although it can be overridden with a --with-dashes test option when running tests.

Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
---
 t/README      |    8 ++++++++
 t/test-lib.sh |   33 +++++++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/t/README b/t/README
index d8f6c7d..b61c34b 100644
--- a/t/README
+++ b/t/README
@@ -75,6 +75,14 @@ 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.
 
+--with-dashes::
+	By default tests are run without dashed forms of
+	commands (like git-commit) in the PATH (it only uses
+	wrappers from TOP/git-bin).  Use this option to include TOP
+	in the PATH, which conains all the dashed forms of commands.
+	This option is currently implied by other options like --valgrind
+	and GIT_TEST_INSTALLED.
+
 Skipping Tests
 --------------
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index ec3336a..54570ac 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -105,6 +105,8 @@ do
 		verbose=t; shift ;;
 	-q|--q|--qu|--qui|--quie|--quiet)
 		quiet=t; shift ;;
+	--with-dashes)
+		with_dashes=t; shift ;;
 	--no-color)
 		color=; shift ;;
 	--no-python)
@@ -551,19 +553,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)
-if test -z "$valgrind"
+if test -n "$valgrind"
 then
-	if test -z "$GIT_TEST_INSTALLED"
-	then
-		PATH=$TEST_DIRECTORY/..:$PATH
-		GIT_EXEC_PATH=$TEST_DIRECTORY/..
-	else
-		GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||
-		error "Cannot run git from $GIT_TEST_INSTALLED."
-		PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH
-		GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
-	fi
-else
 	make_symlink () {
 		test -h "$2" &&
 		test "$1" = "$(readlink "$2")" || {
@@ -625,6 +616,24 @@ else
 	PATH=$GIT_VALGRIND/bin:$PATH
 	GIT_EXEC_PATH=$GIT_VALGRIND/bin
 	export GIT_VALGRIND
+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
+	GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
+else # normal case, use ../test-bin only unless $with_dashes:
+	git_bin_dir="$TEST_DIRECTORY/../test-bin"
+	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"
+		fi
+		with_dashes=t
+	fi
+	PATH="$git_bin_dir:$PATH"
+	GIT_EXEC_PATH=$TEST_DIRECTORY/..
+	if test -n "$with_dashes" ; then
+		PATH="$TEST_DIRECTORY/..:$PATH"
+	fi
 fi
 GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
 unset GIT_CONFIG
-- 
1.6.4.GIT
Previous: Matthew OgilvieNext: Junio C Hamano
Message 5 of 14 in “Run test suite without dashed commands in PATH”
  1. 0/4 Run test suite without dashed commands in PATHMatthew Ogilvie, Nov 28, 2009
  2. 1/4 t2300: use documented technique to invoke git-sh-setupMatthew Ogilvie, Nov 28, 2009
  3. 2/4 t3409 t4107 t7406: use dashless commandsMatthew Ogilvie, Nov 28, 2009
  4. 3/4 build dashless "test-bin" directory similar to installed bindirMatthew Ogilvie, Nov 28, 2009
  5. 4/4 run test suite without dashed git-commands in PATHMatthew Ogilvie, Nov 28, 2009
  6. Junio C HamanoNov 28, 2009
  7. Jeff KingNov 28, 2009
  8. Junio C HamanoNov 29, 2009
  9. Jeff KingNov 29, 2009
  10. Junio C HamanoNov 29, 2009
  11. Jeff KingNov 29, 2009
  12. Matthew OgilvieNov 29, 2009
  13. Matthew OgilvieNov 29, 2009
  14. Nanako ShiraishiNov 30, 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.