Skip to content

Commit 5756ccd

Browse files
pks-tgitster
authored andcommitted
t/perf: fix benchmarks with out-of-tree builds
The "perf-lib.sh" script is sourced by all of our benchmarking suites to make available common infrastructure. The script assumes that build and source directory are the same, which works for our Makefile. But the assumption breaks with both CMake and Meson, where the build directory can be located in an arbitrary place. Adapt the script so that it works with out-of-tree builds. Most importantly, this requires us to figure out the location of the build directory: - When running benchmarks via our Makefile the build directory is the same as the source directory. We already know to derive the test directory ("t/") via `$(pwd)/..`, which works because we chdir into "t/perf" before executing benchmarks. We can thus derive the build directory by appending another "/.." to that path. - When running benchmarks via Meson the build directory is located at an arbitrary location. The build system thus has to make the path known by exporting the `GIT_BUILD_DIR` environment variable. This change prepares us for wiring up benchmarks in Meson. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d84b990 commit 5756ccd

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

t/perf/perf-lib.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,29 @@ TEST_OUTPUT_DIRECTORY=$(pwd)
2525
TEST_NO_CREATE_REPO=t
2626
TEST_NO_MALLOC_CHECK=t
2727

28-
. ../test-lib.sh
28+
# While test-lib.sh computes the build directory for us, we also have to do the
29+
# same thing in order to locate the script via GIT-BUILD-OPTIONS in the first
30+
# place.
31+
GIT_BUILD_DIR="${GIT_BUILD_DIR:-$TEST_DIRECTORY/..}"
32+
if test -f "$GIT_BUILD_DIR/GIT-BUILD-DIR"
33+
then
34+
GIT_BUILD_DIR="$(cat "$GIT_BUILD_DIR/GIT-BUILD-DIR")" || exit 1
35+
# On Windows, we must convert Windows paths lest they contain a colon
36+
case "$(uname -s)" in
37+
*MINGW*)
38+
GIT_BUILD_DIR="$(cygpath -au "$GIT_BUILD_DIR")"
39+
;;
40+
esac
41+
fi
42+
43+
if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
44+
then
45+
echo >&2 'error: GIT-BUILD-OPTIONS missing (has Git been built?).'
46+
exit 1
47+
fi
48+
49+
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
50+
. "$GIT_SOURCE_DIR"/t/test-lib.sh
2951

3052
unset GIT_CONFIG_NOSYSTEM
3153
GIT_CONFIG_SYSTEM="$TEST_DIRECTORY/perf/config"
@@ -324,7 +346,7 @@ test_at_end_hook_ () {
324346
if test -z "$GIT_PERF_AGGREGATING_LATER"; then
325347
(
326348
cd "$TEST_DIRECTORY"/perf &&
327-
"$PERL_PATH" ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0")
349+
"$PERL_PATH" "$GIT_SOURCE_DIR"/t/perf/aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0")
328350
)
329351
fi
330352
}

0 commit comments

Comments
 (0)