Merge branch 'js/difftool-no-index'
[gitweb.git] / t / perf / run
index 213da5d6b9437b7db7f3e5b824afea1df465d934..c7b86104e12a6637b1084d6e02743f6c36df9265 100755 (executable)
@@ -1,21 +1,34 @@
 #!/bin/sh
 
-case "$1" in
+die () {
+       echo >&2 "error: $*"
+       exit 1
+}
+
+while [ $# -gt 0 ]; do
+       arg="$1"
+       case "$arg" in
+       --)
+               break ;;
        --help)
-               echo "usage: $0 [--config file] [other_git_tree...] [--] [test_scripts]"
-               exit 0
-               ;;
+               echo "usage: $0 [--config file] [--subsection subsec] [other_git_tree...] [--] [test_scripts]"
+               exit 0 ;;
        --config)
                shift
                GIT_PERF_CONFIG_FILE=$(cd "$(dirname "$1")"; pwd)/$(basename "$1")
                export GIT_PERF_CONFIG_FILE
                shift ;;
-esac
-
-die () {
-       echo >&2 "error: $*"
-       exit 1
-}
+       --subsection)
+               shift
+               GIT_PERF_SUBSECTION="$1"
+               export GIT_PERF_SUBSECTION
+               shift ;;
+       --*)
+               die "unrecognised option: '$arg'" ;;
+       *)
+               break ;;
+       esac
+done
 
 run_one_dir () {
        if test $# -eq 0; then
@@ -57,6 +70,24 @@ build_git_rev () {
        ) || die "failed to build revision '$mydir'"
 }
 
+set_git_test_installed () {
+       mydir=$1
+
+       mydir_abs=$(cd $mydir && pwd)
+       mydir_abs_wrappers="$mydir_abs_wrappers/bin-wrappers"
+       if test -d "$mydir_abs_wrappers"
+       then
+               GIT_TEST_INSTALLED=$mydir_abs_wrappers
+       else
+               # Older versions of git lacked bin-wrappers;
+               # fallback to the files in the root.
+               GIT_TEST_INSTALLED=$mydir_abs
+       fi
+       export GIT_TEST_INSTALLED
+       PERF_SET_GIT_TEST_INSTALLED=true
+       export PERF_SET_GIT_TEST_INSTALLED
+}
+
 run_dirs_helper () {
        mydir=${1%/}
        shift
@@ -66,7 +97,16 @@ run_dirs_helper () {
        if test $# -gt 0 -a "$1" = --; then
                shift
        fi
-       if [ ! -d "$mydir" ]; then
+
+       PERF_RESULTS_PREFIX=
+       if test "$mydir" = "."
+       then
+               unset GIT_TEST_INSTALLED
+       elif test -d "$mydir"
+       then
+               PERF_RESULTS_PREFIX=bindir$(cd $mydir && printf "%s" "$(pwd)" | tr -c "[a-zA-Z0-9]" "_").
+               set_git_test_installed "$mydir"
+       else
                rev=$(git rev-parse --verify "$mydir" 2>/dev/null) ||
                die "'$mydir' is neither a directory nor a valid revision"
                if [ ! -d build/$rev ]; then
@@ -74,16 +114,12 @@ run_dirs_helper () {
                fi
                build_git_rev $rev "$mydir"
                mydir=build/$rev
+
+               PERF_RESULTS_PREFIX=build_$rev.
+               set_git_test_installed "$mydir"
        fi
-       if test "$mydir" = .; then
-               unset GIT_TEST_INSTALLED
-       else
-               GIT_TEST_INSTALLED="$mydir/bin-wrappers"
-               # Older versions of git lacked bin-wrappers; fallback to the
-               # files in the root.
-               test -d "$GIT_TEST_INSTALLED" || GIT_TEST_INSTALLED=$mydir
-               export GIT_TEST_INSTALLED
-       fi
+       export PERF_RESULTS_PREFIX
+
        run_one_dir "$@"
 }
 
@@ -172,9 +208,32 @@ get_subsections "perf" >test-results/run_subsections.names
 
 if test $(wc -l <test-results/run_subsections.names) -eq 0
 then
+       if test -n "$GIT_PERF_SUBSECTION"
+       then
+               if test -n "$GIT_PERF_CONFIG_FILE"
+               then
+                       die "no subsections are defined in config file '$GIT_PERF_CONFIG_FILE'"
+               else
+                       die "subsection '$GIT_PERF_SUBSECTION' defined without a config file"
+               fi
+       fi
        (
                run_subsection "$@"
        )
+elif test -n "$GIT_PERF_SUBSECTION"
+then
+       egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names >/dev/null ||
+               die "subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'"
+
+       egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names | while read -r subsec
+       do
+               (
+                       GIT_PERF_SUBSECTION="$subsec"
+                       export GIT_PERF_SUBSECTION
+                       echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========"
+                       run_subsection "$@"
+               )
+       done
 else
        while read -r subsec
        do