From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>, git@vger.kernel.org
Subject: Re: [PATCH 3/6] Facilitate debugging Git executables in tests with gdb
Date: Fri, 30 Oct 2015 12:02:56 -0700 [thread overview]
Message-ID: <20151030190256.GI7881@google.com> (raw)
In-Reply-To: <xmqqlhakky0e.fsf@gitster.mtv.corp.google.com>
Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> On Tue, 27 Oct 2015, Junio C Hamano wrote:
>>> It can be called GDB=1, perhaps?
>>
>> No, this is way too generic. As I only test that the environment
>> variable's existence, even something like GDB=/usr/opt/gdb/bin/gdb would
>> trigger it.
>>
>> I could be talked into GDB_GIT=1, though.
>
> As I said in another message, I have no preference myself over the
> name of this variable (or making it a shell function like Duy
> mentioned, which incidentally may give us more visual pleasantness
> by losing '=').
>
> I'd just be happy as long as the feature becomes available, and I'd
> leave the choice of consistent and convenient naming to others who
> have stronger opinions ;-)
Here's a suggested patch.
-- >8 --
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: 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>
---
t/README | 5 +++++
t/test-lib-functions.sh | 8 ++++++++
wrap-for-bin.sh | 8 +++++++-
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/t/README b/t/README
index 35438bc..1dc908e 100644
--- a/t/README
+++ b/t/README
@@ -563,6 +563,11 @@ library for your script to use.
argument. This is primarily meant for use during the
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
Your test script must have test_done at the end. Its purpose
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 6dffb8b..73e37a1 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -145,6 +145,14 @@ test_pause () {
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>]]]"
#
# This will commit a file with the given contents and the given commit
diff --git a/wrap-for-bin.sh b/wrap-for-bin.sh
index 701d233..db0ec6a 100644
--- a/wrap-for-bin.sh
+++ b/wrap-for-bin.sh
@@ -19,4 +19,10 @@ GIT_TEXTDOMAINDIR='@@BUILD_DIR@@/po/build/locale'
PATH='@@BUILD_DIR@@/bin-wrappers:'"$PATH"
export GIT_EXEC_PATH GITPERLLIB PATH GIT_TEXTDOMAINDIR
-exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+if test -n "$GIT_TEST_GDB"
+then
+ unset GIT_TEST_GDB
+ exec gdb --args "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+else
+ exec "${GIT_EXEC_PATH}/@@PROG@@" "$@"
+fi
--
2.6.0.rc2.230.g3dd15c0
next prev parent reply other threads:[~2015-10-30 19:03 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 13:14 [PATCH 0/6] Miscellaneous platform-independent patches from Git for Windows Johannes Schindelin
2015-10-26 13:14 ` [PATCH 1/6] Only use CURLOPT_LOGIN_OPTIONS if it is actually available Johannes Schindelin
2015-10-26 20:17 ` Junio C Hamano
2015-10-26 13:15 ` [PATCH 2/6] remote-http(s): Support SOCKS proxies Johannes Schindelin
2015-10-26 20:15 ` Junio C Hamano
2015-10-27 1:23 ` James McCoy
2015-10-27 1:40 ` Junio C Hamano
2015-10-27 15:50 ` Johannes Schindelin
2015-10-27 15:53 ` Johannes Schindelin
2015-10-27 17:27 ` Junio C Hamano
2015-10-27 19:38 ` Junio C Hamano
2015-10-27 21:01 ` Junio C Hamano
2015-10-30 18:38 ` Johannes Schindelin
2015-11-09 22:28 ` Pat Thoyts
2015-11-16 21:49 ` Johannes Schindelin
2015-11-18 6:52 ` Junio C Hamano
2015-10-26 13:15 ` [PATCH 3/6] Facilitate debugging Git executables in tests with gdb Johannes Schindelin
2015-10-26 19:17 ` Jonathan Nieder
2015-10-27 9:42 ` Johannes Schindelin
2015-10-27 16:34 ` Junio C Hamano
2015-10-27 23:28 ` Jeff King
2015-10-27 23:39 ` Stefan Beller
2015-10-27 23:58 ` Jeff King
2015-10-30 18:25 ` Johannes Schindelin
2015-10-30 19:26 ` Jeff King
2015-10-30 18:27 ` Johannes Schindelin
2015-10-30 18:32 ` Junio C Hamano
2015-10-30 19:02 ` Jonathan Nieder [this message]
2015-10-30 19:14 ` Johannes Schindelin
2015-10-30 19:56 ` Jeff King
2015-10-30 21:30 ` Jonathan Nieder
2015-10-30 21:53 ` Junio C Hamano
2015-10-30 18:31 ` Johannes Schindelin
2015-10-30 18:55 ` Jonathan Nieder
2015-10-27 18:09 ` Duy Nguyen
2015-10-29 16:44 ` Junio C Hamano
2015-10-29 5:15 ` Victor Leschuk
2015-10-30 18:42 ` Johannes Schindelin
2015-11-01 5:31 ` Victor Leschuk
2015-11-01 13:37 ` Johannes Schindelin
2015-10-26 13:15 ` [PATCH 4/6] Squelch warning about an integer overflow Johannes Schindelin
2015-10-26 20:23 ` Junio C Hamano
2015-10-30 18:18 ` Johannes Schindelin
2015-10-30 18:21 ` Junio C Hamano
2015-10-26 13:15 ` [PATCH 5/6] Silence GCC's "cast of pointer to integer of a different size" warning Johannes Schindelin
2015-10-26 20:20 ` Junio C Hamano
2015-10-26 13:15 ` [PATCH 6/6] Correct fscanf formatting string for I64u values Johannes Schindelin
2015-10-26 20:20 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151030190256.GI7881@google.com \
--to=jrnieder@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).