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

[PATCH 1/6] test: fix build for zsh

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Mar 28, 2023, 17:39 UTC
Message-ID
<20230328173932.3614601-2-felipe.contreras@gmail.com>
In-Reply-To
<20230328173932.3614601-1-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/lib-bash.sh |  2 +-
 t/test-lib.sh | 20 ++++++++++++++------
 2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/t/lib-bash.sh b/t/lib-bash.sh
index b0b6060929..798b6d0265 100644
--- a/t/lib-bash.sh
+++ b/t/lib-bash.sh
@@ -10,7 +10,7 @@ elif type bash >/dev/null 2>&1
 then
 	# execute in full-on bash mode
 	unset POSIXLY_CORRECT
-	exec bash "$0" "$@"
+	exec bash "${ZSH_ARGZERO-$0}" "$@"
 else
 	echo '1..0 #SKIP skipping bash completion tests; bash not available'
 	exit 0
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 62136caee5..cc705df981 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -15,6 +15,14 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see http://www.gnu.org/licenses/ .
 
+if test -n "${ZSH_VERSION-}"
+then
+	emulate sh
+	ARGZERO="$ZSH_ARGZERO"
+else
+	ARGZERO="$0"
+fi
+
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in 'trash directory' subdirectory.
 if test -z "$TEST_DIRECTORY"
@@ -310,7 +318,7 @@ then
 fi
 
 TEST_STRESS_JOB_SFX="${GIT_TEST_STRESS_JOB_NR:+.stress-$GIT_TEST_STRESS_JOB_NR}"
-TEST_NAME="$(basename "$0" .sh)"
+TEST_NAME="$(basename "$ARGZERO" .sh)"
 TEST_NUMBER="${TEST_NAME%%-*}"
 TEST_NUMBER="${TEST_NUMBER#t}"
 TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results"
@@ -388,7 +396,7 @@ then
 			      { test -z "$stress_limit" ||
 				test $cnt -le $stress_limit ; }
 			do
-				$TEST_SHELL_PATH "$0" "$@" >"$TEST_RESULTS_BASE.stress-$job_nr.out" 2>&1 &
+				$TEST_SHELL_PATH "$ARGZERO" "$@" >"$TEST_RESULTS_BASE.stress-$job_nr.out" 2>&1 &
 				test_pid=$!
 
 				if wait $test_pid
@@ -442,7 +450,7 @@ then
 	# from any previous runs.
 	>"$GIT_TEST_TEE_OUTPUT_FILE"
 
-	(GIT_TEST_TEE_STARTED=done ${TEST_SHELL_PATH} "$0" "$@" 2>&1;
+	(GIT_TEST_TEE_STARTED=done ${TEST_SHELL_PATH} "$ARGZERO" "$@" 2>&1;
 	 echo $? >"$TEST_RESULTS_BASE.exit") | tee -a "$GIT_TEST_TEE_OUTPUT_FILE"
 	test "$(cat "$TEST_RESULTS_BASE.exit")" = 0
 	exit
@@ -467,7 +475,7 @@ then
 	then
 		: Executed by a Bash version supporting BASH_XTRACEFD.  Good.
 	else
-		echo >&2 "warning: ignoring -x; '$0' is untraceable without BASH_XTRACEFD"
+		echo >&2 "warning: ignoring -x; '$ARGZERO' is untraceable without BASH_XTRACEFD"
 		trace=
 	fi
 fi
@@ -1595,7 +1603,7 @@ fi
 
 if test "${GIT_TEST_CHAIN_LINT:-1}" != 0
 then
-	"$PERL_PATH" "$TEST_DIRECTORY/chainlint.pl" "$0" ||
+	"$PERL_PATH" "$TEST_DIRECTORY/chainlint.pl" "$ARGZERO" ||
 		BUG "lint error (see '?!...!? annotations above)"
 fi
 
@@ -1637,7 +1645,7 @@ fi
 # in subprocesses like git equals our $PWD (for pathname comparisons).
 cd -P "$TRASH_DIRECTORY" || BAIL_OUT "cannot cd -P to \"$TRASH_DIRECTORY\""
 
-start_test_output "$0"
+start_test_output "$ARGZERO"
 
 # Convenience
 # A regexp to match 5 and 35 hexdigits
-- 
2.39.2.13.g1fb56cf030
Previous: Felipe ContrerasNext: Felipe Contreras
Message 3 of 29 in “test: make the test suite work with zsh”
  1. 0/6 test: make the test suite work with zshFelipe Contreras, Mar 28, 2023
  2. 3/6 test: avoid `options` variableFelipe Contreras, Mar 28, 2023
  3. 1/6 test: fix build for zshFelipe Contreras, Mar 28, 2023
  4. 5/6 test: hack for zshFelipe Contreras, Mar 28, 2023
  5. Felipe ContrerasMar 30, 2023
  6. 6/6 mergetools: vimdiff: check for empty fieldsFelipe Contreras, Mar 28, 2023
  7. 2/6 test: avoid `stat` variableFelipe Contreras, Mar 28, 2023
  8. Ævar Arnfjörð BjarmasonMar 29, 2023
  9. Taylor BlauApr 1, 2023
  10. Felipe ContrerasApr 1, 2023
  11. 4/6 test: avoid `path` variableFelipe Contreras, Mar 28, 2023
  12. brian m. carlsonMar 29, 2023
  13. Felipe ContrerasMar 29, 2023
  14. Ævar Arnfjörð BjarmasonMar 29, 2023
  15. Felipe ContrerasMar 29, 2023
  16. Felipe ContrerasMar 30, 2023
  17. Junio C HamanoMar 29, 2023
  18. Felipe ContrerasMar 29, 2023
  19. Junio C HamanoMar 30, 2023
  20. Felipe ContrerasMar 30, 2023
  21. Taylor BlauApr 1, 2023
  22. Felipe ContrerasApr 1, 2023
  23. Junio C HamanoApr 1, 2023
  24. Felipe ContrerasApr 1, 2023
  25. Taylor BlauApr 1, 2023
  26. Felipe ContrerasApr 1, 2023
  27. brian m. carlsonMar 29, 2023
  28. Junio C HamanoMar 30, 2023
  29. Felipe ContrerasMar 30, 2023

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.