提交 5dfc368f 编写于 作者: T Thomas Rast 提交者: Junio C Hamano

test-lib: valgrind for only tests matching a pattern

With the new --valgrind-only=<pattern> option, one can enable
--valgrind at a per-test granularity, exactly analogous to
--verbose-only from the previous commit.

The options are wired such that --valgrind implies --verbose (as
before), but --valgrind-only=<pattern> implies
--verbose-only=<pattern> unless --verbose is also in effect.
Signed-off-by: NThomas Rast <trast@inf.ethz.ch>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 ff09af3f
...@@ -126,6 +126,11 @@ appropriately before running "make". ...@@ -126,6 +126,11 @@ appropriately before running "make".
the 't/valgrind/' directory and use the commands under the 't/valgrind/' directory and use the commands under
't/valgrind/bin/'. 't/valgrind/bin/'.
--valgrind-only=<pattern>::
Like --valgrind, but the effect is limited to tests with
numbers matching <pattern>. The number matched against is
simply the running count of the test within the file.
--tee:: --tee::
In addition to printing the test output to the terminal, In addition to printing the test output to the terminal,
write it to files named 't/test-results/$TEST_NAME.out'. write it to files named 't/test-results/$TEST_NAME.out'.
......
...@@ -201,6 +201,9 @@ do ...@@ -201,6 +201,9 @@ do
--valgrind=*) --valgrind=*)
valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)') valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)')
shift ;; shift ;;
--valgrind-only=*)
valgrind_only=$(expr "z$1" : 'z[^=]*=\(.*\)')
shift ;;
--tee) --tee)
shift ;; # was handled already shift ;; # was handled already
--root=*) --root=*)
...@@ -211,7 +214,14 @@ do ...@@ -211,7 +214,14 @@ do
esac esac
done done
test -n "$valgrind" && verbose=t if test -n "$valgrind_only"
then
test -z "$valgrind" && valgrind=memcheck
test -z "$verbose" && verbose_only="$valgrind_only"
elif test -n "$valgrind"
then
verbose=t
fi
if test -n "$color" if test -n "$color"
then then
...@@ -371,6 +381,25 @@ maybe_setup_verbose () { ...@@ -371,6 +381,25 @@ maybe_setup_verbose () {
last_verbose=$verbose last_verbose=$verbose
} }
maybe_teardown_valgrind () {
test -z "$GIT_VALGRIND" && return
GIT_VALGRIND_ENABLED=
}
maybe_setup_valgrind () {
test -z "$GIT_VALGRIND" && return
if test -z "$valgrind_only"
then
GIT_VALGRIND_ENABLED=t
return
fi
GIT_VALGRIND_ENABLED=
if match_pattern_list $test_count $valgrind_only
then
GIT_VALGRIND_ENABLED=t
fi
}
test_eval_ () { test_eval_ () {
# This is a separate function because some tests use # This is a separate function because some tests use
# "return" to end a test_expect_success block early. # "return" to end a test_expect_success block early.
...@@ -401,10 +430,12 @@ test_run_ () { ...@@ -401,10 +430,12 @@ test_run_ () {
test_start_ () { test_start_ () {
test_count=$(($test_count+1)) test_count=$(($test_count+1))
maybe_setup_verbose maybe_setup_verbose
maybe_setup_valgrind
} }
test_finish_ () { test_finish_ () {
echo >&3 "" echo >&3 ""
maybe_teardown_valgrind
maybe_teardown_verbose maybe_teardown_verbose
} }
...@@ -590,6 +621,9 @@ then ...@@ -590,6 +621,9 @@ then
export GIT_VALGRIND export GIT_VALGRIND
GIT_VALGRIND_MODE="$valgrind" GIT_VALGRIND_MODE="$valgrind"
export GIT_VALGRIND_MODE export GIT_VALGRIND_MODE
GIT_VALGRIND_ENABLED=t
test -n "$valgrind_only" && GIT_VALGRIND_ENABLED=
export GIT_VALGRIND_ENABLED
elif test -n "$GIT_TEST_INSTALLED" elif test -n "$GIT_TEST_INSTALLED"
then then
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) || GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
......
...@@ -4,6 +4,9 @@ base=$(basename "$0") ...@@ -4,6 +4,9 @@ base=$(basename "$0")
TOOL_OPTIONS='--leak-check=no' TOOL_OPTIONS='--leak-check=no'
test -z "$GIT_VALGRIND_ENABLED" &&
exec "$GIT_VALGRIND"/../../"$base" "$@"
case "$GIT_VALGRIND_MODE" in case "$GIT_VALGRIND_MODE" in
memcheck-fast) memcheck-fast)
;; ;;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册