Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dagolden opened this issue Mar 27, 2013 · 0 comments

Comments

@dagolden
Copy link
Collaborator

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants