Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Capture::Tiny + Carp + Debugger fails to capture STDERR [rt.cpan.org #83915] #9

Open
dagolden opened this Issue · 0 comments

1 participant

@dagolden
Owner

https://rt.cpan.org/Ticket/Display.html?id=83915

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.