From: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
To: git@vger.kernel.org
Cc: Matthew Ogilvie <mmogilvi_git@miniinfo.net>,
<Johannes.Schindelin@gmx.de>
Subject: [PATCH 08/10] run test suite without dashed git-commands in PATH
Date: Sat, 24 Jan 2009 16:43:19 -0700 [thread overview]
Message-ID: <1232840601-24696-9-git-send-email-mmogilvi_git@miniinfo.net> (raw)
In-Reply-To: <1232840601-24696-8-git-send-email-mmogilvi_git@miniinfo.net>
Exclude GIT_EXEC_PATH from PATH, to emulate the default user environment,
and ensure all the programs (especially scripts) run correctly in
such an environment.
This works by creating a test-bin directory with wrapper scripts for
the programs normally installed in "bin", and only including that
directory in the PATH.
Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
---
Valgrind conflict: As I was preparing this email, I noticed that a patch
for running the test suite under valgrind has been under discussion
in the mailing list. The valgrind patch probably conflicts with this
one. I've thought of some possible ways to resolve it:
1. Extend this patch to support valgrind by adding
environment-variable controlled hook to test-bin-wrapper.sh,
and enhance the makefile rules to disable the valgrind hook
for instances of the script that are wrapping other scripts.
(This allows dashless, valgrind, or both.)
2. Or change the valgrind patch to only add executables typically
found in bindir (not GIT_EXEC_PATH) to the symlink directory. To
support dashless by itself, it would need to do a similar symlink
when asked for dashless without valgrind.
3. Or keep the core of both patches, and just fix up the setup
in test-lib.sh to only enable one or the other (never both).
Thoughts?
--
Matthew Ogilvie [mmogilvi_git@miniinfo.net]
.gitignore | 1 +
Makefile | 42 +++++++++++++++++++++++++++++++-----------
t/test-lib.sh | 14 +++++++++++++-
test-bin-wrapper.sh | 12 ++++++++++++
4 files changed, 57 insertions(+), 12 deletions(-)
create mode 100644 test-bin-wrapper.sh
diff --git a/.gitignore b/.gitignore
index d9adce5..13a0d33 100644
--- a/.gitignore
+++ b/.gitignore
@@ -143,6 +143,7 @@ git-write-tree
git-core-*/?*
gitk-wish
gitweb/gitweb.cgi
+test-bin
test-chmtime
test-date
test-delta
diff --git a/Makefile b/Makefile
index b4d9cb4..197a6f0 100644
--- a/Makefile
+++ b/Makefile
@@ -330,6 +330,15 @@ ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
# what 'all' will build but not install in gitexecdir
OTHER_PROGRAMS = git$X gitweb/gitweb.cgi
+# what test wrappers are needed and 'install' will install, in bindir
+BINDIR_PROGRAMS_NEED_X += git
+BINDIR_PROGRAMS_NEED_X += git-upload-pack
+BINDIR_PROGRAMS_NEED_X += git-receive-pack
+BINDIR_PROGRAMS_NEED_X += git-upload-archive
+BINDIR_PROGRAMS_NEED_X += git-shell
+
+BINDIR_PROGRAMS_NO_X += git-cvsserver
+
# Set paths to tools early so that they can be used for version tests.
ifndef SHELL_PATH
SHELL_PATH = /bin/sh
@@ -1356,17 +1365,25 @@ endif
### Testing rules
-TEST_PROGRAMS += test-chmtime$X
-TEST_PROGRAMS += test-ctype$X
-TEST_PROGRAMS += test-date$X
-TEST_PROGRAMS += test-delta$X
-TEST_PROGRAMS += test-genrandom$X
-TEST_PROGRAMS += test-match-trees$X
-TEST_PROGRAMS += test-parse-options$X
-TEST_PROGRAMS += test-path-utils$X
-TEST_PROGRAMS += test-sha1$X
+TEST_PROGRAMS_NEED_X += test-chmtime
+TEST_PROGRAMS_NEED_X += test-ctype
+TEST_PROGRAMS_NEED_X += test-date
+TEST_PROGRAMS_NEED_X += test-delta
+TEST_PROGRAMS_NEED_X += test-genrandom
+TEST_PROGRAMS_NEED_X += test-match-trees
+TEST_PROGRAMS_NEED_X += test-parse-options
+TEST_PROGRAMS_NEED_X += test-path-utils
+TEST_PROGRAMS_NEED_X += test-sha1
+
+TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
-all:: $(TEST_PROGRAMS)
+test_bindir_programs := $(patsubst %,test-bin/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
+
+all:: $(TEST_PROGRAMS) $(test_bindir_programs)
+
+test-bin/%: test-bin-wrapper.sh
+ @mkdir -p test-bin
+ $(QUIET_GEN)sed -e 's|__GIT_EXEC_PATH__|$(shell pwd)|' -e 's|__PROG__|$(@F)|' < $< > $@ && chmod +x $@
# GNU make supports exporting all variables by "export" without parameters.
# However, the environment gets quite big, and some programs have problems
@@ -1425,11 +1442,13 @@ endif
gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
export gitexec_instdir
+install_bindir_programs := $(patsubst %,%$X,$(BINDIR_PROGRAMS_NEED_X)) $(BINDIR_PROGRAMS_NO_X)
+
install: all
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
- $(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X git-shell$X git-cvsserver '$(DESTDIR_SQ)$(bindir_SQ)'
+ $(INSTALL) $(install_bindir_programs) '$(DESTDIR_SQ)$(bindir_SQ)'
$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
$(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
ifndef NO_TCLTK
@@ -1533,6 +1552,7 @@ clean:
$(LIB_FILE) $(XDIFF_LIB)
$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
$(RM) $(TEST_PROGRAMS)
+ $(RM) -r test-bin
$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
$(RM) -r autom4te.cache
$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 41d5a59..2f42b5b 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -89,6 +89,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)
@@ -467,8 +469,18 @@ 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)
-PATH=$TEST_DIRECTORY/..:$PATH
GIT_EXEC_PATH=$(pwd)/..
+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"
+if test -n "$with_dashes" ; then
+ PATH="$TEST_DIRECTORY/..:$PATH"
+fi
GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
unset GIT_CONFIG
GIT_CONFIG_NOSYSTEM=1
diff --git a/test-bin-wrapper.sh b/test-bin-wrapper.sh
new file mode 100644
index 0000000..199d098
--- /dev/null
+++ b/test-bin-wrapper.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# test-bin-wrapper.sh: Template for git executable wrapper scripts
+# to run test suite against sandbox, but with only bindir-installed
+# executables in PATH. The Makefile copies this into various
+# files in test-bin, substituting __GIT_EXEC_PATH__ and __PROG__.
+
+GIT_EXEC_PATH="__GIT_EXEC_PATH__"
+GIT_TEMPLATE_DIR="__GIT_EXEC_PATH__/templates/blt"
+export GIT_EXEC_PATH GIT_TEMPLATE_DIR
+
+exec "${GIT_EXEC_PATH}/__PROG__" "$@"
--
1.6.1.81.g9833d.dirty
next prev parent reply other threads:[~2009-01-24 23:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-24 23:43 [PATCH 00/10] Misc. cvsserver, dashless, and test suite patches Matthew Ogilvie
2009-01-24 23:43 ` [PATCH 01/10] cvsserver: removed unused sha1Or-k mode from kopts_from_path Matthew Ogilvie
2009-01-24 23:43 ` [PATCH 02/10] cvsserver: add comments about database schema/usage Matthew Ogilvie
2009-01-24 23:43 ` [PATCH 03/10] cvsserver: remove unused functions _headrev and gethistory Matthew Ogilvie
2009-01-24 23:43 ` [PATCH 04/10] git-shell: allow running git-cvsserver, not just cvs Matthew Ogilvie
2009-01-24 23:43 ` [PATCH 05/10] cvsserver: run dashless "git command"s to access plumbing Matthew Ogilvie
2009-01-24 23:43 ` [PATCH 06/10] t2300: use documented technique to invoke git-sh-setup Matthew Ogilvie
2009-01-24 23:43 ` [PATCH 07/10] t3409: use dashless "git commit" instead of "git-commit" Matthew Ogilvie
2009-01-24 23:43 ` Matthew Ogilvie [this message]
2009-01-24 23:43 ` [PATCH 09/10] Revert "adapt git-cvsserver manpage to dash-free syntax" Matthew Ogilvie
2009-01-24 23:43 ` [PATCH 10/10] cvsserver doc: emphasize using CVS_SERVER= phrase within CVSROOT Matthew Ogilvie
2009-01-25 1:59 ` [PATCH 08/10] run test suite without dashed git-commands in PATH Johannes Schindelin
2009-01-26 6:40 ` Matthew Ogilvie
2009-01-26 11:06 ` Johannes Schindelin
2009-01-27 6:13 ` Matthew Ogilvie
2009-01-25 1:53 ` [PATCH 04/10] git-shell: allow running git-cvsserver, not just cvs Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1232840601-24696-9-git-send-email-mmogilvi_git@miniinfo.net \
--to=mmogilvi_git@miniinfo.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).