1package Test::Builder::Formatter; 2use strict; 3use warnings; 4 5our $VERSION = '1.302162'; 6 7BEGIN { require Test2::Formatter::TAP; our @ISA = qw(Test2::Formatter::TAP) } 8 9use Test2::Util::HashBase qw/no_header no_diag/; 10 11BEGIN { 12 *OUT_STD = Test2::Formatter::TAP->can('OUT_STD'); 13 *OUT_ERR = Test2::Formatter::TAP->can('OUT_ERR'); 14 15 my $todo = OUT_ERR() + 1; 16 *OUT_TODO = sub() { $todo }; 17} 18 19sub init { 20 my $self = shift; 21 $self->SUPER::init(@_); 22 $self->{+HANDLES}->[OUT_TODO] = $self->{+HANDLES}->[OUT_STD]; 23} 24 25sub plan_tap { 26 my ($self, $f) = @_; 27 28 return if $self->{+NO_HEADER}; 29 return $self->SUPER::plan_tap($f); 30} 31 32sub debug_tap { 33 my ($self, $f, $num) = @_; 34 return if $self->{+NO_DIAG}; 35 my @out = $self->SUPER::debug_tap($f, $num); 36 $self->redirect(\@out) if @out && $f->{about}->{package} eq 'Test::Builder::TodoDiag'; 37 return @out; 38} 39 40sub info_tap { 41 my ($self, $f) = @_; 42 return if $self->{+NO_DIAG}; 43 my @out = $self->SUPER::info_tap($f); 44 $self->redirect(\@out) if @out && $f->{about}->{package} eq 'Test::Builder::TodoDiag'; 45 return @out; 46} 47 48sub redirect { 49 my ($self, $out) = @_; 50 $_->[0] = OUT_TODO for @$out; 51} 52 53sub no_subtest_space { 1 } 54 551; 56 57__END__ 58 59=pod 60 61=encoding UTF-8 62 63=head1 NAME 64 65Test::Builder::Formatter - Test::Builder subclass of Test2::Formatter::TAP 66 67=head1 DESCRIPTION 68 69This is what takes events and turns them into TAP. 70 71=head1 SYNOPSIS 72 73 use Test::Builder; # Loads Test::Builder::Formatter for you 74 75=head1 SOURCE 76 77The source code repository for Test2 can be found at 78F<http://github.com/Test-More/test-more/>. 79 80=head1 MAINTAINERS 81 82=over 4 83 84=item Chad Granum E<lt>exodist@cpan.orgE<gt> 85 86=back 87 88=head1 AUTHORS 89 90=over 4 91 92=item Chad Granum E<lt>exodist@cpan.orgE<gt> 93 94=back 95 96=head1 COPYRIGHT 97 98Copyright 2019 Chad Granum E<lt>exodist@cpan.orgE<gt>. 99 100This program is free software; you can redistribute it and/or 101modify it under the same terms as Perl itself. 102 103See F<http://dev.perl.org/licenses/> 104 105=cut 106