@matheusbsbs / matheus-bagliano / commits / 7cf7f54a65
Fork 0

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 24, 2008 at 14:40 UTC 7cf7f54a65aa1c70e21fe73753f6b0671d129adf
4 files changed +10 -3
.gitignore
+1
@@ -1,3 +1,4 @@
1 +GIT-BUILD-OPTIONS
2 GIT-CFLAGS
3 GIT-GUI-VARS
4 GIT-VERSION-FILE
Makefile
+6 -2
@@ -812,7 +812,7 @@ export TAR INSTALL DESTDIR SHELL_PATH
812
813 ### Build rules
814
815 -all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS)
815 +all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
816 ifneq (,$X)
817 $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$p';)
818 endif
@@ -1011,6 +1011,9 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
1011 echo "$$FLAGS" >GIT-CFLAGS; \
1012 fi
1013
1014 +GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
1015 + @echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
1016 +
1017 ### Detect Tck/Tk interpreter path changes
1018 ifndef NO_TCLTK
1019 TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
@@ -1166,10 +1169,11 @@ ifndef NO_TCLTK
1169 $(MAKE) -C gitk-git clean
1170 $(MAKE) -C git-gui clean
1171 endif
1169 - $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS
1172 + $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
1173
1174 .PHONY: all install clean strip
1175 .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
1176 +.PHONY: .FORCE-GIT-BUILD-OPTIONS
1177
1178 ### Check documentation
1179 #
t/t3404-rebase-interactive.sh
+1 -1
@@ -61,7 +61,7 @@ test_expect_success 'setup' '
61 git tag I
62 '
63
64 -echo "#!$SHELL" >fake-editor
64 +echo "#!$SHELL_PATH" >fake-editor.sh
65 cat >> fake-editor.sh <<\EOF
66 case "$1" in
67 */COMMIT_EDITMSG)
t/test-lib.sh
+2
@@ -359,6 +359,8 @@ if ! test -x ../test-chmtime; then
359 exit 1
360 fi
361
362 +. ../GIT-BUILD-OPTIONS
363 +
364 # Test repository
365 test=trash
366 rm -fr "$test"