Skip to content

Commit 8796b30

Browse files
chriscoolgitster
authored andcommitted
perf/run: add --subsection option
This new option makes it possible to run perf tests as defined in only one subsection of a config file. Signed-off-by: Christian Couder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e3efd0 commit 8796b30

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

t/perf/run

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
#!/bin/sh
22

3-
case "$1" in
3+
die () {
4+
echo >&2 "error: $*"
5+
exit 1
6+
}
7+
8+
while [ $# -gt 0 ]; do
9+
arg="$1"
10+
case "$arg" in
11+
--)
12+
break ;;
413
--help)
5-
echo "usage: $0 [--config file] [other_git_tree...] [--] [test_scripts]"
6-
exit 0
7-
;;
14+
echo "usage: $0 [--config file] [--subsection subsec] [other_git_tree...] [--] [test_scripts]"
15+
exit 0 ;;
816
--config)
917
shift
1018
GIT_PERF_CONFIG_FILE=$(cd "$(dirname "$1")"; pwd)/$(basename "$1")
1119
export GIT_PERF_CONFIG_FILE
1220
shift ;;
13-
esac
14-
15-
die () {
16-
echo >&2 "error: $*"
17-
exit 1
18-
}
21+
--subsection)
22+
shift
23+
GIT_PERF_SUBSECTION="$1"
24+
export GIT_PERF_SUBSECTION
25+
shift ;;
26+
--*)
27+
die "unrecognised option: '$arg'" ;;
28+
*)
29+
break ;;
30+
esac
31+
done
1932

2033
run_one_dir () {
2134
if test $# -eq 0; then
@@ -172,9 +185,32 @@ get_subsections "perf" >test-results/run_subsections.names
172185

173186
if test $(wc -l <test-results/run_subsections.names) -eq 0
174187
then
188+
if test -n "$GIT_PERF_SUBSECTION"
189+
then
190+
if test -n "$GIT_PERF_CONFIG_FILE"
191+
then
192+
die "no subsections are defined in config file '$GIT_PERF_CONFIG_FILE'"
193+
else
194+
die "subsection '$GIT_PERF_SUBSECTION' defined without a config file"
195+
fi
196+
fi
175197
(
176198
run_subsection "$@"
177199
)
200+
elif test -n "$GIT_PERF_SUBSECTION"
201+
then
202+
egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names >/dev/null ||
203+
die "subsection '$GIT_PERF_SUBSECTION' not found in '$GIT_PERF_CONFIG_FILE'"
204+
205+
egrep "^$GIT_PERF_SUBSECTION\$" test-results/run_subsections.names | while read -r subsec
206+
do
207+
(
208+
GIT_PERF_SUBSECTION="$subsec"
209+
export GIT_PERF_SUBSECTION
210+
echo "======== Run for subsection '$GIT_PERF_SUBSECTION' ========"
211+
run_subsection "$@"
212+
)
213+
done
178214
else
179215
while read -r subsec
180216
do

0 commit comments

Comments
 (0)