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

[PATCH 1/2] t/perf: fix regression in testing older versions of git

From
Jeff King <peff@peff.net>
Date
Jun 22, 2016, 19:40 UTC
Message-ID
<20160622194013.GA1697@sigill.intra.peff.net>
In-Reply-To
<20160622193904.GA1509@sigill.intra.peff.net>

Commit 7501b59 (perf: make the tests work in worktrees, 2016-05-13) introduced the use of "git rev-parse --git-path" in the perf-lib setup code. Because the to-be-tested version of git is at the front of the $PATH when this code runs, this means we cannot use modern versions of t/perf to test versions of git older than v2.5.0 (when that option was introduced).

This is a symptom of a more general problem. The t/perf suite is essentially independent of git versions, and ideally we would be able to run the most modern and complete set of tests across many historical versions (to see how they compare). But any setup code they run is therefore required to use the lowest common denominator we expect to test.

So let's introduce a new variable, $MODERN_GIT, that we can use both in perf-lib and in the test setup to get a reliable set of git features (we might change git and break some tests, of course, but $MODERN_GIT is tied to the same version of git as the t/perf scripts, so they can be fixed or adjusted together).

This commit fixes the "--git-path" case, but does not mass-convert existing setup code to use $MODERN_GIT. Most setup code is fairly vanilla and will work with effectively all versions. But now the tool is there to fix any other issues we find going forward.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/perf/README      | 12 ++++++++++--
 t/perf/perf-lib.sh |  5 ++++-
 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/t/perf/README b/t/perf/README
index 8848c14..15986ca 100644
--- a/t/perf/README
+++ b/t/perf/README
@@ -115,8 +115,16 @@ After that you will want to use some of the following:
 
 At least one of the first two is required!
 
-You can use test_expect_success as usual.  For actual performance
-tests, use
+You can use test_expect_success as usual. In both test_expect_success
+and in test_perf, running "git" points to the version that is being
+peft-tested. The $MODERN_GIT variable points to the git wrapper for the
+currently checked-out version (i.e., the one that matches the t/perf
+scripts you are running).  This is useful if your setup uses commands
+that only work with newer versions of git than what you might want to
+test (but obviously your new commands must still create a state that can
+be used by the older version of git you are testing).
+
+For actual performance tests, use
 
 	test_perf 'descriptive string' '
 		command1 &&
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh
index 18c363e..4eb2536 100644
--- a/t/perf/perf-lib.sh
+++ b/t/perf/perf-lib.sh
@@ -52,6 +52,9 @@ TEST_NO_MALLOC_CHECK=t
 # need to export them for test_perf subshells
 export TEST_DIRECTORY TRASH_DIRECTORY GIT_BUILD_DIR GIT_TEST_CMP
 
+MODERN_GIT=$GIT_BUILD_DIR/bin-wrappers/git
+export MODERN_GIT
+
 perf_results_dir=$TEST_OUTPUT_DIRECTORY/test-results
 mkdir -p "$perf_results_dir"
 rm -f "$perf_results_dir"/$(basename "$0" .sh).subtests
@@ -81,7 +84,7 @@ test_perf_create_repo_from () {
 	repo="$1"
 	source="$2"
 	source_git="$(git -C "$source" rev-parse --git-dir)"
-	objects_dir="$(git -C "$source" rev-parse --git-path objects)"
+	objects_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-path objects)"
 	mkdir -p "$repo/.git"
 	(
 		cd "$source" &&
-- 
2.9.0.204.g1499a7b
Previous: Jeff KingNext: Johannes Schindelin
Message 2 of 8 in “t/perf tests against older versions”
  1. 0/2 t/perf tests against older versionsJeff King, Jun 22, 2016
  2. 1/2 t/perf: fix regression in testing older versions of gitJeff King, Jun 22, 2016
  3. Johannes SchindelinJun 22, 2016
  4. Johannes SchindelinJun 22, 2016
  5. Junio C HamanoJun 22, 2016
  6. Jeff KingJun 22, 2016
  7. Junio C HamanoJun 22, 2016
  8. 2/2 p4211: explicitly disable renames in no-rename testJeff King, Jun 22, 2016

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.