git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 2/4] test-lib: allow testing another git build tree

From
Thomas Rast <trast@student.ethz.ch>
Date
Dec 14, 2011, 15:23 UTC
Message-ID
<94f64a03398829bb9a11c18577efb39d9b153eca.1323876121.git.trast@student.ethz.ch>
In-Reply-To
<cover.1323876121.git.trast@student.ethz.ch>

The perf-lib work wants this feature, so we may as well do it for test-lib in general. You can now say

  GIT_BUILD_DIR=/another/git/tree
  make test  # or any other test

and it will run the tests of the current tree against the binaries of the other tree.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 Makefile      |    7 ++++++-
 t/test-lib.sh |   19 ++++++++++++++++---
 2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 2127c1b..52506bf 100644
--- a/Makefile
+++ b/Makefile
@@ -2215,6 +2215,12 @@ GIT-BUILD-OPTIONS: FORCE
 	@echo USE_LIBPCRE=\''$(subst ','\'',$(subst ','\'',$(USE_LIBPCRE)))'\' >>$@
 	@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
 	@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
+	@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@
+
+GIT-TEST-OPTIONS: FORCE
+ifdef GIT_TEST_OPTS
+	@echo GIT_TEST_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_OPTS)))'\' >$@
+endif
 ifdef GIT_TEST_CMP
 	@echo GIT_TEST_CMP=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_CMP)))'\' >>$@
 endif
@@ -2222,7 +2228,6 @@ ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
 	@echo GIT_TEST_CMP_USE_COPIED_CONTEXT=YesPlease >>$@
 endif
 	@echo GETTEXT_POISON=\''$(subst ','\'',$(subst ','\'',$(GETTEXT_POISON)))'\' >>$@
-	@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@
 
 ### Detect Tck/Tk interpreter path changes
 ifndef NO_TCLTK
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 368e48c..06f8c96 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -54,6 +54,7 @@ unset $(perl -e '
 		.*_TEST
 		PROVE
 		VALGRIND
+		BUILD_DIR
 	));
 	my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
 	print join("\n", @vars);
@@ -318,7 +319,7 @@ test_done () {
 	GIT_EXIT_OK=t
 
 	if test -z "$HARNESS_ACTIVE"; then
-		test_results_dir="$TEST_DIRECTORY/test-results"
+		test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results"
 		mkdir -p "$test_results_dir"
 		test_results_path="$test_results_dir/${0%.sh}-$$.counts"
 
@@ -379,7 +380,18 @@ then
 	# itself.
 	TEST_DIRECTORY=$(pwd)
 fi
-GIT_BUILD_DIR="$TEST_DIRECTORY"/..
+if test -z "$TEST_OUTPUT_DIRECTORY"
+then
+	# Similarly, override this to store the test-results subdir
+	# elsewhere
+	TEST_OUTPUT_DIRECTORY=$TEST_DIRECTORY
+fi
+if test -z "$GIT_BUILD_DIR"
+then
+	# Similarly, override this to test a different git build tree
+	# than the one you are running the tests from
+	GIT_BUILD_DIR="$TEST_DIRECTORY"/..
+fi
 
 if test -n "$valgrind"
 then
@@ -477,6 +489,7 @@ GIT_ATTR_NOSYSTEM=1
 export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
 
 . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
+. "$TEST_DIRECTORY"/../GIT-TEST-OPTIONS
 
 if test -z "$GIT_TEST_CMP"
 then
@@ -514,7 +527,7 @@ test="trash directory.$(basename "$0" .sh)"
 test -n "$root" && test="$root/$test"
 case "$test" in
 /*) TRASH_DIRECTORY="$test" ;;
- *) TRASH_DIRECTORY="$TEST_DIRECTORY/$test" ;;
+ *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$test" ;;
 esac
 test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
 rm -fr "$test" || {
-- 
1.7.8.304.ge42e4
Previous: Thomas RastNext: Junio C Hamano
Message 3 of 9 in “Performance test framework”
  1. 0/4 Performance test frameworkThomas Rast, Dec 14, 2011
  2. 1/4 Move the user-facing test library to test-lib-functions.shThomas Rast, Dec 14, 2011
  3. 2/4 test-lib: allow testing another git build treeThomas Rast, Dec 14, 2011
  4. Junio C HamanoDec 15, 2011
  5. Thomas RastDec 15, 2011
  6. Junio C HamanoDec 15, 2011
  7. 3/4 Introduce a performance testing frameworkThomas Rast, Dec 14, 2011
  8. Thomas RastDec 14, 2011
  9. 4/4 Add a performance test for git-grepThomas Rast, Dec 14, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.