Skip to content

Commit

Permalink
Forgot to add this
Browse files Browse the repository at this point in the history
  • Loading branch information
exodist committed Jan 23, 2011
1 parent 62657be commit 5a39552
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions lib/Fennec/Listener/TB/Handle.pm
@@ -0,0 +1,45 @@
package Fennec::Listener::TB::Handle;
use strict;
use warnings;

use Fennec::Util qw/accessors get_test_call/;

accessors qw/name out/;

sub TIEHANDLE {
my $class = shift;
my ( $name, $out ) = @_;
return bless( { name => $name, out => $out }, $class );
}

sub PRINT {
my $self = shift;
my @data = @_;
my @call = get_test_call();
my $out = $self->out;

for my $output ( @_ ) {
print $out join( "\0", $$, $self->name, $call[0], $call[1], $call[2], $_ ) . "\n"
for split( /[\n\r]+/, $output );
}
}

1;
__END__
my $original_print = Test::Builder->can('_print_to_fh');
*Test::Builder::_print_to_fh = sub {
my( $tb, $fh, @msgs ) = @_;
my ( $handle, $output );
open( $handle, '>', \$output );
$original_print->( $tb, $handle, @msgs );
close( $handle );
my $ohandle = ($fh == $tb->output) ? 'STDOUT' : 'STDERR';
my @call = get_test_call();
print $out join( "\0", $$, $ohandle, $call[0], $call[1], $call[2], $_ ) . "\n"
for split( /[\n\r]+/, $output );
};

0 comments on commit 5a39552

Please sign in to comment.