From: Jeff King <peff@peff.net>
To: Jens Lehmann <Jens.Lehmann@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] test-lib: add the test_bash convenience function
Date: Sun, 15 Jan 2012 18:24:13 -0500 [thread overview]
Message-ID: <20120115232413.GA14724@sigill.intra.peff.net> (raw)
In-Reply-To: <4F133069.10308@web.de>
On Sun, Jan 15, 2012 at 09:00:41PM +0100, Jens Lehmann wrote:
> 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".
Yeah, an unfortunate side effect.
If you're not relying on particular state in the middle of a chain of
commands, you can just put the "bash" outside of the test_expect_*. But
sometimes you do care about having it in the middle.
> 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.
Nice. Many times I have added such a "bash" or "gdb" invocation then
forgotten "-v", only to scratch my head at why the test seemed to be
hanging.
Two minor nits on the patch itself:
> +# 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
> +}
1. It may be worth putting a warning in the comment that this is never
to be used in a real test, but only temporarily inserted.
2. I do this not just with bash, but with "gdb". I wonder if it is worth
making this "test_foo bash", for some value of "foo" (the ones that
occur to me are "debug" and "run", but of course they are taken).
Actually, I wonder if the existing test_debug could handle this
already (though you do have to remember to add "--debug" to your
command line, then).
-Peff
next prev parent reply other threads:[~2012-01-15 23:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-15 20:00 [PATCH] test-lib: add the test_bash convenience function Jens Lehmann
2012-01-15 23:24 ` Jeff King [this message]
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
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=20120115232413.GA14724@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Jens.Lehmann@web.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).