perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't do
[alt-git.git] / t / perf / run
blobb61024a830a02cace4f9d6720428f2cf562fd5c5
1 #!/bin/sh
3 case "$1" in
4 --help)
5 echo "usage: $0 [other_git_tree...] [--] [test_scripts]"
6 exit 0
7 ;;
8 esac
10 die () {
11 echo >&2 "error: $*"
12 exit 1
15 run_one_dir () {
16 if test $# -eq 0; then
17 set -- p????-*.sh
19 echo "=== Running $# tests in ${GIT_TEST_INSTALLED:-this tree} ==="
20 for t in "$@"; do
21 ./$t $GIT_TEST_OPTS
22 done
25 unpack_git_rev () {
26 rev=$1
27 mkdir -p build/$rev
28 (cd "$(git rev-parse --show-cdup)" && git archive --format=tar $rev) |
29 (cd build/$rev && tar x)
31 build_git_rev () {
32 rev=$1
33 for config in config.mak config.mak.autogen config.status
35 if test -e "../../$config"
36 then
37 cp "../../$config" "build/$rev/"
39 done
41 cd build/$rev &&
42 if test -n "$GIT_PERF_MAKE_COMMAND"
43 then
44 sh -c "$GIT_PERF_MAKE_COMMAND"
45 else
46 make $GIT_PERF_MAKE_OPTS
48 ) || die "failed to build revision '$mydir'"
51 run_dirs_helper () {
52 mydir=${1%/}
53 shift
54 while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
55 shift
56 done
57 if test $# -gt 0 -a "$1" = --; then
58 shift
60 if [ ! -d "$mydir" ]; then
61 rev=$(git rev-parse --verify "$mydir" 2>/dev/null) ||
62 die "'$mydir' is neither a directory nor a valid revision"
63 if [ ! -d build/$rev ]; then
64 unpack_git_rev $rev
66 build_git_rev $rev
67 mydir=build/$rev
69 if test "$mydir" = .; then
70 unset GIT_TEST_INSTALLED
71 else
72 GIT_TEST_INSTALLED="$mydir/bin-wrappers"
73 # Older versions of git lacked bin-wrappers; fallback to the
74 # files in the root.
75 test -d "$GIT_TEST_INSTALLED" || GIT_TEST_INSTALLED=$mydir
76 export GIT_TEST_INSTALLED
78 run_one_dir "$@"
81 run_dirs () {
82 while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
83 run_dirs_helper "$@"
84 shift
85 done
88 GIT_PERF_AGGREGATING_LATER=t
89 export GIT_PERF_AGGREGATING_LATER
91 cd "$(dirname $0)"
92 . ../../GIT-BUILD-OPTIONS
94 if test $# = 0 -o "$1" = -- -o -f "$1"; then
95 set -- . "$@"
97 run_dirs "$@"
98 ./aggregate.perl "$@"