Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Redirecting STDOUT from internal function with 5.6.1 restrictions

by diotalevi (Canon)
on Oct 12, 2004 at 23:49 UTC ( #398739=note: print w/replies, xml ) Need Help??

in reply to Redirecting STDOUT from internal function with 5.6.1 restrictions

If you were using Test::More, this would be easy and documented. The output handle is set by the internal Test::Builder object which itself has the methods ->output( $fh ), ->failure_output( $fh ), and ->todo_output( $fh ) to set the various filehandles.

Here is an example from one of my scripts which shows test output being captured.

use Test::More; use vars qw( $TEST_OUTPUT ); main( @ARGV ); exit 0; sub main { intialize( @_ ); ok( ... ); print $TEST_OUTPUT; 1; } sub initialize { $| = 1; open my $fh, ">", \ $TEST_OUTPUT or die; my $b = Test::More->builder; $b->output( $fh ); $b->failure_output( $fh ); $b->todo_output( $fh ); 1; }

Replies are listed 'Best First'.
Re^2: Redirecting STDOUT from internal function with 5.6.1 restrictions
by mgc (Novice) on Oct 13, 2004 at 20:13 UTC
    Thanks, but the reason I posted this was because I don't have Test::More available to me. Thanks.

      Its available from CPAN.

      If silly office politics prevent you from installing CPAN modules you can copy the module straight into your test directory and have your tests do "use lib 't/lib'". See for an example.

      -- Michael G Schwern

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://398739]
choroba notices a missing "C"
[LanX]: horoba?
[marto]: Rocks (YouTubes warning)
[Corion]: Your Mother: Better than Roc hunting, I guess :)
LanX WTF. Gernany beat Canada in ice hockey
[LanX]: Not fair ... I'm totally ignoring the doping games...
[Corion]: Huh? That's weird indeed... Also, I thought that the olympic games were over already, but obviously not ;)
[choroba]: And we lost to unknown sportspersons with no official dresses
[choroba]: Russia didn't send them officially, they're on vacation in Korea
[LanX]: no that was Syria! ;-)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2018-02-23 16:22 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (303 votes). Check out past polls.