# [PATCH 0/2] Allow running the test suite against installed git

7 messages from 2009-03-13 to 2009-03-16. Participants: Michael J Gruber, Junio C Hamano.
Thread: https://gitlist.dev/t/18303

## Michael J Gruber, 2009-03-13 15:45

Subject: [PATCH 0/2] Allow running the test suite against installed git
Message-ID: <1236959116-3334-1-git-send-email-git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/1236959116-3334-1-git-send-email-git%40drmicha.warpmail.net

```
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(-)

```

## Michael J Gruber, 2009-03-13 15:45

Subject: [PATCH 1/2] test-lib.sh: Test for presence of git-init in the right path.
Message-ID: <1236959116-3334-2-git-send-email-git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/1236959116-3334-2-git-send-email-git%40drmicha.warpmail.net
In-Reply-To: <1236959116-3334-1-git-send-email-git@drmicha.warpmail.net>

```
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.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 t/test-lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7a847ec..b9da86e 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -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"
-- 
1.6.2.149.g6462

```

## Michael J Gruber, 2009-03-13 15:45

Subject: [PATCH 2/2] test-lib.sh: Allow running the test suite against installed git
Message-ID: <1236959116-3334-3-git-send-email-git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/1236959116-3334-3-git-send-email-git%40drmicha.warpmail.net
In-Reply-To: <1236959116-3334-2-git-send-email-git@drmicha.warpmail.net>

```
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.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 t/test-lib.sh |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index b9da86e..f6c467f 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -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" &&
-- 
1.6.2.149.g6462

```

## Junio C Hamano, 2009-03-14 20:25

Subject: Re: [PATCH 2/2] test-lib.sh: Allow running the test suite against installed git
Message-ID: <7v3adfc0n4.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v3adfc0n4.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1236959116-3334-3-git-send-email-git@drmicha.warpmail.net>

```
Michael J Gruber <git@drmicha.warpmail.net> writes:

> 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

```

## Michael J Gruber, 2009-03-16 17:03

Subject: [PATCHv2 0/2] Allow running the test suite against installed git
Message-ID: <1237222992-19421-1-git-send-email-git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/1237222992-19421-1-git-send-email-git%40drmicha.warpmail.net
In-Reply-To: <7v3adfc0n4.fsf@gitster.siamese.dyndns.org>

```
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(-)

```

## Michael J Gruber, 2009-03-16 17:03

Subject: [PATCHv2 1/2] test-lib.sh: Test for presence of git-init in the right path.
Message-ID: <1237222992-19421-2-git-send-email-git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/1237222992-19421-2-git-send-email-git%40drmicha.warpmail.net
In-Reply-To: <7v3adfc0n4.fsf@gitster.siamese.dyndns.org>

```
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.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 t/test-lib.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7a847ec..b9da86e 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -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"
-- 
1.6.2.149.g6462

```

## Michael J Gruber, 2009-03-16 17:03

Subject: [PATCHv2 2/2] test-lib.sh: Allow running the test suite against installed git
Message-ID: <1237222992-19421-3-git-send-email-git@drmicha.warpmail.net>
URL: https://gitlist.dev/e/1237222992-19421-3-git-send-email-git%40drmicha.warpmail.net
In-Reply-To: <7v3adfc0n4.fsf@gitster.siamese.dyndns.org>

```
Introduce 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.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
 t/test-lib.sh |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index b9da86e..c677904 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -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" &&
-- 
1.6.2.149.g6462

```
