Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Capture-Tiny CPAN distribution.

Report information
The Basics
Id: 83915
Status: open
Priority: 0/
Queue: Capture-Tiny

People
Owner: Nobody in particular
Requestors: ovid [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.21
Fixed in: (no value)



Subject: Capture::Tiny + Carp + Debugger fails to capture STDERR
This is the smallest test case I can replicate: #!/usr/bin/env perl use Capture::Tiny 'capture'; use Carp; my ( $in, $err, @results ) = capture { print "STDIN"; carp("STDERR"); return ( 1, 2 ); }; As expected, that prints no output. However, if you run under the debugger, STDERR is written to my terminal and $err contains the empty string. If you prefer a test: use Capture::Tiny 'capture'; use Test::More; use Carp; my ( $in, $err, @results ) = capture { print "STDIN"; carp("STDERR"); return ( 1, 2 ); }; is $in, 'STDIN', '$in ok'; like $out, qr/^STDERR/, '$out ok'; is_deeply \@results, [ 1, 2 ], '@results ok'; done_testing; However, I can only force that test to fail under the debugger, making it somewhat less useful. This is Capture::Tiny version 0.21 This is Carp version 1.25 This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64- linux $ uname -a Linux ovid-desktop 3.2.0-38-generic #61-Ubuntu SMP Tue Feb 19 12:18:21 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux Cheers, Ovid
Download (untitled) / with headers
text/plain 407b
On Wed Mar 13 07:03:10 2013, OVID wrote: <snip> Show quoted text
> use Capture::Tiny 'capture'; > use Test::More; > use Carp; > > my ( $in, $err, @results ) = capture { > print "STDIN"; > carp("STDERR"); > return ( 1, 2 ); > }; > is $in, 'STDIN', '$in ok'; > like $out, qr/^STDERR/, '$out ok';
Of course, that's "like $err...". Same thing, though. Cheers, Ovid
Download (untitled) / with headers
text/plain 332b
I have no idea how I would test that in an automated way, but thank you. Is it specific to Carp? Or does it happen for warn()? It's possible this might fall under the "modifying filehandles before capturing" caveat and need to be documented. I'm really reluctant to dig around in the guts of the debugger to see what it's doing.
Download (untitled) / with headers
text/plain 823b
On Wed Mar 13 11:17:39 2013, DAGOLDEN wrote: Show quoted text
> I have no idea how I would test that in an automated way, but thank
you. Show quoted text
> > Is it specific to Carp? Or does it happen for warn()? > > It's possible this might fall under the "modifying filehandles before > capturing" caveat and need to be documented. > > I'm really reluctant to dig around in the guts of the debugger to see > what it's doing.
Wow, I missed something in my attempts to reduce this to a simple test case because it does happen with warn(). carp() is a red herring. I know testing this might be rough, but didn't Shlomi write some debugger tests? Is there something which could be stolen there? Or maybe Leon Brocard might have suggestions? (He wrote Devel::ebug). And yeah, I've done enough debugger hacking to know that it's not fun. Cheers, Ovid


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.