Skip Menu |

This queue is for tickets about the Test-Harness CPAN distribution.

Report information
The Basics
Id: 32511
Status: resolved
Priority: 0/
Queue: Test-Harness

People
Owner: andy [...] hexten.net
Requestors: RENEEB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 3.07
Fixed in: (no value)



Subject: Option for "redirecting" failure output
Hi, it would be great to have another option for redirecting output: Something like # verbosity => -3 means absolutely no output (even the failure output is surpressed) execute_tests( tests => \@tests, out => $handle, verbosity => -3 ); or execute_tests( tests => \@tests, out => $handle, err => $err_handle ); err should accept objects of IO::Handle, IO::Scalar,... Cheers, Renee
On Tue Jan 22 07:57:01 2008, RENEEB wrote: Show quoted text
> it would be great to have another option for redirecting output:
This is Test::Harness rather than TAP::Harness, right? We're not planning to extend the Test::Harness interface - it's there for legacy support. New applications should instead use TAP::Harness. I'm not sure about capturing stderr in TAP::Harness either. It's likely to be a confusing interface because we don't always see stderr - under some circumstances it just goes direct to your console (or wherever you're sending it). TAP::Harness has a 'stdout' parameter that lets you redirect stdout to anything that looks like an IO handle.
From: RENEEB [...] cpan.org
Show quoted text
> TAP::Harness has a 'stdout' parameter that lets you redirect stdout
to Show quoted text
> anything that looks like > an IO handle.
I know that, but you can't capture everything with stdout... A simple script that uses *::Harness (works with both TAP::Harness and Test::Harness) #!/usr/bin/perl use strict; use warnings; use TAP::Harness; use IO::Scalar; my $var; my $out = IO::Scalar->new( \$var ); my @tests = ('test2.pl'); my $harness = TAP::Harness->new({ verbosity => -2, stdout => $out, }); $harness->runtests( \@tests ); And a little test-script: #!/usr/bin/perl use strict; use warnings; use Test::More tests => 3; is(1,1); is(2,1); die; When I run the first script I still see this: C:\>harness.pl # Failed test at test2.pl line 9. # got: '2' # expected: '1' Died at test2.pl line 10. # Looks like you planned 3 tests but only ran 2. # Looks like you failed 1 test of 2 run. # Looks like your test died just after 2. And I want to handle this output with an IO::Handle object or (at least) suppress the output.
On Wed Jan 23 08:17:04 2008, RENEEB wrote: Show quoted text
> And I want to handle this output with an IO::Handle object or (at > least) suppress the output.
Yeah, but that's output on stderr and we don't always filter stderr. Sometimes it goes directly from your test to your console without going anywhere near TAP::Harness. In particular on non-forking platforms (apart from Win32) we don't grab stderr at all. So if we implemented stderr capture it'd only work on some platforms. The long term solution is to have all diagnostic information from the tests generated as YAMLish markup which goes down the same handle as all the other TAP - and stderr should just be for real errors. That being the case I'd rather we didn't futz around with stderr in the mean time.
Show quoted text
> The long term solution is to have all diagnostic information from the > tests generated as > YAMLish markup which goes down the same handle as all the other TAP - > and stderr should > just be for real errors. > > That being the case I'd rather we didn't futz around with stderr in > the mean time. >
Ok, that sounds good!