Allow running the test suite against installed git
cover Allow running the test suite against installed git
Part 1 corrects only an inconsistency which does not matter as long as you run tests against git compiled in a checkout only: There, $GIT_EXEC_PATH contains git, in general it does not.
Part 2 allows running the test suite against a git installed anywhere in the file system. This has at least 2 use cases:
- Test an installed distro package after the installation.
- Run easily current tests against older versions, or vice versa, if you have those versions installed somewhere.
Note that one still needs git compiled in git.git for test helpers etc., and also because I did not adjust the paths to templates and such. I did not really feel a need for that.
Also, t0000 there is still one explicit use of "../git" which is fine because it simply tests for the presence of a built, which we need anyways.
Michael J Gruber (2):
test-lib.sh: Test for presence of git-init in the right path. test-lib.sh: Allow running the test suite against installed git
t/test-lib.sh | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
PATCH 1/2 test-lib.sh: Test for presence of git-init in the right path.
It just happens so that when GIT_EXEC_PATH points to a compiled checkout of git.git it contains "git". Since this is not true in general make test-lib check for "git-init" which is always in GIT_EXEC_PATH.
--- t/test-lib.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
t/test-lib.sh +1 -1
@@ -454,7 +454,7 @@ test_create_repo () { repo="$1" mkdir -p "$repo" cd "$repo" || error "Cannot setup test environment" - "$GIT_EXEC_PATH/git" init "--template=$owd/../templates/blt/" >&3 2>&4 || + "$GIT_EXEC_PATH/git-init" "--template=$owd/../templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" mv .git/hooks .git/hooks-disabled cd "$owd"
Signature · 1 line
1.6.2.149.g6462
PATCH 2/2 test-lib.sh: Allow running the test suite against installed git
Introduce variables externalpath and externalexecpath such that the test suite can be run against a git which is installed at $externalpath with subcommands at $externalexecpath. externalpath defaults to the git.git checkout, externalexecpath defaults to $externalpath. Run the suite as
externalpath=somepath externalexecpath=someotherpath make test
but note that this requires and uses parts of a compiled git in the git.git checkout: test helpers, templates and perl libraries are taken from there.
--- t/test-lib.sh | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-)
t/test-lib.sh +8 -2
@@ -514,8 +514,14 @@ test_done () { TEST_DIRECTORY=$(pwd) if test -z "$valgrind" then - PATH=$TEST_DIRECTORY/..:$PATH - GIT_EXEC_PATH=$TEST_DIRECTORY/.. + if test -z "$externalpath" + then + PATH=$TEST_DIRECTORY/..:$PATH + GIT_EXEC_PATH=$TEST_DIRECTORY/.. + else + PATH=$externalpath:$TEST_DIRECTORY/..:$PATH + GIT_EXEC_PATH=${externalexecpath:-$externalpath} + fi else make_symlink () { test -h "$2" &&
Signature · 1 line
1.6.2.149.g6462
Re: [PATCH 2/2] test-lib.sh: Allow running the test suite against installed git
Quoted 10 lines · Michael J Gruber
Introduce variables externalpath and externalexecpath such that the test suite can be run against a git which is installed at $externalpath with subcommands at $externalexecpath. externalpath defaults to the git.git checkout, externalexecpath defaults to $externalpath. Run the suite as
externalpath=somepath externalexecpath=someotherpath make test
but note that this requires and uses parts of a compiled git in the git.git checkout: test helpers, templates and perl libraries are taken from there.
While I like the end result this series tries to achieve, may I suggest a few things?
- This is like GIT_SKIP_TESTS and GIT_TEST_HTTPD in that extra environments affect how the tests are run. It would be much easier to use if the new environment variables are named similarly, prefixed with GIT_, in all caps, and with underscores between words.
- When externalpath is given but not externalexecpath, you can deduce the latter from the former by running "$externalpath/git --exec-path", which makes running the tests against an installed git even easier. For example, I keep many git installations under $HOME/git-snap-vX.Y.Z, and it would be great if your patch allowed me to say something like:
$ GIT_TEST_INSTALLED=$HOME/git-snap-v1.4.4.4/bin/git make test
v2 cover Allow running the test suite against installed git
Part 1 corrects only an inconsistency which does not matter as long as you run tests against git compiled in a checkout only: There, $GIT_EXEC_PATH contains git, in general it does not.
Part 2 allows running the test suite against a git installed anywhere in the file system. This has at least 2 use cases:
- Test an installed distro package after the installation.
- Run easily current tests against older versions, or vice versa, if you have those versions installed somewhere.
Note that one still needs git compiled in git.git for test helpers etc., and also because I did not adjust the paths to templates and such. I did not really feel a need for that.
Also, in t0000 there is still one explicit use of "../git" which is fine because it simply tests for the presence of a build, which we need anyways.
v2 incorporates feed-back by JCH: variables are named GIT_TEST_INSTALLED and GIT_TEST_EXEC_PATH now, the latter defaulting to the output of $GIT_TEST_INSTALLED/git --exec-path.
Also, we exit gracefully in case we cannot run $GIT_TEST_INSTALLED/git.
Michael J Gruber (2):
test-lib.sh: Test for presence of git-init in the right path. test-lib.sh: Allow running the test suite against installed git
t/test-lib.sh | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
PATCH v2 1/2 test-lib.sh: Test for presence of git-init in the right path.
In reply to Junio C HamanoIt just happens so that when GIT_EXEC_PATH points to a compiled checkout of git.git it contains "git". Since this is not true in general make test-lib check for "git-init" which is always in GIT_EXEC_PATH.
--- t/test-lib.sh | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
t/test-lib.sh +1 -1
@@ -454,7 +454,7 @@ test_create_repo () { repo="$1" mkdir -p "$repo" cd "$repo" || error "Cannot setup test environment" - "$GIT_EXEC_PATH/git" init "--template=$owd/../templates/blt/" >&3 2>&4 || + "$GIT_EXEC_PATH/git-init" "--template=$owd/../templates/blt/" >&3 2>&4 || error "cannot run git init -- have you built things yet?" mv .git/hooks .git/hooks-disabled cd "$owd"
Signature · 1 line
1.6.2.149.g6462
PATCH v2 2/2 test-lib.sh: Allow running the test suite against installed git
In reply to Junio C HamanoIntroduce variables GIT_TEST_INSTALLED and GIT_TEST_EXEC_PATH such that the test suite can be run against a git which is installed at GIT_TEST_INSTALLED with subcommands at GIT_TEST_EXEC_PATH. GIT_TEST_INSTALLED defaults to the git.git checkout, GIT_TEST_EXEC_PATH defaults to the output of '$GIT_TEST_INSTALLED/git --exec-path'. Run the suite e.g. as
GIT_TEST_INSTALLED=/some/path make test
but note that this requires and uses parts of a compiled git in the git.git checkout: test helpers, templates and perl libraries are taken from there.
--- t/test-lib.sh | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
t/test-lib.sh +10 -2
@@ -514,8 +514,16 @@ test_done () { TEST_DIRECTORY=$(pwd) if test -z "$valgrind" then - PATH=$TEST_DIRECTORY/..:$PATH - GIT_EXEC_PATH=$TEST_DIRECTORY/.. + if test -z "$GIT_TEST_INSTALLED" + then + PATH=$TEST_DIRECTORY/..:$PATH + GIT_EXEC_PATH=$TEST_DIRECTORY/.. + else + GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) || + error "Cannot run git from $GIT_TEST_INSTALLED." + PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH + GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH} + fi else make_symlink () { test -h "$2" &&
Signature · 1 line
1.6.2.149.g6462