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