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 <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Apr 8, 2018 at 11:35 UTC
8796b307ea86f8fa28cc6effc2defebbba0b56b9
1 file changed
+46
-10
t/perf/run
+46
-10
@@ -1,21 +1,34 @@
1
#!/bin/sh
2
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 ;;
13
--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 ;;
16
--config)
17
shift
18
GIT_PERF_CONFIG_FILE=$(cd "$(dirname "$1")"; pwd)/$(basename "$1")
19
export GIT_PERF_CONFIG_FILE
20
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
32
33
run_one_dir () {
34
if test $# -eq 0; then
@@ -172,9 +185,32 @@ get_subsections "perf" >test-results/run_subsections.names
185
186
if test $(wc -l <test-results/run_subsections.names) -eq 0
187
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
197
(
198
run_subsection "$@"
199
)
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
214
else
215
while read -r subsec
216
do