test: facilitate debugging Git executables in tests with gdb
When prefixing a Git call in the test suite with 'debug ', it will now be run with GDB, allowing the developer to debug test failures more conveniently. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
80980a1d5c
commit
6a94088cc3
5
t/README
5
t/README
@ -563,6 +563,11 @@ library for your script to use.
|
|||||||
argument. This is primarily meant for use during the
|
argument. This is primarily meant for use during the
|
||||||
development of a new test script.
|
development of a new test script.
|
||||||
|
|
||||||
|
- debug <git-command>
|
||||||
|
|
||||||
|
Run a git command inside a debugger. This is primarily meant for
|
||||||
|
use when debugging a failing test script.
|
||||||
|
|
||||||
- test_done
|
- test_done
|
||||||
|
|
||||||
Your test script must have test_done at the end. Its purpose
|
Your test script must have test_done at the end. Its purpose
|
||||||
|
@ -145,6 +145,14 @@ test_pause () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Wrap git in gdb. Adding this to a command can make it easier to
|
||||||
|
# understand what is going on in a failing test.
|
||||||
|
#
|
||||||
|
# Example: "debug git checkout master".
|
||||||
|
debug () {
|
||||||
|
GIT_TEST_GDB=1 "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# Call test_commit with the arguments "<message> [<file> [<contents> [<tag>]]]"
|
# Call test_commit with the arguments "<message> [<file> [<contents> [<tag>]]]"
|
||||||
#
|
#
|
||||||
# This will commit a file with the given contents and the given commit
|
# This will commit a file with the given contents and the given commit
|
||||||
|
@ -19,4 +19,10 @@ GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
|
|||||||
PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
|
PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
|
||||||
export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
|
export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
|
||||||
|
|
||||||
|
if test -n "$GIT_TEST_GDB"
|
||||||
|
then
|
||||||
|
unset GIT_TEST_GDB
|
||||||
|
exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
|
||||||
|
else
|
||||||
exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
|
exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
|
||||||
|
fi
|
||||||
|
Reference in New Issue
Block a user