git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: git@vger.kernel.org
Cc: tboegi@web.de
Subject: [RFC]  test-lib.sh: preprocess to use PERL_PATH
Date: Sat, 23 Jun 2012 07:04:37 +0200	[thread overview]
Message-ID: <201206230704.38648.tboegi@web.de> (raw)

All test cases found in t/*.sh must include test-lib instead of test-lib.sh

Replace the inclusion of GIT-BUILD-OPTIONS with definitions that are filled in
during preprocessing.

The new test-lib doesn't need to to open GIT-BUILD-OPTIONS for each
test script, which speeds up the execution a bit.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---

Note: The diff of all files in t/* is not here in this patch - the mail seems not to got through when I add
all the diffs here.

So this patch is incomplete and should show the idea.

I ran the following script to do the changes:
sedmulti.sh t/*
(where sedmulti.sh is below:)

====================
#!/bin/sh

if [ $# -lt 3 ]; then
  echo "usage sedmulti <fromtext> <totext> filename ..." >&2
        exit 1;
fi

fromtext=$1;
shift;
totext=$1;
shift;

for f in "$@"; do
  echo sed -ire "s%$fromtext%$totext%g" $f
  sed -ire "s%$fromtext%$totext%g" $f
done
===================


 .gitignore    |    1 +
 Makefile      |    4 ++++
 t/README      |    8 ++++----
 t/test-lib.sh |   11 ++++++++---
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index bf66648..62c60ce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -192,6 +192,7 @@
 /test-sigchain
 /test-subprocess
 /test-svn-fe
+t/test-lib
 /common-cmds.h
 *.tar.gz
 *.dsc
diff --git a/Makefile b/Makefile
index 0914133..d540ab6 100644
--- a/Makefile
+++ b/Makefile
@@ -442,6 +442,7 @@ SCRIPT_LIB += git-rebase--interactive
 SCRIPT_LIB += git-rebase--merge
 SCRIPT_LIB += git-sh-setup
 SCRIPT_LIB += git-sh-i18n
+SCRIPT_LIB += t/test-lib
 
 SCRIPT_PERL += git-add--interactive.perl
 SCRIPT_PERL += git-difftool.perl
@@ -2018,6 +2019,9 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \
     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
     -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \
+    -e 's|@@PERL_PATH@@|$(PERL_PATH)|g' \
+    -e 's|@@PYTHON_PATH@@|$(PYTHON_PATH)|g' \
+    -e 's|@@TAR@@|$(TAR)|g' \
     -e $(BROKEN_PATH_FIX) \
     $@.sh >$@+
 endef
diff --git a/t/README b/t/README
index 4c3ea25..fa23726 100644
--- a/t/README
+++ b/t/README
@@ -203,7 +203,7 @@ the top-level test script, never name the file to match the above
 pattern.  The Makefile here considers all such files as the
 top-level test script and tries to run all of them.  Care is
 especially needed if you are creating a common test library
-file, similar to test-lib.sh, because such a library file may
+file, similar to test-lib, because such a library file may
 not be suitable for standalone execution.
 
 
@@ -225,13 +225,13 @@ assignment to variable 'test_description', like this:
 	and tries to run git-ls-files with option --frotz.'
 
 
-Source 'test-lib.sh'
+Source 'test-lib'
 --------------------
 
 After assigning test_description, the test script should source
-test-lib.sh like this:
+test-lib like this:
 
-	. ./test-lib.sh
+	. ./test-lib
 
 This test harness library does the following things:
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 9e2b711..306fcd9 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -46,7 +46,7 @@ EDITOR=:
 # /usr/xpg4/bin/sh and /bin/ksh to bail out.  So keep the unsets
 # deriving from the command substitution clustered with the other
 # ones.
-unset VISUAL EMAIL LANGUAGE COLUMNS $(perl -e '
+unset VISUAL EMAIL LANGUAGE COLUMNS $(@@PERL_PATH@@ -e '
 	my @env = keys %ENV;
 	my $ok = join("|", qw(
 		TRACE
@@ -107,7 +107,7 @@ export _x05 _x40 _z40 LF
 # test_description='Description of this test...
 # This test checks if command xyzzy does the right thing...
 # '
-# . ./test-lib.sh
+# . ./test-lib
 [ "x$ORIGINAL_TERM" != "xdumb" ] && (
 		TERM=$ORIGINAL_TERM &&
 		export TERM &&
@@ -492,7 +492,12 @@ GIT_CONFIG_NOSYSTEM=1
 GIT_ATTR_NOSYSTEM=1
 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
 
-. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
+SHELL_PATH='@SHELL_PATH@'
+PERL_PATH='@@PERL_PATH@@'
+DIFF='@@DIFF@@'
+PYTHON_PATH='@@PYTHON_PATH@@'
+TAR='@@TAR@@'
+export PERL_PATH 
 
 if test -z "$GIT_TEST_CMP"
 then
-- 
1.7.9.1.3.gd6f4c.dirty

             reply	other threads:[~2012-06-23  5:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-23  5:04 Torsten Bögershausen [this message]
2012-06-23  5:22 ` [RFC] test-lib.sh: preprocess to use PERL_PATH Junio C Hamano
2012-06-23  5:26   ` Torsten Bögershausen
2012-06-23  6:18     ` Junio C Hamano
2012-06-23 13:11       ` Torsten Bögershausen

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=201206230704.38648.tboegi@web.de \
    --to=tboegi@web.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).