Grokbase
x

[PATCH] Quiet autodie's pollution of test output

View TopicPrint | Flat  Thread  Threaded
1) Jerry D. Hedden The attached patch quiets the output from lib/autodie/t/hints.t which is currently outputting the...
paperclip | +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
The attached patch quiets the output from lib/autodie/t/hints.t which
is currently outputting the following:

lib/autodie/t/format-clobber..................................ok
lib/autodie/t/hints...........................................#
Sub::Identify is not loaded
ok
lib/autodie/t/hints_insist....................................ok

Attachment: quiet.patch
2) Craig Berry I guess this should go to: <http://rt.cpan.org/Public/Dist/Display.html?Name=autodie> rather than...
| +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Wed, Jul 1, 2009 at 3:36 PM, Jerry D. Hedden<jdhedden@cpan.org> wrote:
> The attached patch quiets the output from lib/autodie/t/hints.t which
> is currently outputting the following:
>
> lib/autodie/t/format-clobber..................................ok
> lib/autodie/t/hints...........................................#
> Sub::Identify is not loaded
> ok
> lib/autodie/t/hints_insist....................................ok

I guess this should go to:

<http://rt.cpan.org/Public/Dist/Display.html?Name=autodie>

rather than p5p.  And since the test is already using Test::More, it
might make more sense for it to call use_ok() rather than scanning
%INC to see if something got loaded successfully (unless I"m missing
the intent of the test or misremembering the capabilities of use_ok()
).  Barring  that, I think prepending '#' might be preferable to
suppressing output in the core, but that's a minor nit.
3) Paul Fenwick G'day Jerry, Craig, and p5p, RT is preferred. github isn't bad. p5p's not bad either. The big no-no...
| +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
G'day Jerry, Craig, and p5p,

Craig A. Berry wrote:

> I guess this should go to:
>
> <http://rt.cpan.org/Public/Dist/Display.html?Name=autodie>

RT is preferred.  github isn't bad.  p5p's not bad either.  The big no-no is
reporting bugs by bitching randomly on twitter.  I have terrible response
times on those.  ;)

> rather than p5p. And since the test is already using Test::More, it
> might make more sense for it to call use_ok() rather than scanning
> %INC to see if something got loaded successfully (unless I"m missing
> the intent of the test or misremembering the capabilities of use_ok()

The test is actually more complex than it first appears.  autodie::hints
uses Sub::Identify to resolve subroutine references back to subroutine
times.  However if Sub::Identify is not loaded, it uses its own internal
code to do the same.  The tests in question are checking to see if we're
correctly resolving subroutine names, and if that ever throws a bug, I want
to know *how* we were resolving subroutine names.

use_ok() would insist that we be able to load Sub::Identify, but here it's
perfectly fine if we don't, hence the check to %INC.

> Barring that, I think prepending '#' might be preferable to
> suppressing output in the core, but that's a minor nit.

Since the line in question is using diag(), it already does have a #
prepended to it.  AFAIK most TAP parses pass that through to the user by
default.

In this case, I'm very happy for the debug output to be suppressed when
doing core testing, since Sub::Identify is not a core module, it's never
going to be loaded.  That makes the debug line itself is therefore redundant.

I've applied this upstream as a72aad7, and will go into the next release of
autodie.  I'm very happy for Jerry's patch to be applied as-is to the core;
it will bring my repo and blead back into sync.

Jerry - many thanks for the patch!

All the best,

Paul

--
Paul Fenwick <pjf@perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia | Fax: +61 3 9354 2681
4) Rafael Garcia-Suarez 2009/7/2 Paul Fenwick <pjf@perltraining.com.au>: y diag() writes to STDERR by default, so it's...
| +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
2009/7/2 Paul Fenwick <pjf@perltraining.com.au>:
> Since the line in question is using diag(), it already does have a #
> prepended to it. =A0AFAIK most TAP parses pass that through to the user b=
y
> default.

diag() writes to STDERR by default, so it's noisy and clutters output. Core
tests use C<print "# message\n"> instead for this reason.

Is there a way to make diag() output to STDOUT by default globally (from
the test harness) ? I'd rather not mess with redirections, but a global
environment variable that would tell Test::Builder to use STDOUT for
all streams by default would be nice. That way dual-life module authors
could still use diag() to print informative messages. Would a patch be welc=
omed?
5) David E. Wheeler Use note() instead of diag(). Looks like there isn't, but I could see where that'd be useful. Best,...
| +1 vote (Anchor)
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Jul 2, 2009, at 3:32 AM, Rafael Garcia-Suarez wrote:

> 2009/7/2 Paul Fenwick <pjf@perltraining.com.au>:
>> Since the line in question is using diag(), it already does have a #
>> prepended to it. AFAIK most TAP parses pass that through to the
>> user by
>> default.
>
> diag() writes to STDERR by default, so it's noisy and clutters
> output. Core
> tests use C<print "# message\n"> instead for this reason.

> Is there a way to make diag() output to STDOUT by default globally
> (from
> the test harness) ?

Use note() instead of diag().

> I'd rather not mess with redirections, but a global
> environment variable that would tell Test::Builder to use STDOUT for
> all streams by default would be nice. That way dual-life module
> authors
> could still use diag() to print informative messages. Would a patch
> be welcomed?

Looks like there isn't, but I could see where that'd be useful.

Best,

David
spacer
View TopicPrint | Flat  Thread  Threaded
Home > Groups > Perl 5 Porters > [PATCH] Quiet autodie's pollution of test output (5 posts)