File Coverage

blib/lib/App/Prove/Plugin/CumulativeTimer.pm
Criterion Covered Total %
statement 33 33 100.0
branch n/a
condition 4 6 66.6
subroutine 9 9 100.0
pod 0 1 0.0
total 46 49 93.8


line stmt bran cond sub pod time code
1             package App::Prove::Plugin::CumulativeTimer;
2 2     2   5621 use 5.008001;
  2         6  
3 2     2   8 use strict;
  2         4  
  2         35  
4 2     2   9 use warnings;
  2         3  
  2         82  
5              
6             our $VERSION = "0.02";
7              
8 2     2   549 use Class::Method::Modifiers qw( around );
  2         2252  
  2         95  
9 2     2   692 use TAP::Parser;
  2         60032  
  2         60  
10 2     2   501 use TAP::Formatter::Session;
  2         1650  
  2         148  
11              
12             sub load {
13 1     1 0 33 my ( $class, $p ) = @_;
14              
15 1         6 $p->{app_prove}->timer(1);
16              
17 1         9 my $first_start_time;
18             my $first_start_times;
19             around 'TAP::Formatter::Session::time_report' => sub {
20 2     2   2710203 my $orig = shift;
21 2         6 my ( $self, $formatter, $parser ) = @_;
22 2   66     13 $first_start_time ||= $parser->start_time;
23 2   66     17 $first_start_times ||= $parser->start_times;
24 2     2   13 no warnings 'redefine';
  2         5  
  2         208  
25 2         27 local *TAP::Parser::start_time = sub {$first_start_time};
  2         27  
26 2         8 local *TAP::Parser::start_times = sub {$first_start_times};
  2         63  
27 2         33 return $orig->(@_);
28 1         9 };
29             }
30              
31             1;
32             __END__