Poking about in the code for Test::Harness and several responses in SuperSearch is not getting me to the promised land. So permit me please to ask here.

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; }
if( $lal && $lol ) { $life++; }

In reply to Redirecting STDOUT by hesco

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.