git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] test-lib: add the test_bash convenience function
@ 2012-01-15 20:00 Jens Lehmann
  2012-01-15 23:24 ` Jeff King
  0 siblings, 1 reply; 12+ messages in thread
From: Jens Lehmann @ 2012-01-15 20:00 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Jeff King, Junio C Hamano

Since 781f76b15 (test-lib: redirect stdin of tests) you can't simply put a
"bash &&" into a test for debugging purposes anymore. Instead you'll have
to use "bash <&6 >&3 2>&4".

As that invocation is not that easy to remember add the test_bash
convenience function. This function also checks if the -v flag is given
and will complain if that is not the case instead of letting the test
hang until ^D is pressed.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---

I was tempted to call that method "run_bash" but after looking around
in test-lib.sh "test_bash" seemed like a better name.

 t/test-lib.sh |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index a65dfc7..f9061e0 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -329,6 +329,17 @@ test_tick () {
 	export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
 }

+# Stop execution and start a bash shell. This is useful for debugging tests
+# and only makes sense together with "-v".
+
+test_bash () {
+	if test "$verbose" = t; then
+		bash <&6 >&3 2>&4
+	else
+		say >&5 "skipping test_bash as it makes no sense without -v"
+	fi
+}
+
 # Call test_commit with the arguments "<message> [<file> [<contents>]]"
 #
 # This will commit a file with the given contents and the given commit
-- 
1.7.9.rc1.1.g46aa0.dirty

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-01-17 21:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-15 20:00 [PATCH] test-lib: add the test_bash convenience function Jens Lehmann
2012-01-15 23:24 ` Jeff King
2012-01-16 15:49   ` [PATCH] test_interactive: interactive debugging in test scripts Pete Wyckoff
2012-01-16 20:01     ` Jens Lehmann
2012-01-16 20:11       ` Jeff King
2012-01-16 20:48         ` Jens Lehmann
2012-01-16 22:07           ` Pete Wyckoff
2012-01-16 20:19     ` Jeff King
2012-01-16 22:51   ` [PATCH] test-lib: add the test_bash convenience function Junio C Hamano
2012-01-17  8:21     ` [PATCH] test-lib: add the test_pause " Jens Lehmann
2012-01-17 19:15       ` Junio C Hamano
2012-01-17 21:04         ` [PATCH v2] " Jens Lehmann

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).