diff options
author | Jens Lehmann <Jens.Lehmann@web.de> | 2012-01-17 22:04:31 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-01-17 15:15:35 -0800 |
commit | c4d2539af751ed394ee68c02fe688e75c647c5fe (patch) | |
tree | cb9658bddd4e0ff8d5c47ae4bfef7dd94255bf1e /t/test-lib.sh | |
parent | 52b9d2cf7fbde061bf0d3336e3a89d7333d5b23d (diff) | |
download | git-c4d2539af751ed394ee68c02fe688e75c647c5fe.tar.gz |
test-lib: add the test_pause convenience functionjl/test-pause
Since 781f76b15 (test-lib: redirect stdin of tests) you can't simply put a
"bash &&" into a test for debugging purposes anymore. Instead you'll have
to use "bash <&6 >&3 2>&4".
As that invocation is not that easy to remember add the test_pause
convenience function. It invokes "$SHELL_PATH" to provide a sane shell
for the user.
This function also checks if the -v flag is given and will error out if
that is not the case instead of letting the test hang until ^D is pressed.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index a65dfc7ea9..709a30067e 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -329,6 +329,19 @@ test_tick () { export GIT_COMMITTER_DATE GIT_AUTHOR_DATE } +# Stop execution and start a shell. This is useful for debugging tests and +# only makes sense together with "-v". +# +# Be sure to remove all invocations of this command before submitting. + +test_pause () { + if test "$verbose" = t; then + "$SHELL_PATH" <&6 >&3 2>&4 + else + error >&5 "test_pause requires --verbose" + fi +} + # Call test_commit with the arguments "<message> [<file> [<contents>]]" # # This will commit a file with the given contents and the given commit |