Merge branch 'jb/t8008-cleanup' into maint
[git.git] / t / perf / run
blobbeb4acc0e428d20280a649c428da8b0b3aa5b4c6
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 echo "=== Unpacking $rev in build/$rev ==="
28 mkdir -p build/$rev
29 (cd "$(git rev-parse --show-cdup)" && git archive --format=tar $rev) |
30 (cd build/$rev && tar x)
32 build_git_rev () {
33 rev=$1
34 for config in config.mak config.mak.autogen config.status
36 if test -e "../../$config"
37 then
38 cp "../../$config" "build/$rev/"
40 done
41 echo "=== Building $rev ==="
43 cd build/$rev &&
44 if test -n "$GIT_PERF_MAKE_COMMAND"
45 then
46 sh -c "$GIT_PERF_MAKE_COMMAND"
47 else
48 make $GIT_PERF_MAKE_OPTS
50 ) || die "failed to build revision '$mydir'"
53 run_dirs_helper () {
54 mydir=${1%/}
55 shift
56 while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
57 shift
58 done
59 if test $# -gt 0 -a "$1" = --; then
60 shift
62 if [ ! -d "$mydir" ]; then
63 rev=$(git rev-parse --verify "$mydir" 2>/dev/null) ||
64 die "'$mydir' is neither a directory nor a valid revision"
65 if [ ! -d build/$rev ]; then
66 unpack_git_rev $rev
68 build_git_rev $rev
69 mydir=build/$rev
71 if test "$mydir" = .; then
72 unset GIT_TEST_INSTALLED
73 else
74 GIT_TEST_INSTALLED="$mydir/bin-wrappers"
75 # Older versions of git lacked bin-wrappers; fallback to the
76 # files in the root.
77 test -d "$GIT_TEST_INSTALLED" || GIT_TEST_INSTALLED=$mydir
78 export GIT_TEST_INSTALLED
80 run_one_dir "$@"
83 run_dirs () {
84 while test $# -gt 0 -a "$1" != -- -a ! -f "$1"; do
85 run_dirs_helper "$@"
86 shift
87 done
90 GIT_PERF_AGGREGATING_LATER=t
91 export GIT_PERF_AGGREGATING_LATER
93 cd "$(dirname $0)"
94 . ../../GIT-BUILD-OPTIONS
96 if test $# = 0 -o "$1" = -- -o -f "$1"; then
97 set -- . "$@"
99 run_dirs "$@"
100 ./aggregate.perl "$@"