1package TAP::Formatter::File::Session; 2 3use strict; 4use warnings; 5use base 'TAP::Formatter::Session'; 6 7=head1 NAME 8 9TAP::Formatter::File::Session - Harness output delegate for file output 10 11=head1 VERSION 12 13Version 3.48 14 15=cut 16 17our $VERSION = '3.48'; 18 19=head1 DESCRIPTION 20 21This provides file orientated output formatting for L<TAP::Harness>. 22It is particularly important when running with parallel tests, as it 23ensures that test results are not interleaved, even when run 24verbosely. 25 26=cut 27 28=head1 METHODS 29 30=head2 result 31 32Stores results for later output, all together. 33 34=cut 35 36sub result { 37 my $self = shift; 38 my $result = shift; 39 40 my $parser = $self->parser; 41 my $formatter = $self->formatter; 42 43 if ( $result->is_bailout ) { 44 $formatter->_failure_output( 45 "Bailout called. Further testing stopped: " 46 . $result->explanation 47 . "\n" ); 48 return; 49 } 50 51 if (!$formatter->quiet 52 && ( $formatter->verbose 53 || ( $result->is_test && $formatter->failures && !$result->is_ok ) 54 || ( $formatter->comments && $result->is_comment ) 55 || ( $result->has_directive && $formatter->directives ) ) 56 ) 57 { 58 $self->{results} .= $self->_format_for_output($result) . "\n"; 59 } 60} 61 62=head2 close_test 63 64When the test file finishes, outputs the summary, together. 65 66=cut 67 68sub close_test { 69 my $self = shift; 70 71 # Avoid circular references 72 $self->parser(undef); 73 74 my $parser = $self->parser; 75 my $formatter = $self->formatter; 76 my $pretty = $formatter->_format_name( $self->name ); 77 78 return if $formatter->really_quiet; 79 if ( my $skip_all = $parser->skip_all ) { 80 $formatter->_output( $pretty . "skipped: $skip_all\n" ); 81 } 82 elsif ( $parser->has_problems ) { 83 $formatter->_output( 84 $pretty . ( $self->{results} ? "\n" . $self->{results} : "\n" ) ); 85 $self->_output_test_failure($parser); 86 } 87 else { 88 my $time_report = $self->time_report( $formatter, $parser ); 89 $formatter->_output( 90 $pretty . ( $self->{results} ? "\n" . $self->{results} : "" ) ); 91 $formatter->_output_success( $self->_make_ok_line($time_report) ); 92 } 93} 94 951; 96