Skip to content

Commit 7cf7f54

Browse files
peffgitster
authored andcommitted
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>
1 parent 7533687 commit 7cf7f54

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
GIT-BUILD-OPTIONS
12
GIT-CFLAGS
23
GIT-GUI-VARS
34
GIT-VERSION-FILE

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ export TAR INSTALL DESTDIR SHELL_PATH
812812

813813
### Build rules
814814

815-
all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS)
815+
all:: $(ALL_PROGRAMS) $(BUILT_INS) $(OTHER_PROGRAMS) GIT-BUILD-OPTIONS
816816
ifneq (,$X)
817817
$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$p';)
818818
endif
@@ -1011,6 +1011,9 @@ GIT-CFLAGS: .FORCE-GIT-CFLAGS
10111011
echo "$$FLAGS" >GIT-CFLAGS; \
10121012
fi
10131013

1014+
GIT-BUILD-OPTIONS: .FORCE-GIT-BUILD-OPTIONS
1015+
@echo SHELL_PATH=\''$(SHELL_PATH_SQ)'\' >$@
1016+
10141017
### Detect Tck/Tk interpreter path changes
10151018
ifndef NO_TCLTK
10161019
TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
@@ -1166,10 +1169,11 @@ ifndef NO_TCLTK
11661169
$(MAKE) -C gitk-git clean
11671170
$(MAKE) -C git-gui clean
11681171
endif
1169-
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS
1172+
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
11701173

11711174
.PHONY: all install clean strip
11721175
.PHONY: .FORCE-GIT-VERSION-FILE TAGS tags cscope .FORCE-GIT-CFLAGS
1176+
.PHONY: .FORCE-GIT-BUILD-OPTIONS
11731177

11741178
### Check documentation
11751179
#

t/t3404-rebase-interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test_expect_success 'setup' '
6161
git tag I
6262
'
6363

64-
echo "#!$SHELL" >fake-editor
64+
echo "#!$SHELL_PATH" >fake-editor.sh
6565
cat >> fake-editor.sh <<\EOF
6666
case "$1" in
6767
*/COMMIT_EDITMSG)

t/test-lib.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ if ! test -x ../test-chmtime; then
359359
exit 1
360360
fi
361361

362+
. ../GIT-BUILD-OPTIONS
363+
362364
# Test repository
363365
test=trash
364366
rm -fr "$test"

0 commit comments

Comments
 (0)