diff options
author | Thomas Rast <trast@inf.ethz.ch> | 2013-06-23 20:12:57 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-06-23 12:24:06 -0700 |
commit | 5dfc368f5ec4c448cf3c76908b4c0e77cb4b902a (patch) | |
tree | d00694edc2d230ecd0a1a980a6cab196d49b83fa /t/test-lib.sh | |
parent | ff09af3fb8f5bede0de523723bbd00d6ef2ab71e (diff) | |
download | git-5dfc368f5ec4c448cf3c76908b4c0e77cb4b902a.tar.gz |
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: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index 95df832ed9..e9f3294bc8 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -201,6 +201,9 @@ do --valgrind=*) valgrind=$(expr "z$1" : 'z[^=]*=\(.*\)') shift ;; + --valgrind-only=*) + valgrind_only=$(expr "z$1" : 'z[^=]*=\(.*\)') + shift ;; --tee) shift ;; # was handled already --root=*) @@ -211,7 +214,14 @@ do esac 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" then @@ -371,6 +381,25 @@ maybe_setup_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_ () { # This is a separate function because some tests use # "return" to end a test_expect_success block early. @@ -401,10 +430,12 @@ test_run_ () { test_start_ () { test_count=$(($test_count+1)) maybe_setup_verbose + maybe_setup_valgrind } test_finish_ () { echo >&3 "" + maybe_teardown_valgrind maybe_teardown_verbose } @@ -590,6 +621,9 @@ then export GIT_VALGRIND GIT_VALGRIND_MODE="$valgrind" 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" then GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) || |