git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2 2/2] tests: make the 'test_pause' helper work in non-verbose mode

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Mar 18, 2017, 16:14 UTC
Message-ID
<20170318161400.19753-2-szeder.dev@gmail.com>
In-Reply-To
<20170318161400.19753-1-szeder.dev@gmail.com>

When the 'test_pause' helper function invokes the shell mid-test, it explicitly redirects the shell's stdout and stderr to file descriptors 3 and 4, which are the stdout and stderr of the tests (i.e. where they would be connected anyway without those redirections). These file descriptors are only attached to the terminal in verbose mode, hence the restriction of 'test_pause' to work only with '-v'.

Redirect the shell's stdout and stderr to the test environment's original stdout and stderr, allowing it to work properly even in non-verbose mode, and the restriction can be lifted.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/test-lib-functions.sh | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 4a50a6104..5ee124332 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -136,17 +136,12 @@ 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".
+# Stop execution and start a shell. This is useful for debugging tests.
 #
 # 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
+	"$SHELL_PATH" <&6 >&5 2>&7
 }
 
 # Wrap git in gdb. Adding this to a command can make it easier to
-- 
2.12.0.377.g15f6ffe90
Previous: SZEDER GáborNext: Jeff King
Message 5 of 9 in “tests: create an interactive gdb session with the 'debug' helper”
  1. tests: create an interactive gdb session with the 'debug' helperSZEDER Gábor, Mar 17, 2017
  2. Jeff KingMar 17, 2017
  3. SZEDER GáborMar 18, 2017
  4. 1/2 tests: create an interactive gdb session with the 'debug' helperSZEDER Gábor, Mar 18, 2017
  5. 2/2 tests: make the 'test_pause' helper work in non-verbose modeSZEDER Gábor, Mar 18, 2017
  6. Jeff KingMar 20, 2017
  7. Jeff KingMar 20, 2017
  8. Johannes SchindelinMar 21, 2017
  9. Jeff KingMar 20, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.