hesco has asked for the wisdom of the Perl Monks concerning the following question:
I need to redirect STDOUT, and probably STDERR, before its all over, for a test suite, analyze the results and take appropriate action based on that analysis. I'm finding it quite a challenge to figure out the right incantation which will accomplish this. I've left one of my tests commented out.
The print statement is writing to the file. But the Test::More->diag() calls are not making it. Neither are the results of the Test::More tests run in the subroutine call to the $self->_test_site() method.
I'd certainly appreciate any ideas. -- Hugh
{ local *STDOUT; my $log_file = '/tmp/test_sites_output'; # open(STDOUT,"| tee $log_file"); open(STDOUT,'>',"$log_file"); print "Testing the redirected STDOUT filehandle.\n"; foreach my $site (keys %{$sites}){ diag("Next . . . $site"); push @sites, $site; @url = @{$sites->{'url'}}; @expected = @{$sites->{'expected'}}; diag("The url is $url[0]"); diag("We expect the find: $expected[0]"); $self->_test_site($agent,$url[0],$expected[0]); # $self->_test_links($agent,$url); # $self->_test_valid_html($url); } close STDOUT; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Redirecting STDOUT
by Sidhekin (Priest) on Feb 11, 2007 at 13:14 UTC | |
|
Re: Redirecting STDOUT
by TOD (Friar) on Feb 11, 2007 at 13:09 UTC | |
|
Re: Redirecting STDOUT
by Moron (Curate) on Feb 12, 2007 at 16:00 UTC |