File Coverage

blib/lib/App/autotest/Test/Runner/Result/History.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition 3 3 100.0
subroutine 6 6 100.0
pod 2 2 100.0
total 35 35 100.0


line stmt bran cond sub pod time code
1 4     4   63721 use strict;
  4         5  
  4         126  
2 4     4   16 use warnings;
  4         5  
  4         166  
3              
4             package App::autotest::Test::Runner::Result::History;
5             $App::autotest::Test::Runner::Result::History::VERSION = '0.006';
6             # ABSTRACT: collects test runner results
7              
8 4     4   393 use Moose;
  4         272845  
  4         19  
9 4     4   16991 use App::autotest::Test::Runner::Result;
  4         8  
  4         482  
10              
11             has current_result => ( is => 'rw' );
12             has last_result => ( is => 'rw' );
13              
14              
15             sub perpetuate {
16 14     14 1 2982 my ( $self, $result ) = @_;
17              
18 14 100       513 $self->last_result( $self->current_result ) if $self->current_result;
19 14         504 $self->current_result($result);
20             }
21              
22              
23             sub things_just_got_better {
24 13     13 1 2727 my ( $self ) = @_;
25              
26             # we can't claim 'better' if we have no last result
27 13 100       479 return unless $self->last_result;
28              
29 5         162 my $was_red=$self->last_result->has_failures;
30 5         226 my $is_green=not $self->current_result->has_failures;
31              
32 5   100     96 return $was_red && $is_green;
33             }
34              
35             1;
36              
37             __END__
38              
39             =pod
40              
41             =encoding UTF-8
42              
43             =head1 NAME
44              
45             App::autotest::Test::Runner::Result::History - collects test runner results
46              
47             =head1 VERSION
48              
49             version 0.006
50              
51             =head2 perpetuate ($result)
52              
53             Stores C<$result> as the new current result.
54             Shifts the former current result to the last result.
55              
56             =head2 things_just_got_better
57              
58             Things are better if the last run was red and the current run is green.
59              
60             =head1 AUTHOR
61              
62             Gregor Goldbach <glauschwuffel@nomaden.org>
63              
64             =head1 COPYRIGHT AND LICENSE
65              
66             This software is copyright (c) 2015 by Gregor Goldbach.
67              
68             This is free software; you can redistribute it and/or modify it under
69             the same terms as the Perl 5 programming language system itself.
70              
71             =cut