Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / TAP / Formatter / File / Session.pm
1 package TAP::Formatter::File::Session;
2
3 use strict;
4 use TAP::Formatter::Session;
5
6 use vars qw($VERSION @ISA);
7
8 @ISA = qw(TAP::Formatter::Session);
9
10 =head1 NAME
11
12 TAP::Formatter::File::Session - Harness output delegate for file output
13
14 =head1 VERSION
15
16 Version 3.17
17
18 =cut
19
20 $VERSION = '3.17';
21
22 =head1 DESCRIPTION
23
24 This provides file orientated output formatting for L<TAP::Harness>.
25 It is particularly important when running with parallel tests, as it
26 ensures that test results are not interleaved, even when run
27 verbosely.
28
29 =cut
30
31 =head1 METHODS
32
33 =head2 result
34
35 Stores results for later output, all together.
36
37 =cut
38
39 sub 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
55         && (   $formatter->verbose
56             || ( $result->is_test && $formatter->failures && !$result->is_ok )
57             || ( $formatter->comments   && $result->is_comment )
58             || ( $result->has_directive && $formatter->directives ) )
59       )
60     {
61         $self->{results} .= $self->_format_for_output($result) . "\n";
62     }
63 }
64
65 =head2 close_test
66
67 When the test file finishes, outputs the summary, together.
68
69 =cut
70
71 sub 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
110 1;