Skip to content

Commit 1a0962d

Browse files
peffgitster
authored andcommitted
t/perf: fix regression in testing older versions of git
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7501b59 commit 1a0962d

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

t/perf/README

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,16 @@ After that you will want to use some of the following:
115115

116116
At least one of the first two is required!
117117

118-
You can use test_expect_success as usual. For actual performance
119-
tests, use
118+
You can use test_expect_success as usual. In both test_expect_success
119+
and in test_perf, running "git" points to the version that is being
120+
perf-tested. The $MODERN_GIT variable points to the git wrapper for the
121+
currently checked-out version (i.e., the one that matches the t/perf
122+
scripts you are running). This is useful if your setup uses commands
123+
that only work with newer versions of git than what you might want to
124+
test (but obviously your new commands must still create a state that can
125+
be used by the older version of git you are testing).
126+
127+
For actual performance tests, use
120128

121129
test_perf 'descriptive string' '
122130
command1 &&

t/perf/perf-lib.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ TEST_NO_MALLOC_CHECK=t
5252
# need to export them for test_perf subshells
5353
export TEST_DIRECTORY TRASH_DIRECTORY GIT_BUILD_DIR GIT_TEST_CMP
5454

55+
MODERN_GIT=$GIT_BUILD_DIR/bin-wrappers/git
56+
export MODERN_GIT
57+
5558
perf_results_dir=$TEST_OUTPUT_DIRECTORY/test-results
5659
mkdir -p "$perf_results_dir"
5760
rm -f "$perf_results_dir"/$(basename "$0" .sh).subtests
@@ -81,7 +84,7 @@ test_perf_create_repo_from () {
8184
repo="$1"
8285
source="$2"
8386
source_git="$(git -C "$source" rev-parse --git-dir)"
84-
objects_dir="$(git -C "$source" rev-parse --git-path objects)"
87+
objects_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-path objects)"
8588
mkdir -p "$repo/.git"
8689
(
8790
{ cp -Rl "$objects_dir" "$repo/.git/" 2>/dev/null ||

0 commit comments

Comments
 (0)