X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FTest%2FLeaner.pm;h=92f386f6402913e7bfd40a71d3e8a2ac5870c507;hb=da6dd0b8533e32433851119428d3bc4e1959599c;hp=c1b8df4b712334a900802ec34b9260407b905f2e;hpb=e3abaf6002541705d0afdab5a64e6f82dde4ec6c;p=perl%2Fmodules%2FTest-Leaner.git diff --git a/lib/Test/Leaner.pm b/lib/Test/Leaner.pm index c1b8df4..92f386f 100644 --- a/lib/Test/Leaner.pm +++ b/lib/Test/Leaner.pm @@ -52,14 +52,7 @@ BEGIN { } } -my $TAP_STREAM = *STDOUT; -my $DIAG_STREAM = *STDERR; - -for ($TAP_STREAM, $DIAG_STREAM) { - my $fh = select $_; - $|++; - select $fh; -} +my ($TAP_STREAM, $DIAG_STREAM); my ($plan, $test, $failed, $no_diag, $done_testing); @@ -505,6 +498,58 @@ END { L, L, L, L, L, L, L and L are all guaranteed to return the truth value of the test. Their L counterparts behave the same, but it is not documented anywhere. +L also provides some functions of its own, which are never exported. + +=head2 C + +Read/write accessor for the filehandle to which the tests are outputted. +On write, it also turns autoflush on onto C<$fh>. + +Note that it can only be used as a write accessor before you start any thread, as L cannot reliably share filehandles. + +Defaults to C. + +=cut + +sub tap_stream (;*) { + if (@_) { + $TAP_STREAM = $_[0]; + + my $fh = select $TAP_STREAM; + $|++; + select $fh; + } + + return $TAP_STREAM; +} + +tap_stream *STDOUT; + +=head2 C + +Read/write accessor for the filehandle to which the diagnostics are printed. +On write, it also turns autoflush on onto C<$fh>. + +Just like L, it can only be used as a write accessor before you start any thread, as L cannot reliably share filehandles. + +Defaults to C. + +=cut + +sub diag_stream (;*) { + if (@_) { + $DIAG_STREAM = $_[0]; + + my $fh = select $DIAG_STREAM; + $|++; + select $fh; + } + + return $DIAG_STREAM; +} + +diag_stream *STDERR; + =head1 DEPENDENCIES L 5.6.