tests: create an interactive gdb session with the 'debug' helper
authorSZEDER Gábor <szeder.dev@gmail.com>
Sat, 18 Mar 2017 16:13:59 +0000 (17:13 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 18 Mar 2017 17:18:20 +0000 (10:18 -0700)
The 'debug' test helper is supposed to facilitate debugging by running
a command of the test suite under gdb. Unfortunately, its usefulness
is severely limited, because that gdb session is not interactive,
since the test's, and thus gdb's standard input is redirected from
/dev/null (for a good reason, see 781f76b15 (test-lib: redirect stdin
of tests, 2011-12-15)).

Redirect gdb's standard file descriptors from/to the test
environment's stdin, stdout and stderr in the 'debug' helper, thus
creating an interactive gdb session (even in non-verbose mode), which
is much, much more useful.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib-functions.sh
t/test-lib.sh
index bd357704cce987afa79ec8fce038aa05f8c0a762..4a50a61040a651beeb10762bcb9241cbc7a56a60 100644 (file)
@@ -154,7 +154,7 @@ test_pause () {
 #
 # Example: "debug git checkout master".
 debug () {
-        GIT_TEST_GDB=1 "$@"
+        GIT_TEST_GDB=1 "$@" <&6 >&5 2>&7
 }
 
 # Call test_commit with the arguments
index 86d77c16dd3abcedd3fd4937a73b142a6b83b7b6..23c29bce6edbb5b921145e80849600896c2e1e3f 100644 (file)
@@ -342,6 +342,7 @@ fi
 
 exec 5>&1
 exec 6<&0
+exec 7>&2
 if test "$verbose_log" = "t"
 then
        exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3