All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Thomas Rast <trast@inf.ethz.ch>
Cc: git@vger.kernel.org, Eric Wong <normalperson@yhbt.net>,
	Marcin Owsiany <marcin@owsiany.pl>, Petr Baudis <pasky@ucw.cz>
Subject: Re: [PATCH v2 2/2] t9700: do not close STDERR
Date: Thu, 4 Apr 2013 14:11:15 -0700	[thread overview]
Message-ID: <20130404211114.GQ30308@google.com> (raw)
In-Reply-To: <3689abc8e1af4ddbbb7791dd6241996f86e4efa2.1365107899.git.trast@inf.ethz.ch>

Thomas Rast wrote:

> --- a/t/t9700/test.pl
> +++ b/t/t9700/test.pl
> @@ -45,7 +45,8 @@ is($r->get_color("color.test.slot1", "red"), $ansi_green, "get_color");
>  # Failure cases for config:
>  # Save and restore STDERR; we will probably extract this into a
>  # "dies_ok" method and possibly move the STDERR handling to Git.pm.
> -open our $tmpstderr, ">&STDERR" or die "cannot save STDERR"; close STDERR;
> +open our $tmpstderr, ">&STDERR" or die "cannot save STDERR";
> +open STDERR, ">", "/dev/null" or die "cannot redirect STDERR to /dev/null";
>  is($r->config("test.dupstring"), "value2", "config: multivar");
>  eval { $r->config_bool("test.boolother") };
>  ok($@, "config_bool: non-boolean values fail");
>  open STDERR, ">&", $tmpstderr or die "cannot restore STDERR";

Yeah, this makes sense.

At first I was confused: why not just let stderr go out to the console,
where a person reading can see it?  But this test is meant to be run
using test_external_without_stderr, which redirects stderr to a file and
dies if it ends up getting any content.

perlfunc(1) documents the close-and-then-open trick for redirecting a
filehandle to an in-memory buffer.  Here a plain reopen works fine.

So for what it's worth
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

      reply	other threads:[~2013-04-04 21:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-03 22:26 [PATCH] perl: redirect stderr to /dev/null instead of closing Thomas Rast
2013-04-04  1:16 ` Eric Wong
2013-04-04 20:41   ` [PATCH v2 1/2] " Thomas Rast
2013-04-04 21:14     ` Eric Wong
2013-04-05 14:48     ` Petr Baudis
2013-04-05 18:57       ` Junio C Hamano
2013-04-05 23:34         ` Petr Baudis
2013-04-06  8:07           ` Thomas Rast
2013-04-06 10:34             ` Petr Baudis
2013-04-04 20:41   ` [PATCH v2 2/2] t9700: do not close STDERR Thomas Rast
2013-04-04 21:11     ` Jonathan Nieder [this message]

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=20130404211114.GQ30308@google.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=marcin@owsiany.pl \
    --cc=normalperson@yhbt.net \
    --cc=pasky@ucw.cz \
    --cc=trast@inf.ethz.ch \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.