[PATCH 1/2] Allow Overriding GIT_BUILD_DIR

Subsystems: the rest

DORMANTno replies

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH 1/2] Allow Overriding GIT_BUILD_DIR

From: <hidden>
Date: 2016-06-15 22:53:13

From: "David A. Greene" <redacted>

Let tests override GIT_BUILD_DIR so git will work if tests are not at
the same directory level as standard git tests.  Prior to this change,
GIT_BUILD_DIR is hardwired to be exactly one directory above where the
test lives.  A test within contrib/, for example, can now use
test-lib.sh and set an appropriate value for GIT_BUILD_DIR.

Signed-off-by: David A. Greene <redacted>
---
 t/test-lib.sh |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index a65dfc7..cb3a0a2 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -55,6 +55,7 @@ unset $(perl -e '
 		.*_TEST
 		PROVE
 		VALGRIND
+                BUILD_DIR
 	));
 	my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
 	print join("\n", @vars);
@@ -901,7 +902,20 @@ then
 	# itself.
 	TEST_DIRECTORY=$(pwd)
 fi
-GIT_BUILD_DIR="$TEST_DIRECTORY"/..
+
+if test -z "$GIT_BUILD_DIR"
+then
+	# We allow tests to override this, in case they want to run tests
+	# outside of t/.
+ 
+        # For in-tree test scripts, this is one level above the
+        # TEST_DIRECTORY (t/), but a test script that lives outside t/
+        # can set this variable to point at the right place so that it
+        # can find t/ directory that house test helpers like
+        # lib-pager*.sh and test vectors like t4013/ as well as
+        # previously built git tools.
+       GIT_BUILD_DIR="$TEST_DIRECTORY"/..
+fi
 
 if test -n "$valgrind"
 then
-- 
1.7.9.1

[PATCH 2/2] Support Out-Of-Tree Valgrind Tests

From: <hidden>
Date: 2016-06-15 22:53:13

From: "David A. Greene" <redacted>

Allow tests that do not live in the top-level t/ directory to run
under valgrind.  This requires exporting a couple more variables to
indicate where the git tools were built and where the valgrind support
files live.

Prior to this chage the valgrind support files were hard-coded to be
in a sibling directory to where the valgrind tests are run.

Also prior to this change the base git build was hard-coded to be
exactly two directories up from where the valgrind tests are run.

Signed-off-by: David A. Greene <redacted>
---
 t/test-lib.sh          |   22 ++++++++++++++++++++--
 t/valgrind/valgrind.sh |    4 ++--
 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index cb3a0a2..0ebb3a8 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -56,6 +56,7 @@ unset $(perl -e '
 		PROVE
 		VALGRIND
                 BUILD_DIR
+                VALGRIND_TOOLS
 	));
 	my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
 	print join("\n", @vars);
@@ -917,6 +918,20 @@ then
        GIT_BUILD_DIR="$TEST_DIRECTORY"/..
 fi
 
+# GIT_VALGRIND_TOOLS is the location of tools like valgrind.sh.
+if test -z "$GIT_VALGRIND_TOOLS"
+then
+	# We allow tests to override this, in case they want to run tests
+	# outside of t/.
+ 
+        # For in-tree test scripts, this is in TEST_DIRECTORY/valgrind
+        # (t/valgrind), but a test script that lives outside t/ can
+        # set this variable to point at the right place so that it can
+        # find t/valgrind directory that house test helpers like
+        # valgrind.sh.
+       GIT_VALGRIND_TOOLS="$TEST_DIRECTORY"/valgrind
+fi
+
 if test -n "$valgrind"
 then
 	make_symlink () {
@@ -954,11 +969,11 @@ then
 		    test ! -d "$symlink_target" &&
 		    test "#!" != "$(head -c 2 < "$symlink_target")"
 		then
-			symlink_target=../valgrind.sh
+			symlink_target=${GIT_VALGRIND_TOOLS}/valgrind.sh
 		fi
 		case "$base" in
 		*.sh|*.perl)
-			symlink_target=../unprocessed-script
+			symlink_target=${GIT_VALGRIND_TOOLS}/unprocessed-script
 		esac
 		# create the link, or replace it if it is out of date
 		make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit
@@ -986,7 +1001,10 @@ then
 	IFS=$OLDIFS
 	PATH=$GIT_VALGRIND/bin:$PATH
 	GIT_EXEC_PATH=$GIT_VALGRIND/bin
+	# Make these available in valgrind.sh
+	export GIT_BUILD_DIR
 	export GIT_VALGRIND
+	export GIT_VALGRIND_TOOLS
 elif test -n "$GIT_TEST_INSTALLED" ; then
 	GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||
 	error "Cannot run git from $GIT_TEST_INSTALLED."
diff --git a/t/valgrind/valgrind.sh b/t/valgrind/valgrind.sh
index 582b4dc..d638d10 100755
--- a/t/valgrind/valgrind.sh
+++ b/t/valgrind/valgrind.sh
@@ -13,10 +13,10 @@ TRACK_ORIGINS=--track-origins=yes
 
 exec valgrind -q --error-exitcode=126 \
 	--leak-check=no \
-	--suppressions="$GIT_VALGRIND/default.supp" \
+	--suppressions="$GIT_VALGRIND_TOOLS/default.supp" \
 	--gen-suppressions=all \
 	$TRACK_ORIGINS \
 	--log-fd=4 \
 	--input-fd=4 \
 	$GIT_VALGRIND_OPTIONS \
-	"$GIT_VALGRIND"/../../"$base" "$@"
+	"$GIT_BUILD_DIR"/"$base" "$@"
-- 
1.7.9.1

Re: [PATCH 1/2] Allow Overriding GIT_BUILD_DIR

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:13

Both of your changes seem to have broken indentation to use 8-SP at
the beginning of some (but not all) lines instead 1-HT.  I'll queue
a fixed up version and push the result out in 'pu' later, so please
double check to make sure I didn't screw up.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help