Branch Coverage

blib/lib/File/Write/Rotate.pm
Criterion Covered Total %
branch 97 132 73.4


line true false branch
30 0 278 unless defined($args{'dir'} = delete $args0{'dir'})
32 0 278 unless defined($args{'prefix'} = delete $args0{'prefix'})
38 39 239 if ($args{'period'})
39 0 39 unless $args{'period'} =~ /\A(daily|day|month|monthly|year|yearly)\z/
45 1373 17 unless $args0{$_}
48 0 17 unless ref $args{$_} eq 'CODE'
51 21 218 unless ($args{'period'} or $args{'size'})
62 0 278 unless $args{'lock_mode'} =~ /\A(none|write|exclusive)\z/
66 0 278 if (defined $args{'rotate_probability'})
67 0 0 unless $args{'rotate_probability'} > 0 and $args{'rotate_probability'} < 1
71 0 278 if (keys %args0)
80 1 277 if $self->{'lock_mode'} eq 'exclusive'
87 1 1 if (@_) { }
118 110 691 if ($self->{'period'}) { }
119 13 97 if ($self->{'period'} =~ /year/i) { }
13 84 elsif ($self->{'period'} =~ /month/) { }
84 0 elsif ($self->{'period'} =~ /day|daily/) { }
136 110 691 length $period ? :
137 308 493 if (wantarray) { }
151 4 588 if $self->{'lock_mode'} eq 'none'
152 78 510 if defined $self->{'_weak_lock'}
167 0 98 unless (opendir my $dh, $self->{'dir'})
174 1 462 if $e =~ s/(\.gz)\z//
175 311 152 unless $e =~ /\A\Q$self->{'prefix'}\E (?:\. (?<period>\d{4}(?:-\d\d(?:-\d\d)?)?) )? \Q$self->{'suffix'}\E (?:\. (?<rotate_suffix>\d+) )? \z /x
186 0 57 unless $File::Write::Rotate::a->[2] cmp $File::Write::Rotate::b->[2]
198 0 85 unless my $files = $self->_get_files
205 0 85 if (-f "$self->{'dir'}/$self->{'prefix'}-compress.pid")
211 7 78 if $self->{'hook_before_rotate'}
218 53 32 @$files ? :
232 22 100 if ($i <= @$files - $self->{'histories'})
233 0 22 if $Debug
235 22 0 if (unlink "$dir/$orig$cs") { }
242 48 17 if (not $delete_only and defined $rotating_period and $period eq $rotating_period)
244 14 34 if ($rs) { }
249 48 0 if ($new ne $orig)
250 0 48 if $Debug
252 48 0 if (rename "$dir/$orig$cs", "$dir/$new$cs") { }
262 7 78 if $self->{'hook_after_rotate'}
270 0 298 unless open $self->{'_fh'}, '>>', $fp
271 2 296 if (defined $self->{'binmode'})
272 0 2 if ($self->{'binmode'} eq '1') { }
276 0 2 unless binmode $self->{'_fh'}, $self->{'binmode'}
284 7 291 if $self->{'hook_after_create'}
298 0 0 if ($self->{'rotate_probability'} and $self->{'_fh'})
299 0 0 if rand() > $self->{'rotate_probability'}
303 50 443 unless (-e $fp)
311 219 224 unless ($self->{'_fh'})
316 0 443 if ($self->{'_fp'} ne $fp)
325 437 6 if ($self->{'size'} > 0)
331 28 409 if ($size >= $self->{'size'}) { }
332 0 28 if $Debug
339 0 409 unless @st
345 1 408 if (defined $inode and $finode != $inode)
353 78 415 if $do_rotate
354 79 414 if $do_rotate or $do_open
374 13 480 if $self->{'hook_before_write'}
382 5 488 if ($err)
383 4 1 if (($self->{'buffer_size'} // 0) > @{$self->{'_buffer'};}) { }
395 1 0 @{$self->{'_buffer'};} ? :
413 13 0 if (@{$files_ref;})
423 0 13 if ($pid->alive) { }
431 0 30 if $cs
432 5 5 unless $self->{'period'} or $rs
433 8 17 if $self->{'period'} and $period eq $latest_period
437 13 0 if (@tocompress)
440 0 17 unless (gzip($file, "$file.gz"))