dragonchild has asked for the wisdom of the Perl Monks concerning the following question:

I re-read Parallel maintenance on many projects, part II: The Testing and decided to try something similar for some of the modules I've been working with (both CPAN and not). Unlike brian_d_foy, I wanted to use Test::Harness::Straps from the get-go. Just to be different. :-)

Starting with the code Schwern posted (that brian_d_foy links to), I modified it slightly to run through all the tests in a given t/, as so:

use strict; use warnings; use Test::Harness::Straps; my $tester = Test::Harness::Straps->new; use lib 'blib'; my @failures; foreach my $file (<t/*.t>) { local *STDERR; my %results = $tester->analyze_file( $file ); push @failures, $file unless $results{passing}; } if (@failures) { print scalar(@failures), " files failed.\n"; local $"=$/; print "@failures\n"; } else { print "All tests succeeded.\n"; }

When all the tests pass, I get a nice "All tests succeeded." message. But, when the tests fail, especially due to a module that doesn't compile, a bunch of messages appear on STDERR and local *STDERR; doesn't fix that. Turns out it's cause the test file is being run in a sub-process.

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Replies are listed 'Best First'.
Re: Test::Harness::Straps and STDERR
by PodMaster (Abbot) on Jan 14, 2005 at 20:01 UTC
    local *STDERR; doesn't fix that
    That's because system calls some c function which doesn't know about *main::STDERR, and which takes file descriptor 2 to mean STDERR.
    print "local *STDERR$/"; { local *STDERR; system $^X, qw[ -le warn(6) ]; } print "close STDERR$/"; { close STDERR; system $^X, qw[ -le warn(6) ]; } __END__ local *STDERR 6 at -e line 1. close STDERR
    Is there some way I can stop that without having to patch Test...
    Don't patch Test::Harness::Straps , just subclass it and use File::Spec->devnull()

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.