| 1 | package App::Prove::State; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use App::Prove::State::Result; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use TAP::Parser::YAMLish::Reader (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use TAP::Parser::YAMLish::Writer (); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use base 'TAP::Base'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | 8 | __PACKAGE__->mk_methods('result_class'); | |||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 8 | ▶ | use constant IS_WIN32 => ( $^O =~ /^(MS)?Win32$/ ); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use constant NEED_GLOB => IS_WIN32; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | App::Prove::State - State storage for the C<prove> command. | ||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | =head1 VERSION | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | Version 3.52 | ||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 8 | our $VERSION = '3.52'; | |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | The C<prove> command supports a C<--state> option that instructs it to | ||||||||||||||||||||||||||||||||||
| 37 | store persistent state across runs. This module implements that state | ||||||||||||||||||||||||||||||||||
| 38 | and the operations that may be performed on it. | ||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||
| 40 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||
| 42 | # Re-run failed tests | ||||||||||||||||||||||||||||||||||
| 43 | $ prove --state=failed,save -rbv | ||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||
| 47 | =head1 METHODS | ||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | =head2 Class Methods | ||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | =head3 C<new> | ||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | Accepts a hashref with the following key/value pairs: | ||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||
| 55 | =over 4 | ||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||
| 57 | =item * C<store> | ||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | The filename of the data store holding the data that App::Prove::State reads. | ||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||
| 61 | =item * C<extensions> (optional) | ||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||
| 63 | The test name extensions. Defaults to C<.t>. | ||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | =item * C<result_class> (optional) | ||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||
| 67 | The name of the C<result_class>. Defaults to C<App::Prove::State::Result>. | ||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||
| 69 | =back | ||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||
| 73 | # override TAP::Base::new: | ||||||||||||||||||||||||||||||||||
| 74 | 75 | ▶ | sub new { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 75 | 75 | my $class = shift; | |||||||||||||||||||||||||||||||||
| 76 | 75 | ▶ | my %args = %{ shift || {} }; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || {}
MC/DC100%1/1
shift() || {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||
| 78 | my $self = bless { | ||||||||||||||||||||||||||||||||||
| 79 | select => [], | ||||||||||||||||||||||||||||||||||
| 80 | seq => 1, | ||||||||||||||||||||||||||||||||||
| 81 | store => delete $args{store}, | ||||||||||||||||||||||||||||||||||
| 82 | extensions => ( delete $args{extensions} || ['.t'] ), | ||||||||||||||||||||||||||||||||||
| 83 | result_class => | ||||||||||||||||||||||||||||||||||
| 84 | 75 | ▶ | ( delete $args{result_class} || 'App::Prove::State::Result' ), | ||||||||||||||||||||||||||||||||
|
Condition50%2/4
delete $args{'extensions'} || ['.t']
delete $args{'result_class'} || 'App::Prove::State::Result'
MC/DC0%0/1
delete $args{'extensions'} || ['.t']
delete $args{'extensions'}
MC/DC0%0/1
delete $args{'result_class'} || 'App::Prove::State::Result'
delete $args{'result_class'}
Truth table50%1/2
A
A= delete $args{'extensions'}
Truth table50%1/2
A
A= delete $args{'result_class'}
| |||||||||||||||||||||||||||||||||||
| 85 | }, $class; | ||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||
| 87 | 75 | $self->{_} = $self->result_class->new( | |||||||||||||||||||||||||||||||||
| 88 | { tests => {}, | ||||||||||||||||||||||||||||||||||
| 89 | generation => 1, | ||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||
| 92 | 75 | my $store = $self->{store}; | |||||||||||||||||||||||||||||||||
| 93 | 75 | ▶ | $self->load($store) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $store and -f $store
MC/DC0%0/2
defined $store and -f $store
defined $store
-f $store
Truth table66%2/3
A and B
A= defined $storeB= -f $store
| |||||||||||||||||||||||||||||||||||
| 94 | if defined $store && -f $store; | ||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||
| 96 | 75 | return $self; | |||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||
| 99 | =head2 C<result_class> | ||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | Getter/setter for the name of the class used for tracking test results. This | ||||||||||||||||||||||||||||||||||
| 102 | class should either subclass from C<App::Prove::State::Result> or provide an | ||||||||||||||||||||||||||||||||||
| 103 | identical interface. | ||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | =cut | ||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | =head2 C<extensions> | ||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||
| 109 | Get or set the list of extensions that files must have in order to be | ||||||||||||||||||||||||||||||||||
| 110 | considered tests. Defaults to ['.t']. | ||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | =cut | ||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | sub extensions { | ||||||||||||||||||||||||||||||||
|
Subroutine
extensions: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 115 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | $self->{extensions} = shift if @_; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 117 | 2 | return $self->{extensions}; | |||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||
| 120 | =head2 C<results> | ||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | Get the results of the last test run. Returns a C<result_class()> instance. | ||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||
| 124 | =cut | ||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | 185 | ▶ | sub results { | ||||||||||||||||||||||||||||||||
|
Subroutine
results: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 127 | 185 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 128 | 185 | ▶ | $self->{_} || $self->result_class->new; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | =head2 C<commit> | ||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | Save the test results. Should be called after all tests have run. | ||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | =cut | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 2 | ▶ | sub commit { | ||||||||||||||||||||||||||||||||
|
Subroutine
commit: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 138 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | if ( $self->{should_save} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->save; | |||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||
| 144 | =head2 Instance Methods | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | =head3 C<apply_switch> | ||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||
| 148 | $self->apply_switch('failed,save'); | ||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||
| 150 | Apply a list of switch options to the state, updating the internal | ||||||||||||||||||||||||||||||||||
| 151 | object state as a result. Nothing is returned. | ||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||
| 153 | Diagnostics: | ||||||||||||||||||||||||||||||||||
| 154 | - "Illegal state option: %s" | ||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||
| 156 | =over | ||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | =item C<last> | ||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||
| 160 | Run in the same order as last time | ||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||
| 162 | =item C<failed> | ||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||
| 164 | Run only the failed tests from last time | ||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | =item C<passed> | ||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||
| 168 | Run only the passed tests from last time | ||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||
| 170 | =item C<all> | ||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||
| 172 | Run all tests in normal order | ||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||
| 174 | =item C<hot> | ||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||
| 176 | Run the tests that most recently failed first | ||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||
| 178 | =item C<todo> | ||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | Run the tests ordered by number of todos. | ||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||
| 182 | =item C<slow> | ||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||
| 184 | Run the tests in slowest to fastest order. | ||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | =item C<fast> | ||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||
| 188 | Run test tests in fastest to slowest order. | ||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | =item C<new> | ||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||
| 192 | Run the tests in newest to oldest order. | ||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | =item C<old> | ||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||
| 196 | Run the tests in oldest to newest order. | ||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | =item C<save> | ||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||
| 200 | Save the state on exit. | ||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||
| 202 | =back | ||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||
| 204 | =cut | ||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||
| 206 | 75 | ▶ | sub apply_switch { | ||||||||||||||||||||||||||||||||
|
Subroutine
apply_switch: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 207 | 75 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 208 | 75 | my @opts = @_; | |||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||
| 210 | 75 | my $last_gen = $self->results->generation - 1; | |||||||||||||||||||||||||||||||||
| 211 | 75 | my $last_run_time = $self->results->last_run_time; | |||||||||||||||||||||||||||||||||
| 212 | 75 | my $now = $self->get_time; | |||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||
| 214 | 75 | my @switches = map { split /,/ } @opts; | |||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||
| 216 | my %handler = ( | ||||||||||||||||||||||||||||||||||
| 217 | 1 | ▶ | last => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 218 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 219 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 220 | 6 | ▶ | where => sub { $_->generation >= $last_gen }, | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 221 | 5 | ▶ | order => sub { $_->sequence } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 222 | 1 | ); | |||||||||||||||||||||||||||||||||
| 223 | }, | ||||||||||||||||||||||||||||||||||
| 224 | 3 | ▶ | failed => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 225 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 226 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 227 | 18 | ▶ | where => sub { $_->result != 0 }, | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 228 | 6 | ▶ | order => sub { -$_->result } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 229 | 3 | ); | |||||||||||||||||||||||||||||||||
| 230 | }, | ||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | passed => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 232 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 233 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 234 | 18 | ▶ | where => sub { $_->result == 0 } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 235 | 3 | ); | |||||||||||||||||||||||||||||||||
| 236 | }, | ||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | all => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 238 | 2 | $self->_select( limit => shift ); | |||||||||||||||||||||||||||||||||
| 239 | }, | ||||||||||||||||||||||||||||||||||
| 240 | 1 | ▶ | todo => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 241 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 242 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 243 | 6 | ▶ | where => sub { $_->num_todo != 0 }, | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 244 | 2 | ▶ | order => sub { -$_->num_todo; } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 245 | 1 | ); | |||||||||||||||||||||||||||||||||
| 246 | }, | ||||||||||||||||||||||||||||||||||
| 247 | 2 | ▶ | hot => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 248 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 249 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 250 | 12 | ▶ | where => sub { defined $_->last_fail_time }, | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 251 | 6 | ▶ | order => sub { $now - $_->last_fail_time } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 252 | 2 | ); | |||||||||||||||||||||||||||||||||
| 253 | }, | ||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | slow => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 255 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 256 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 257 | 6 | ▶ | order => sub { -$_->elapsed } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 258 | 1 | ); | |||||||||||||||||||||||||||||||||
| 259 | }, | ||||||||||||||||||||||||||||||||||
| 260 | 1 | ▶ | fast => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 261 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 262 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 263 | 6 | ▶ | order => sub { $_->elapsed } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 264 | 1 | ); | |||||||||||||||||||||||||||||||||
| 265 | }, | ||||||||||||||||||||||||||||||||||
| 266 | 1 | ▶ | new => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 267 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 268 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 269 | 6 | ▶ | order => sub { -$_->mtime } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 270 | 1 | ); | |||||||||||||||||||||||||||||||||
| 271 | }, | ||||||||||||||||||||||||||||||||||
| 272 | 1 | ▶ | old => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 273 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 274 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 275 | 6 | ▶ | order => sub { $_->mtime } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 276 | 1 | ); | |||||||||||||||||||||||||||||||||
| 277 | }, | ||||||||||||||||||||||||||||||||||
| 278 | 1 | ▶ | fresh => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 279 | $self->_select( | ||||||||||||||||||||||||||||||||||
| 280 | limit => shift, | ||||||||||||||||||||||||||||||||||
| 281 | 6 | ▶ | where => sub { $_->mtime >= $last_run_time } | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 282 | 1 | ); | |||||||||||||||||||||||||||||||||
| 283 | }, | ||||||||||||||||||||||||||||||||||
| 284 | 1 | ▶ | save => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 285 | 1 | $self->{should_save}++; | |||||||||||||||||||||||||||||||||
| 286 | }, | ||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | adrian => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 288 | 1 | unshift @switches, qw( hot all save ); | |||||||||||||||||||||||||||||||||
| 289 | }, | ||||||||||||||||||||||||||||||||||
| 290 | 75 | ); | |||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||
| 292 | 75 | ▶ | while ( defined( my $ele = shift @switches ) ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 293 | 19 | ▶ | my ( $opt, $arg ) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 294 | = ( $ele =~ /^([^:]+):(.*)/ ) | ||||||||||||||||||||||||||||||||||
| 295 | ? ( $1, $2 ) | ||||||||||||||||||||||||||||||||||
| 296 | : ( $ele, undef ); | ||||||||||||||||||||||||||||||||||
| 297 | 19 | ▶ | my $code = $handler{$opt} | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$handler{$opt} || croak("Illegal state option: $opt")
MC/DC0%0/1
$handler{$opt} || croak("Illegal state option: $opt")
$handler{$opt}
Truth table50%1/2
A
A= $handler{$opt}
| |||||||||||||||||||||||||||||||||||
| 298 | || croak "Illegal state option: $opt"; | ||||||||||||||||||||||||||||||||||
| 299 | 19 | $code->($arg); | |||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||
| 301 | 75 | return; | |||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | 17 | ▶ | sub _select { | ||||||||||||||||||||||||||||||||
|
Subroutine
_select: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 305 | 17 | my ( $self, %spec ) = @_; | |||||||||||||||||||||||||||||||||
| 306 | 17 | push @{ $self->{select} }, \%spec; | |||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||
| 309 | =head3 C<get_tests> | ||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||
| 311 | Given a list of args get the names of tests that should run | ||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||
| 313 | =cut | ||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||
| 315 | 75 | ▶ | sub get_tests { | ||||||||||||||||||||||||||||||||
|
Subroutine
get_tests: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 316 | 75 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 317 | 75 | my $recurse = shift; | |||||||||||||||||||||||||||||||||
| 318 | 75 | my @argv = @_; | |||||||||||||||||||||||||||||||||
| 319 | 75 | my %seen; | |||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||
| 321 | 75 | my @selected = $self->_query; | |||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||
| 323 | 75 | ▶ | unless ( @argv || @{ $self->{select} } ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@argv or @{$self->{"select"};}
MC/DC100%2/2
@argv or @{$self->{"select"};}
@argv
@{$self->{"select"};}
Truth table100%3/3
A or B
A= @argvB= @{$self->{"select"};}
| |||||||||||||||||||||||||||||||||||
| 324 | 2 | ▶ | @argv = $recurse ? '.' : 't'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 325 | 2 | ▶ | croak qq{No tests named and '@argv' directory not found} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 326 | unless -d $argv[0]; | ||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||
| 329 | 75 | ▶ | push @selected, $self->_get_raw_tests( $recurse, @argv ) if @argv; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 330 | 75 | return grep { !$seen{$_}++ } @selected; | |||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||
| 333 | 75 | ▶ | sub _query { | ||||||||||||||||||||||||||||||||
|
Subroutine
_query: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||
| 334 | 75 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 335 | 75 | ▶ | if ( my @sel = @{ $self->{select} } ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 336 | 14 | ▶ | warn "No saved state, selection will be empty\n" | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 337 | unless $self->results->num_tests; | ||||||||||||||||||||||||||||||||||
| 338 | 14 | return map { $self->_query_clause($_) } @sel; | |||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||
| 340 | 61 | return; | |||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||
| 343 | 17 | ▶ | sub _query_clause { | ||||||||||||||||||||||||||||||||
|
Subroutine
_query_clause: called CC=11 SCAR=25.2
| |||||||||||||||||||||||||||||||||||
| 344 | 17 | my ( $self, $clause ) = @_; | |||||||||||||||||||||||||||||||||
| 345 | 17 | my @got; | |||||||||||||||||||||||||||||||||
| 346 | 17 | my $results = $self->results; | |||||||||||||||||||||||||||||||||
| 347 | 17 | ▶ | my $where = $clause->{where} || sub {1}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Condition66%2/3
$clause->{'where'} || sub {
1;
}
MC/DC0%0/2
$clause->{'where'} || sub {
1;
}
$clause->{'where'}
sub {
1;
}
Truth table66%2/3
A || B
A= $clause->{'where'}B= sub {
1;
}
| |||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||
| 349 | # Select | ||||||||||||||||||||||||||||||||||
| 350 | 17 | for my $name ( $results->test_names ) { | |||||||||||||||||||||||||||||||||
| 351 | 102 | ▶ | next unless -f $name; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 352 | 102 | local $_ = $results->test($name); | |||||||||||||||||||||||||||||||||
| 353 | 102 | ▶ | push @got, $name if $where->(); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||
| 356 | # Sort | ||||||||||||||||||||||||||||||||||
| 357 | 17 | ▶ | if ( my $order = $clause->{order} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 358 | 43 | @got = map { $_->[0] } | |||||||||||||||||||||||||||||||||
| 359 | sort { | ||||||||||||||||||||||||||||||||||
| 360 | 59 | ▶ | ( defined $b->[1] <=> defined $a->[1] ) | ||||||||||||||||||||||||||||||||
|
Condition57%4/7
defined $App::Prove::State::b->[1] <=> defined $App::Prove::State::a->[1] || ($App::Prove::State::a->[1] || 0) <=> ($App::Prove::State::b->[1] || 0)
$App::Prove::State::a->[1] || 0
$App::Prove::State::b->[1] || 0
MC/DC0%0/2
defined $App::Prove::State::b->[1] <=> defined $App::Prove::State::a->[1] || ($App::Prove::State::a->[1] || 0) <=> ($App::Prove::State::b->[1] || 0)
defined $App::Prove::State::b->[1] <=> defined $App::Prove::State::a->[1]
$App::Prove::State::a->[1]
MC/DC0%0/1
$App::Prove::State::b->[1] || 0
$App::Prove::State::b->[1]
Truth table33%1/3
A || B
A= defined $App::Prove::State::b->[1] <=> defined $App::Prove::State::a->[1]B= $App::Prove::State::a->[1]
Truth table50%1/2
A
A= $App::Prove::State::b->[1]
| |||||||||||||||||||||||||||||||||||
| 361 | || ( ( $a->[1] || 0 ) <=> ( $b->[1] || 0 ) ) | ||||||||||||||||||||||||||||||||||
| 362 | } map { | ||||||||||||||||||||||||||||||||||
| 363 | 11 | [ $_, | |||||||||||||||||||||||||||||||||
| 364 | 43 | do { local $_ = $results->test($_); $order->() } | |||||||||||||||||||||||||||||||||
| 365 | ] | ||||||||||||||||||||||||||||||||||
| 366 | } @got; | ||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | 17 | ▶ | if ( my $limit = $clause->{limit} ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | @got = splice @got, 0, $limit if @got > $limit; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||
| 373 | 17 | return @got; | |||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||
| 376 | 61 | ▶ | sub _get_raw_tests { | ||||||||||||||||||||||||||||||||
|
Subroutine
_get_raw_tests: called CC=6 SCAR=19.6
| |||||||||||||||||||||||||||||||||||
| 377 | 61 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 378 | 61 | my $recurse = shift; | |||||||||||||||||||||||||||||||||
| 379 | 61 | my @argv = @_; | |||||||||||||||||||||||||||||||||
| 380 | 61 | my @tests; | |||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||
| 382 | # Do globbing on Win32. | ||||||||||||||||||||||||||||||||||
| 383 | 61 | ▶ | if (NEED_GLOB) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 384 | 0 | eval "use File::Glob::Windows"; # [49732] | |||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | @argv = map { glob "$_" } @argv; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||
| 387 | 61 | my $extensions = $self->{extensions}; | |||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||
| 389 | 61 | for my $arg (@argv) { | |||||||||||||||||||||||||||||||||
| 390 | 106 | ▶ | if ( '-' eq $arg ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 391 | 0 | push @argv => <STDIN>; | |||||||||||||||||||||||||||||||||
| 392 | 0 | chomp(@argv); | |||||||||||||||||||||||||||||||||
| 393 | 0 | next; | |||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||
| 396 | push @tests, | ||||||||||||||||||||||||||||||||||
| 397 | sort -d $arg | ||||||||||||||||||||||||||||||||||
| 398 | ? $recurse | ||||||||||||||||||||||||||||||||||
| 399 | ? $self->_expand_dir_recursive( $arg, $extensions ) | ||||||||||||||||||||||||||||||||||
| 400 | 3 | : map { glob( File::Spec->catfile( $arg, "*$_" ) ) } | |||||||||||||||||||||||||||||||||
| 401 | 106 | ▶ | @{$extensions} | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 402 | : $arg; | ||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||
| 404 | 61 | return @tests; | |||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub _expand_dir_recursive { | ||||||||||||||||||||||||||||||||
|
Subroutine
_expand_dir_recursive: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 408 | 0 | my ( $self, $dir, $extensions ) = @_; | |||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||
| 410 | 0 | my @tests; | |||||||||||||||||||||||||||||||||
| 411 | 0 | my $ext_string = join( '|', map {quotemeta} @{$extensions} ); | |||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||
| 413 | find( | ||||||||||||||||||||||||||||||||||
| 414 | { follow => 1, #21938 | ||||||||||||||||||||||||||||||||||
| 415 | follow_skip => 2, | ||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | wanted => sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 417 | -f | ||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | && /(?:$ext_string)$/ | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-f $_ and /(?:$ext_string)$/
MC/DC0%0/2
-f $_ and /(?:$ext_string)$/
-f $_
/(?:$ext_string)$/
Truth table0%0/3
A and B
A= -f $_B= /(?:$ext_string)$/
| |||||||||||||||||||||||||||||||||||
| 419 | && push @tests => $File::Find::name; | ||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||
| 421 | }, | ||||||||||||||||||||||||||||||||||
| 422 | 0 | $dir | |||||||||||||||||||||||||||||||||
| 423 | ); | ||||||||||||||||||||||||||||||||||
| 424 | 0 | return @tests; | |||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||
| 427 | =head3 C<observe_test> | ||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||
| 429 | Store the results of a test. | ||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||
| 431 | =cut | ||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | # Store: | ||||||||||||||||||||||||||||||||||
| 434 | # last fail time | ||||||||||||||||||||||||||||||||||
| 435 | # last pass time | ||||||||||||||||||||||||||||||||||
| 436 | # last run time | ||||||||||||||||||||||||||||||||||
| 437 | # most recent result | ||||||||||||||||||||||||||||||||||
| 438 | # most recent todos | ||||||||||||||||||||||||||||||||||
| 439 | # total failures | ||||||||||||||||||||||||||||||||||
| 440 | # total passes | ||||||||||||||||||||||||||||||||||
| 441 | # state generation | ||||||||||||||||||||||||||||||||||
| 442 | # parser | ||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||
| 444 | 2 | ▶ | sub observe_test { | ||||||||||||||||||||||||||||||||
|
Subroutine
observe_test: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||
| 446 | 2 | my ( $self, $test_info, $parser ) = @_; | |||||||||||||||||||||||||||||||||
| 447 | 2 | my $name = $test_info->[0]; | |||||||||||||||||||||||||||||||||
| 448 | 2 | ▶ | my $fail = scalar( $parser->failed ) + ( $parser->has_problems ? 1 : 0 ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 449 | 2 | my $todo = scalar( $parser->todo ); | |||||||||||||||||||||||||||||||||
| 450 | 2 | my $start_time = $parser->start_time; | |||||||||||||||||||||||||||||||||
| 451 | 2 | my $end_time = $parser->end_time, | |||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||
| 453 | my $test = $self->results->test($name); | ||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||
| 455 | 2 | $test->sequence( $self->{seq}++ ); | |||||||||||||||||||||||||||||||||
| 456 | 2 | $test->generation( $self->results->generation ); | |||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||
| 458 | 2 | $test->run_time($end_time); | |||||||||||||||||||||||||||||||||
| 459 | 2 | $test->result($fail); | |||||||||||||||||||||||||||||||||
| 460 | 2 | $test->num_todo($todo); | |||||||||||||||||||||||||||||||||
| 461 | 2 | $test->elapsed( $end_time - $start_time ); | |||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||
| 463 | 2 | $test->parser($parser); | |||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||
| 465 | 2 | ▶ | if ($fail) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 466 | 0 | $test->total_failures( $test->total_failures + 1 ); | |||||||||||||||||||||||||||||||||
| 467 | 0 | $test->last_fail_time($end_time); | |||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||
| 469 | else { | ||||||||||||||||||||||||||||||||||
| 470 | 2 | $test->total_passes( $test->total_passes + 1 ); | |||||||||||||||||||||||||||||||||
| 471 | 2 | $test->last_pass_time($end_time); | |||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||
| 475 | =head3 C<save> | ||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||
| 477 | Write the state to a file. | ||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||
| 479 | =cut | ||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | sub save { | ||||||||||||||||||||||||||||||||
|
Subroutine
save: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 482 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | my $store = $self->{store} or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 485 | 0 | $self->results->last_run_time( $self->get_time ); | |||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||
| 487 | 0 | my $writer = TAP::Parser::YAMLish::Writer->new; | |||||||||||||||||||||||||||||||||
| 488 | 0 | local *FH; | |||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | open FH, ">$store" or croak "Can't write $store ($!)"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 490 | 0 | $writer->write( $self->results->raw, \*FH ); | |||||||||||||||||||||||||||||||||
| 491 | 0 | close FH; | |||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||
| 494 | =head3 C<load> | ||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||
| 496 | Load the state from a file | ||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||
| 498 | =cut | ||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | sub load { | ||||||||||||||||||||||||||||||||
|
Subroutine
load: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 501 | 0 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||
| 502 | 0 | my $reader = TAP::Parser::YAMLish::Reader->new; | |||||||||||||||||||||||||||||||||
| 503 | 0 | local *FH; | |||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | open FH, "<$name" or croak "Can't read $name ($!)"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||
| 506 | # XXX this is temporary | ||||||||||||||||||||||||||||||||||
| 507 | $self->{_} = $self->result_class->new( | ||||||||||||||||||||||||||||||||||
| 508 | $reader->read( | ||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 510 | 0 | my $line = <FH>; | |||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | defined $line && chomp $line; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 512 | 0 | return $line; | |||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||
| 514 | ) | ||||||||||||||||||||||||||||||||||
| 515 | 0 | ); | |||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||
| 517 | # $writer->write( $self->{tests} || {}, \*FH ); | ||||||||||||||||||||||||||||||||||
| 518 | 0 | close FH; | |||||||||||||||||||||||||||||||||
| 519 | 0 | $self->_regen_seq; | |||||||||||||||||||||||||||||||||
| 520 | 0 | $self->_prune_and_stamp; | |||||||||||||||||||||||||||||||||
| 521 | 0 | $self->results->generation( $self->results->generation + 1 ); | |||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | sub _prune_and_stamp { | ||||||||||||||||||||||||||||||||
|
Subroutine
_prune_and_stamp: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||
| 525 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||
| 527 | 0 | my $results = $self->results; | |||||||||||||||||||||||||||||||||
| 528 | 0 | my @tests = $self->results->tests; | |||||||||||||||||||||||||||||||||
| 529 | 0 | for my $test (@tests) { | |||||||||||||||||||||||||||||||||
| 530 | 0 | my $name = $test->name; | |||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if ( my @stat = stat $name ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 532 | 0 | $test->mtime( $stat[9] ); | |||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||
| 534 | else { | ||||||||||||||||||||||||||||||||||
| 535 | 0 | $results->remove($name); | |||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | sub _regen_seq { | ||||||||||||||||||||||||||||||||
|
Subroutine
_regen_seq: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 541 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 542 | 0 | for my $test ( $self->results->tests ) { | |||||||||||||||||||||||||||||||||
| 543 | $self->{seq} = $test->sequence + 1 | ||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | if defined $test->sequence && $test->sequence >= $self->{seq}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $test->sequence and $test->sequence >= $self->{"seq"}
MC/DC0%0/2
defined $test->sequence and $test->sequence >= $self->{"seq"}
defined $test->sequence
$test->sequence >= $self->{"seq"}
Truth table0%0/3
A and B
A= defined $test->sequenceB= $test->sequence >= $self->{"seq"}
| |||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||
| 548 | 8 | 1; | |||||||||||||||||||||||||||||||||