From: Junio C Hamano <gitster@pobox.com>
To: Thomas Rast <trast@inf.ethz.ch>
Cc: Jakub Narebski <jnareb@gmail.com>,
Thomas Rast <trast@student.ethz.ch>, <git@vger.kernel.org>,
Michal Privoznik <mprivozn@redhat.com>, Jeff King <peff@peff.net>
Subject: Re: [PATCH 1/2] perf: compare diff algorithms
Date: Wed, 07 Mar 2012 09:45:19 -0800 [thread overview]
Message-ID: <7vk42wnw40.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <877gywy40l.fsf@thomas.inf.ethz.ch> (Thomas Rast's message of "Wed, 7 Mar 2012 13:44:26 +0100")
Thomas Rast <trast@inf.ethz.ch> writes:
> Jakub Narebski <jnareb@gmail.com> writes:
>
>> Thomas, take a look at how it is solved in 't/t9700/test.pl', used by
>> 't/t9700-perl-git.sh':
>>
>> use lib (split(/:/, $ENV{GITPERLLIB}));
>
> Hum. The problem is that the user may invoke aggregate.perl manually,
> and GITPERLLIB won't be set in that case.
I would equate "manual invocation" with "the user knows what he is doing",
so if that is the only problem, I think we are good.
> Is there a better solution than duplicating the logic that sets
> GITPERLLIB in test-lib.sh within aggregate.perl?
Perhaps the part to figure out the directory layout can and should
be split out of test-lib.sh into test-env.sh or something and be
dot-sourced at the beginning of test-lib.sh; would that help?
t/test-env.sh | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
t/test-lib.sh | 118 ++++-----------------------------------------------------
2 files changed, 120 insertions(+), 110 deletions(-)
diff --git a/t/test-env.sh b/t/test-env.sh
new file mode 100644
index 0000000..1159c5a
--- /dev/null
+++ b/t/test-env.sh
@@ -0,0 +1,112 @@
+# figure out the environment a test-related script is being run
+# taken from test-lib.sh, Copyright (c) 2005 Junio C Hamano
+
+# The directory to find other helper pieces e.g. lib-gpg.sh of the
+# test suite; usually t/ in the git source tree.
+if test -z "$TEST_DIRECTORY"
+then
+ # We allow tests to override this, in case they want to run tests
+ # outside of t/, e.g. for running tests on the test library
+ # itself.
+ TEST_DIRECTORY=$(pwd)
+fi
+GIT_BUILD_DIR="$TEST_DIRECTORY"/..
+GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
+GITPERLLIB="$GIT_BUILD_DIR"/perl/blib/lib:"$GIT_BUILD_DIR"/perl/blib/arch/auto/Git
+
+if test -n "$valgrind"
+then
+ make_symlink () {
+ test -h "$2" &&
+ test "$1" = "$(readlink "$2")" || {
+ # be super paranoid
+ if mkdir "$2".lock
+ then
+ rm -f "$2" &&
+ ln -s "$1" "$2" &&
+ rm -r "$2".lock
+ else
+ while test -d "$2".lock
+ do
+ say "Waiting for lock on $2."
+ sleep 1
+ done
+ fi
+ }
+ }
+
+ make_valgrind_symlink () {
+ # handle only executables, unless they are shell libraries that
+ # need to be in the exec-path. We will just use "#!" as a
+ # guess for a shell-script, since we have no idea what the user
+ # may have configured as the shell path.
+ test -x "$1" ||
+ test "#!" = "$(head -c 2 <"$1")" ||
+ return;
+
+ base=$(basename "$1")
+ symlink_target=$GIT_BUILD_DIR/$base
+ # do not override scripts
+ if test -x "$symlink_target" &&
+ test ! -d "$symlink_target" &&
+ test "#!" != "$(head -c 2 < "$symlink_target")"
+ then
+ symlink_target=../valgrind.sh
+ fi
+ case "$base" in
+ *.sh|*.perl)
+ symlink_target=../unprocessed-script
+ esac
+ # create the link, or replace it if it is out of date
+ make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit
+ }
+
+ # override all git executables in TEST_DIRECTORY/..
+ GIT_VALGRIND=$TEST_DIRECTORY/valgrind
+ mkdir -p "$GIT_VALGRIND"/bin
+ for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
+ do
+ make_valgrind_symlink $file
+ done
+ # special-case the mergetools loadables
+ make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools"
+ OLDIFS=$IFS
+ IFS=:
+ for path in $PATH
+ do
+ ls "$path"/git-* 2> /dev/null |
+ while read file
+ do
+ make_valgrind_symlink "$file"
+ done
+ done
+ IFS=$OLDIFS
+ PATH=$GIT_VALGRIND/bin:$PATH
+ GIT_EXEC_PATH=$GIT_VALGRIND/bin
+ export GIT_VALGRIND
+elif test -n "$GIT_TEST_INSTALLED" ; then
+ GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
+ error "Cannot run git from $GIT_TEST_INSTALLED."
+ PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
+ GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
+else # normal case, use ../bin-wrappers only unless $with_dashes:
+ git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
+ 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"
+ GIT_EXEC_PATH=$GIT_BUILD_DIR
+ if test -n "$with_dashes" ; then
+ PATH="$GIT_BUILD_DIR:$PATH"
+ fi
+fi
+GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
+
+. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
+
+GITPERLLIB="$GIT_BUILD_DIR"/perl/blib/lib:"$GIT_BUILD_DIR"/perl/blib/arch/auto/Git
+
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GITPERLLIB
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 30ed4d7..e892368 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -31,6 +31,13 @@ done,*)
;;
esac
+# Protect ourselves from common misconfiguration to export
+# CDPATH into the environment
+unset CDPATH
+unset GREP_OPTIONS
+
+. ./test-env.sh
+
# Keep the original TERM for say_color
ORIGINAL_TERM=$TERM
@@ -72,12 +79,6 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR
-# Protect ourselves from common misconfiguration to export
-# CDPATH into the environment
-unset CDPATH
-
-unset GREP_OPTIONS
-
case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
1|2|true)
echo "* warning: Some tests will not work if GIT_TRACE" \
@@ -380,117 +381,17 @@ test_done () {
esac
}
-# Test the binaries we have just built. The tests are kept in
-# t/ subdirectory and are run in 'trash directory' subdirectory.
-if test -z "$TEST_DIRECTORY"
-then
- # We allow tests to override this, in case they want to run tests
- # outside of t/, e.g. for running tests on the test library
- # itself.
- TEST_DIRECTORY=$(pwd)
-fi
if test -z "$TEST_OUTPUT_DIRECTORY"
then
# Similarly, override this to store the test-results subdir
# elsewhere
TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
fi
-GIT_BUILD_DIR="$TEST_DIRECTORY"/..
-if test -n "$valgrind"
-then
- make_symlink () {
- test -h "$2" &&
- test "$1" = "$(readlink "$2")" || {
- # be super paranoid
- if mkdir "$2".lock
- then
- rm -f "$2" &&
- ln -s "$1" "$2" &&
- rm -r "$2".lock
- else
- while test -d "$2".lock
- do
- say "Waiting for lock on $2."
- sleep 1
- done
- fi
- }
- }
-
- make_valgrind_symlink () {
- # handle only executables, unless they are shell libraries that
- # need to be in the exec-path. We will just use "#!" as a
- # guess for a shell-script, since we have no idea what the user
- # may have configured as the shell path.
- test -x "$1" ||
- test "#!" = "$(head -c 2 <"$1")" ||
- return;
-
- base=$(basename "$1")
- symlink_target=$GIT_BUILD_DIR/$base
- # do not override scripts
- if test -x "$symlink_target" &&
- test ! -d "$symlink_target" &&
- test "#!" != "$(head -c 2 < "$symlink_target")"
- then
- symlink_target=../valgrind.sh
- fi
- case "$base" in
- *.sh|*.perl)
- symlink_target=../unprocessed-script
- esac
- # create the link, or replace it if it is out of date
- make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit
- }
-
- # override all git executables in TEST_DIRECTORY/..
- GIT_VALGRIND=$TEST_DIRECTORY/valgrind
- mkdir -p "$GIT_VALGRIND"/bin
- for file in $GIT_BUILD_DIR/git* $GIT_BUILD_DIR/test-*
- do
- make_valgrind_symlink $file
- done
- # special-case the mergetools loadables
- make_symlink "$GIT_BUILD_DIR"/mergetools "$GIT_VALGRIND/bin/mergetools"
- OLDIFS=$IFS
- IFS=:
- for path in $PATH
- do
- ls "$path"/git-* 2> /dev/null |
- while read file
- do
- make_valgrind_symlink "$file"
- done
- done
- IFS=$OLDIFS
- PATH=$GIT_VALGRIND/bin:$PATH
- GIT_EXEC_PATH=$GIT_VALGRIND/bin
- export GIT_VALGRIND
-elif test -n "$GIT_TEST_INSTALLED" ; then
- GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
- error "Cannot run git from $GIT_TEST_INSTALLED."
- PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
- GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
-else # normal case, use ../bin-wrappers only unless $with_dashes:
- git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
- 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"
- GIT_EXEC_PATH=$GIT_BUILD_DIR
- if test -n "$with_dashes" ; then
- PATH="$GIT_BUILD_DIR:$PATH"
- fi
-fi
-GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
unset GIT_CONFIG
GIT_CONFIG_NOSYSTEM=1
GIT_ATTR_NOSYSTEM=1
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
+export GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
@@ -503,9 +404,6 @@ then
GIT_TEST_CMP="$DIFF -u"
fi
fi
-
-GITPERLLIB="$GIT_BUILD_DIR"/perl/blib/lib:"$GIT_BUILD_DIR"/perl/blib/arch/auto/Git
-export GITPERLLIB
test -d "$GIT_BUILD_DIR"/templates/blt || {
error "You haven't built things yet, have you?"
}
next prev parent reply other threads:[~2012-03-07 17:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-06 10:59 [PATCH] config: Introduce --patience config variable Michal Privoznik
2012-03-06 11:49 ` Jeff King
2012-03-06 13:01 ` Thomas Rast
2012-03-06 13:15 ` [PATCH 1/2] perf: compare diff algorithms Thomas Rast
2012-03-06 13:15 ` [PATCH 2/2] Document the --histogram diff option Thomas Rast
2012-03-06 19:57 ` Junio C Hamano
2012-03-06 20:42 ` Thomas Rast
2012-03-06 19:52 ` [PATCH 1/2] perf: compare diff algorithms Junio C Hamano
2012-03-06 21:00 ` Thomas Rast
2012-03-06 21:18 ` Junio C Hamano
2012-03-06 21:41 ` Jakub Narebski
2012-03-07 12:44 ` Thomas Rast
2012-03-07 17:45 ` Junio C Hamano [this message]
2012-03-07 18:03 ` Jakub Narebski
2012-03-07 18:19 ` Junio C Hamano
2012-03-10 7:13 ` René Scharfe
2012-03-06 13:30 ` [PATCH] config: Introduce --patience config variable Jeff King
2012-03-06 13:32 ` Michal Privoznik
2012-03-06 13:38 ` Matthieu Moy
2012-03-06 14:09 ` Jeff King
2012-03-07 2:57 ` Junio C Hamano
2012-03-07 11:47 ` Jeff King
2012-03-07 17:24 ` Junio C Hamano
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=7vk42wnw40.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
--cc=mprivozn@redhat.com \
--cc=peff@peff.net \
--cc=trast@inf.ethz.ch \
--cc=trast@student.ethz.ch \
/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).