1package Test::Builder::Formatter; 2use strict; 3use warnings; 4 5our $VERSION = '1.302175'; 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 && ref $f->{about} && defined $f->{about}->{package} 37 && $f->{about}->{package} eq 'Test::Builder::TodoDiag'; 38 return @out; 39} 40 41sub info_tap { 42 my ($self, $f) = @_; 43 return if $self->{+NO_DIAG}; 44 my @out = $self->SUPER::info_tap($f); 45 $self->redirect(\@out) if @out && ref $f->{about} && defined $f->{about}->{package} 46 && $f->{about}->{package} eq 'Test::Builder::TodoDiag'; 47 return @out; 48} 49 50sub redirect { 51 my ($self, $out) = @_; 52 $_->[0] = OUT_TODO for @$out; 53} 54 55sub no_subtest_space { 1 } 56 571; 58 59__END__ 60 61=pod 62 63=encoding UTF-8 64 65=head1 NAME 66 67Test::Builder::Formatter - Test::Builder subclass of Test2::Formatter::TAP 68 69=head1 DESCRIPTION 70 71This is what takes events and turns them into TAP. 72 73=head1 SYNOPSIS 74 75 use Test::Builder; # Loads Test::Builder::Formatter for you 76 77=head1 SOURCE 78 79The source code repository for Test2 can be found at 80F<http://github.com/Test-More/test-more/>. 81 82=head1 MAINTAINERS 83 84=over 4 85 86=item Chad Granum E<lt>exodist@cpan.orgE<gt> 87 88=back 89 90=head1 AUTHORS 91 92=over 4 93 94=item Chad Granum E<lt>exodist@cpan.orgE<gt> 95 96=back 97 98=head1 COPYRIGHT 99 100Copyright 2019 Chad Granum E<lt>exodist@cpan.orgE<gt>. 101 102This program is free software; you can redistribute it and/or 103modify it under the same terms as Perl itself. 104 105See F<http://dev.perl.org/licenses/> 106 107=cut 108