summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2018-04-24 23:46:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-25 01:47:22 (GMT)
commit842436466aa5d9f1e5f1a09d41d22d902006219c (patch)
tree56dad3da9119021dc8f6b0df47abceba92782907 /t/test-lib-functions.sh
parentfe0a9eaf31dd0c349ae4308498c33a5c3794b293 (diff)
downloadgit-842436466aa5d9f1e5f1a09d41d22d902006219c.zip
git-842436466aa5d9f1e5f1a09d41d22d902006219c.tar.gz
git-842436466aa5d9f1e5f1a09d41d22d902006219c.tar.bz2
Make running git under other debugger-like programs easy
This allows us to run git, when using the script from bin-wrappers, under other programs. A few examples for usage within testsuite scripts: debug git checkout master debug --debugger=nemiver git $ARGS debug -d "valgrind --tool-memcheck --track-origins=yes" git $ARGS Or, if someone has bin-wrappers/ in their $PATH and is executing git outside the testsuite: GIT_DEBUGGER="gdb --args" git $ARGS GIT_DEBUGGER=nemiver git $ARGS GIT_DEBUGGER="valgrind --tool=memcheck --track-origins=yes" git $ARGS There is also a handy shortcut of GIT_DEBUGGER=1 meaning the same as GIT_DEBUGGER="gdb --args" Original-patch-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh24
1 files changed, 20 insertions, 4 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 7d620bf..c55ef09 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -145,12 +145,28 @@ test_pause () {
"$SHELL_PATH" <&6 >&5 2>&7
}
-# Wrap git in gdb. Adding this to a command can make it easier to
-# understand what is going on in a failing test.
+# Wrap git with a debugger. Adding this to a command can make it easier
+# to understand what is going on in a failing test.
#
-# Example: "debug git checkout master".
+# Examples:
+# debug git checkout master
+# debug --debugger=nemiver git $ARGS
+# debug -d "valgrind --tool=memcheck --track-origins=yes" git $ARGS
debug () {
- GIT_TEST_GDB=1 "$@" <&6 >&5 2>&7
+ case "$1" in
+ -d)
+ GIT_DEBUGGER="$2" &&
+ shift 2
+ ;;
+ --debugger=*)
+ GIT_DEBUGGER="${1#*=}" &&
+ shift 1
+ ;;
+ *)
+ GIT_DEBUGGER=1
+ ;;
+ esac &&
+ GIT_DEBUGGER="${GIT_DEBUGGER}" "$@" <&6 >&5 2>&7
}
# Call test_commit with the arguments