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

Re: [PATCH 2/3] t3404: use configured shell instead of /bin/sh

From
Jeff King <peff@peff.net>
Date
Feb 24, 2008, 19:40 UTC
Message-ID
<20080224194045.GA27606@coredump.intra.peff.net>
In-Reply-To
<7vfxvjxlsv.fsf@gitster.siamese.dyndns.org>
On Sat, Feb 23, 2008 at 04:03:44PM -0800, Junio C Hamano wrote:
> Sounds sane to me.

OK, here it is cleaned up a little (adding some missing quotation marks and the proper gitignore) and with a commit message.

Possibly t/Makefile should also be getting this information to actually
run the test scripts. That would require either:
  - making the GIT-BUILD-OPTIONS both make and shell parseable, meaning
    changing SHELL_PATH='$(SHELL_PATH_SQ)' into SHELL_PATH=$(SHELL_PATH)
    and hoping nobody uses metacharacters
  - writing two separate files, one for shell and one for make
  - working some Makefile magic to set variables from the shell; this is
    not possible in ordinary make, but I suspect there are some GNU-isms
    we could use

-- >8 -- use build-time SHELL_PATH in test scripts

The top-level Makefile now creates a GIT-BUILD-OPTIONS file which stores any options selected by the make process that may be of use to further parts of the build process. Specifically, we store the SHELL_PATH so that it can be used by tests to construct shell scripts on the fly.

The format of the GIT-BUILD-OPTIONS file is Bourne shell, and it is sourced by test-lib.sh; all tests can rely on just having $SHELL_PATH correctly set in the environment.

The GIT-BUILD-OPTIONS file is written every time the toplevel 'make' is invoked. Since the only users right now are the test scripts, there's no drawback to updating its timestamp. If something build-related depends on this, we can do a trick similar to the one used by GIT-CFLAGS.

Signed-off-by: Jeff King <peff@peff.net>
---
 .gitignore                    |    1 +
 Makefile                      |    6 +++++-
 t/t3404-rebase-interactive.sh |    2 +-
 t/test-lib.sh                 |    2 ++
 4 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 165b256..4ff2fec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+GIT-BUILD-OPTIONS
 GIT-CFLAGS
 GIT-GUI-VARS
 GIT-VERSION-FILE
diff --git a/Makefile b/Makefile
index d33a556..ba1aaf8 100644
--- a/Makefile
+++ b/Makefile
@@ -808,7 +808,7 @@ export TAR INSTALL DESTDIR SHELL_PATH
 
 ### Build rules
 
-all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS)
+all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
 ifneq (,$X)
 	$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$p';)
 endif
@@ -1010,6 +1010,9 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
 		echo "$$FLAGS" >GIT-CFLAGS; \
             fi
 
+GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
+	@echo SHELL_PATH='$(SHELL_PATH_SQ)' >$@
+
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
 TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
@@ -1169,6 +1172,7 @@ endif
 
 .PHONY: all install clean strip
 .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
+.PHONY: .FORCE-GIT-BUILD-OPTIONS
 
 ### Check documentation
 #
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 62e65d7..049aa37 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -61,7 +61,7 @@ test_expect_success 'setup' '
 	git tag I
 '
 
-echo "#!$SHELL" >fake-editor
+echo "#!$SHELL_PATH" >fake-editor.sh
 cat >> fake-editor.sh <<\EOF
 case "$1" in
 */COMMIT_EDITMSG)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 83889c4..3c4e21f 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -342,6 +342,8 @@ if ! test -x ../test-chmtime; then
 	exit 1
 fi
 
+. ../GIT-BUILD-OPTIONS
+
 # Test repository
 test=trash
 rm -fr "$test"
-- 
1.5.4.2.276.g0ede
Previous: Junio C HamanoNext: Jeff King
Message 16 of 28 in “solaris test results”
  1. 0/3 solaris test resultsJeff King, Feb 20, 2008
  2. 1/3 git_config_*: don't assume we are parsing a config fileJeff King, Feb 21, 2008
  3. 2/3 t3404: use configured shell instead of /bin/shJeff King, Feb 21, 2008
  4. Johannes SixtFeb 23, 2008
  5. Junio C HamanoFeb 23, 2008
  6. Junio C HamanoFeb 23, 2008
  7. Johannes SixtFeb 23, 2008
  8. Jeff KingFeb 23, 2008
  9. Junio C HamanoFeb 23, 2008
  10. Jeff KingFeb 23, 2008
  11. Junio C HamanoFeb 23, 2008
  12. Jeff KingFeb 23, 2008
  13. Junio C HamanoFeb 23, 2008
  14. Jeff KingFeb 23, 2008
  15. Junio C HamanoFeb 24, 2008
  16. Jeff KingFeb 24, 2008
  17. Jeff KingFeb 23, 2008
  18. Junio C HamanoFeb 23, 2008
  19. Jeff KingFeb 23, 2008
  20. Jeff KingFeb 23, 2008
  21. Junio C HamanoFeb 23, 2008
  22. Jeff KingFeb 23, 2008
  23. 3/3 diff: fix java funcname pattern for solarisJeff King, Feb 21, 2008
  24. Junio C HamanoFeb 21, 2008
  25. Jeff KingFeb 21, 2008
  26. Junio C HamanoFeb 22, 2008
  27. Junio C HamanoFeb 22, 2008
  28. Jeff KingFeb 22, 2008

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.