提交 c4d2539a 编写于 作者: J Jens Lehmann 提交者: Junio C Hamano

test-lib: add the test_pause convenience function

Since 781f76b1 (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: NJens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 52b9d2cf
......@@ -548,6 +548,19 @@ library for your script to use.
...
'
- test_pause
This command is useful for writing and debugging tests and must be
removed before submitting. It halts the execution of the test and
spawns a shell in the trash directory. Exit the shell to continue
the test. Example:
test_expect_success 'test' '
git do-something >actual &&
test_pause &&
test_cmp expected actual
'
Prerequisites
-------------
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册