Upgrade to Test-Harness-3.17
[p5sagit/p5-mst-13.2.git] / ext / Test-Harness / lib / TAP / Formatter / File / Session.pm
CommitLineData
bdaf8c65 1package TAP::Formatter::File::Session;
2
3use strict;
4use TAP::Formatter::Session;
5
6use vars qw($VERSION @ISA);
7
8@ISA = qw(TAP::Formatter::Session);
9
10=head1 NAME
11
12TAP::Formatter::File::Session - Harness output delegate for file output
13
14=head1 VERSION
15
a39e16d8 16Version 3.17
bdaf8c65 17
18=cut
19
a39e16d8 20$VERSION = '3.17';
bdaf8c65 21
22=head1 DESCRIPTION
23
24This provides file orientated output formatting for L<TAP::Harness>.
25It is particularly important when running with parallel tests, as it
26ensures that test results are not interleaved, even when run
27verbosely.
28
29=cut
30
31=head1 METHODS
32
33=head2 result
34
35Stores results for later output, all together.
36
37=cut
38
39sub result {
40 my $self = shift;
41 my $result = shift;
42
43 my $parser = $self->parser;
44 my $formatter = $self->formatter;
45
46 if ( $result->is_bailout ) {
47 $formatter->_failure_output(
48 "Bailout called. Further testing stopped: "
49 . $result->explanation
50 . "\n" );
51 return;
52 }
53
54 if (!$formatter->quiet
a39e16d8 55 && ( $formatter->verbose
bdaf8c65 56 || ( $result->is_test && $formatter->failures && !$result->is_ok )
a39e16d8 57 || ( $formatter->comments && $result->is_comment )
bdaf8c65 58 || ( $result->has_directive && $formatter->directives ) )
59 )
60 {
a39e16d8 61 $self->{results} .= $self->_format_for_output($result) . "\n";
bdaf8c65 62 }
63}
64
65=head2 close_test
66
67When the test file finishes, outputs the summary, together.
68
69=cut
70
71sub close_test {
72 my $self = shift;
73
74 # Avoid circular references
75 $self->parser(undef);
76
77 my $parser = $self->parser;
78 my $formatter = $self->formatter;
79 my $pretty = $formatter->_format_name( $self->name );
80
81 return if $formatter->really_quiet;
82 if ( my $skip_all = $parser->skip_all ) {
83 $formatter->_output( $pretty . "skipped: $skip_all\n" );
84 }
85 elsif ( $parser->has_problems ) {
86 $formatter->_output(
87 $pretty . ( $self->{results} ? "\n" . $self->{results} : "\n" ) );
88 $self->_output_test_failure($parser);
89 }
90 else {
91 my $time_report = '';
92 if ( $formatter->timer ) {
93 my $start_time = $parser->start_time;
94 my $end_time = $parser->end_time;
95 if ( defined $start_time and defined $end_time ) {
96 my $elapsed = $end_time - $start_time;
97 $time_report
98 = $self->time_is_hires
99 ? sprintf( ' %8d ms', $elapsed * 1000 )
100 : sprintf( ' %8s s', $elapsed || '<1' );
101 }
102 }
103
104 $formatter->_output( $pretty
105 . ( $self->{results} ? "\n" . $self->{results} : "" )
106 . "ok$time_report\n" );
107 }
108}
109
1101;