| 1 | package DBIx::QuickDB::Pool; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | our $VERSION = '0.000066'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Carp qw/croak/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Fcntl qw/:flock/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use File::Path qw/make_path/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Digest::SHA qw/sha1_hex/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Scalar::Util qw/refaddr/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Time::HiRes qw/time/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use DBIx::QuickDB; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use DBIx::QuickDB::Util qw/remove_tree_robust remove_tree_or_quarantine disconnect_dbi_handles/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use DBIx::QuickDB::Util::HashBase qw{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | +cache_dir | ||||||||||||||||||||||||||||||||||||||||||
| 19 | +instance_dir | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | <library | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | +databases | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | update_checksums | ||||||||||||||||||||||||||||||||||||||||||
| 26 | purge_old | ||||||||||||||||||||||||||||||||||||||||||
| 27 | verbose | ||||||||||||||||||||||||||||||||||||||||||
| 28 | show_diag | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $params{library} ||= caller; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$params{"library"} ||= caller
MC/DC0%0/2
$params{"library"} ||= caller
$params{"library"}
caller
Truth table0%0/3
A ||= B
A= $params{"library"}B= caller
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $inst = $class->new(%params); | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $inst->export(); | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=10 SCAR=27.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | croak "'cache_dir' is a required_attribute" unless $self->{+CACHE_DIR}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | croak "'cache_dir' must point to an existing directory" | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | unless -d $self->{+CACHE_DIR}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | croak "'$self->{+INSTANCE_DIR}' must be an existing directory" | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | ▶ | if $self->{+INSTANCE_DIR} && !-d $self->{+INSTANCE_DIR}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"instance_dir"} and not -d $self->{"instance_dir"}
MC/DC0%0/2
$self->{"instance_dir"} and not -d $self->{"instance_dir"}
$self->{"instance_dir"}
not -d $self->{"instance_dir"}
Truth table33%1/3
A and not(B)
A= $self->{"instance_dir"}B= not -d $self->{"instance_dir"}
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | $self->{+LIBRARY} //= caller(1); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"library"} //= caller 1
MC/DC0%0/2
$self->{"library"} //= caller 1
$self->{"library"}
caller 1
Truth table33%1/3
A //= B
A= $self->{"library"}B= caller 1
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | ▶ | $self->{+VERBOSE} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"verbose"} //= 0
MC/DC0%0/1
$self->{"verbose"} //= 0
$self->{"verbose"}
Truth table50%1/2
A
A= $self->{"verbose"}
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | $self->{+PURGE_OLD} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"purge_old"} //= 0
MC/DC0%0/1
$self->{"purge_old"} //= 0
$self->{"purge_old"}
Truth table50%1/2
A
A= $self->{"purge_old"}
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | ▶ | $self->{+UPDATE_CHECKSUMS} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"update_checksums"} //= 1
MC/DC0%0/1
$self->{"update_checksums"} //= 1
$self->{"update_checksums"}
Truth table50%1/2
A
A= $self->{"update_checksums"}
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | $self->{+DATABASES} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"databases"} //= {}
MC/DC0%0/1
$self->{"databases"} //= {}
$self->{"databases"}
Truth table50%1/2
A
A= $self->{"databases"}
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | # Remove a disposable database tree, or move it out of the canonical cache path | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # when Windows still refuses the removal after retries. Returning true means the | ||||||||||||||||||||||||||||||||||||||||||
| 64 | # canonical path is clear and safe to rebuild; clear_old_cache() reclaims the | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # quarantine on a later pass, and it can never be mistaken for a valid entry. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 3 | ▶ | sub _remove_or_quarantine { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_remove_or_quarantine: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | my ($self, $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my $stale = remove_tree_or_quarantine($dir); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 3 | ▶ | return 0 unless defined $stale; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | ▶ | $self->diag("$$ Quarantined stale database directory '$dir' as '$stale'") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | if length $stale; | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | ▶ | sub clear_old_cache { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_old_cache: called CC=15 SCAR=27.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | my ($age) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | my $dir = $self->{+CACHE_DIR}; | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | opendir(my $dh, $dir) or die "Could not open cache dir '$dir': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | for my $name (readdir($dh)) { | |||||||||||||||||||||||||||||||||||||||||
| 85 | 8 | my $full = "$dir/$name"; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | # Quarantines sit outside the canonical cache path (see | ||||||||||||||||||||||||||||||||||||||||||
| 88 | # _remove_or_quarantine). Retry their removal on every pass: the | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # transient Windows file lock that blocked deletion may have cleared. | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 8 | ▶ | if ($name =~ m/\.STALE-/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | remove_tree_robust($full) if -d $full; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | # A live cache entry is a bare directory name. Its marker files | ||||||||||||||||||||||||||||||||||||||||||
| 96 | # ("$name.lock", "$name.READY") do contain dots and are handled | ||||||||||||||||||||||||||||||||||||||||||
| 97 | # through their entry, never scanned directly. | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 7 | ▶ | next if $name =~ m/\./; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 3 | ▶ | next unless -d $full; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 3 | my $file = "$full/cloned"; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 3 | ▶ | next unless -f $file; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 2 | ▶ | open(my $fh, '<', $file) or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | my $stamp = <$fh>; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | ▶ | $stamp = '' unless defined $stamp; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | chomp($stamp); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | # Time::HiRes values written by older releases can contain a decimal | ||||||||||||||||||||||||||||||||||||||||||
| 112 | # comma under the Windows process locale (for example 1785633742,27439). | ||||||||||||||||||||||||||||||||||||||||||
| 113 | # Cache expiry needs only whole seconds, so accept either historical | ||||||||||||||||||||||||||||||||||||||||||
| 114 | # fractional spelling and reduce it to a locale-independent integer. A | ||||||||||||||||||||||||||||||||||||||||||
| 115 | # damaged stamp is treated as infinitely old so it is reclaimed rather | ||||||||||||||||||||||||||||||||||||||||||
| 116 | # than pinning an unusable clone in the cache forever. | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | $stamp =~ s/[.,]\d+\z//; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | $stamp = 0 unless $stamp =~ /^\d+\z/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | next unless $age <= (time - $stamp); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | eval { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | # An expired SQLite source may still have DBI handles retained by | ||||||||||||||||||||||||||||||||||||||||||
| 124 | # application/test code. On Windows those handles prevent unlinking | ||||||||||||||||||||||||||||||||||||||||||
| 125 | # the database file. Close every matching handle before removal. | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | disconnect_dbi_handles($full); | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # If removal remains blocked, moving the tree out of its canonical | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # path keeps a later build from seeing partially-removed SQLite | ||||||||||||||||||||||||||||||||||||||||||
| 130 | # schema/data. Either way, invalidate the external markers: expiry | ||||||||||||||||||||||||||||||||||||||||||
| 131 | # was explicitly requested, and build_db() will refuse to build on | ||||||||||||||||||||||||||||||||||||||||||
| 132 | # any stubborn tree that could not be quarantined. | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | $self->_remove_or_quarantine($full); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | unlink("$full.lock") if -e "$full.lock"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | ▶ | unlink("$full.READY") if -e "$full.READY"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } or warn $@; | ||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub export { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
export: not called CC=1 SCAR=5.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $library = $self->{+LIBRARY}; | |||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $qdb = sub { $self }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | my $build = sub { $self->add_db(@_, caller => [caller()]) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my $db = sub { $self->fetch_db(@_, caller => [caller()]) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my $driver = sub { $self->add_driver(@_, caller => [caller()]) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | *{"$library\::QDB_POOL"} = $qdb; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | *{"$library\::driver"} = $driver; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | *{"$library\::build"} = $build; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | *{"$library\::db"} = $db; | |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | push @{"$library\::EXPORT_OK"} => 'db'; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub throw { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
throw: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my ($msg, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my $caller = $params{caller} || [caller(1)]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params{'caller'} || [caller 1]
MC/DC0%0/1
$params{'caller'} || [caller 1]
$params{'caller'}
Truth table0%0/2
A
A= $params{'caller'}
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | die "$msg at $caller->[1] line $caller->[2].\n"; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub alert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
alert: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | my ($msg, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | my $caller = $params{caller} || [caller(1)]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params{'caller'} || [caller 1]
MC/DC0%0/1
$params{'caller'} || [caller 1]
$params{'caller'}
Truth table0%0/2
A
A= $params{'caller'}
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | warn "$msg at $caller->[1] line $caller->[2].\n"; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | ▶ | sub diag { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag: called CC=5 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | my ($msg, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | my $show = $self->{+VERBOSE} || $self->{+SHOW_DIAG}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'verbose'} || $self->{'show_diag'}
MC/DC0%0/2
$self->{'verbose'} || $self->{'show_diag'}
$self->{'verbose'}
$self->{'show_diag'}
Truth table33%1/3
A || B
A= $self->{'verbose'}B= $self->{'show_diag'}
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | return unless $show; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | # Only append caller info when asked | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if (my $caller = $params{caller}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $msg .= " at $caller->[1] line $caller->[2]."; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | if ($show > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | print STDERR "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | print STDOUT "$msg\n"; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub add_db { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_db: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my ($name, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $from = $params{from} or $self->throw("You must specify a 'from' database", %params); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | my $from_spec = $self->{+DATABASES}->{$from} or $self->throw("Cannot build '$name' from '$from' which has not been defined"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | $self->throw("Database '$name' is already defined", %params) | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if $self->{+DATABASES}->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | $self->throw("'build' is a required argument", %params) | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | unless $params{build}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | $self->throw("'$params{build}' is not a valid builder, it must be either a coderef, or a class method on '$self->{+LIBRARY}'", %params) | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | unless ref($params{build}) eq 'CODE' || $self->{+LIBRARY}->can($params{build}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $params{"build"} eq "CODE" or $self->{"library"}->can($params{"build"})
MC/DC0%0/2
ref $params{"build"} eq "CODE" or $self->{"library"}->can($params{"build"})
ref $params{"build"} eq "CODE"
$self->{"library"}->can($params{"build"})
Truth table0%0/3
A or B
A= ref $params{"build"} eq "CODE"B= $self->{"library"}->can($params{"build"})
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | $self->throw("A checksum sub or method name is required") | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | unless $params{checksum}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | unless (ref($params{checksum}) eq 'CODE' || $self->{+LIBRARY}->can($params{checksum})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $params{"checksum"} eq "CODE" or $self->{"library"}->can($params{"checksum"})
MC/DC0%0/2
ref $params{"checksum"} eq "CODE" or $self->{"library"}->can($params{"checksum"})
ref $params{"checksum"} eq "CODE"
$self->{"library"}->can($params{"checksum"})
Truth table0%0/3
A or B
A= ref $params{"checksum"} eq "CODE"B= $self->{"library"}->can($params{"checksum"})
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $self->throw( | |||||||||||||||||||||||||||||||||||||||||
| 216 | "'$params{checksum}' is not a valid checksum calculator, it must be either a coderef or a class method on '$self->{+LIBRARY}'", | ||||||||||||||||||||||||||||||||||||||||||
| 217 | %params, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->{+DATABASES}->{$name} = {%params, name => $name, driver => $from_spec->{driver}}; | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | sub add_driver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_driver: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my ($driver, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $name = $params{name}; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | unless ($name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $name = $driver; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $name =~ s/^.*:://g; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $params{name} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | $self->throw("Database '$name' is already defined", %params) | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if $self->{+DATABASES}->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | $driver = "DBIx::QuickDB::Driver::$driver" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$driver =~ s/^\+// or $driver =~ /^DBIx::QuickDB::Driver::/
MC/DC0%0/2
$driver =~ s/^\+// or $driver =~ /^DBIx::QuickDB::Driver::/
$driver =~ s/^\+//
$driver =~ /^DBIx::QuickDB::Driver::/
Truth table0%0/3
A or B
A= $driver =~ s/^\+//B= $driver =~ /^DBIx::QuickDB::Driver::/
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | unless $driver =~ s/^\+// || $driver =~ m/^DBIx::QuickDB::Driver::/; | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $file = $driver; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $file =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $file .= ".pm"; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | eval { require $file; 1 } or $self->throw("Could not load driver '$driver': $@", %params); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my ($viable, $why_not) = $driver->viable({bootstrap => 1, autostart => 1, load_sql => 1}); | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $self->throw("Driver '$driver' is not viable:\n$why_not\n") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | unless $viable; | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $params{driver} = $driver; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $params{checksum} //= \&driver_checksum; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params{"checksum"} //= \&DBIx::QuickDB::Pool::driver_checksum
MC/DC0%0/1
$params{"checksum"} //= \&DBIx::QuickDB::Pool::driver_checksum
$params{"checksum"}
Truth table0%0/2
A
A= $params{"checksum"}
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | unless (ref($params{checksum}) eq 'CODE' || $self->{+LIBRARY}->can($params{checksum})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $params{"checksum"} eq "CODE" or $self->{"library"}->can($params{"checksum"})
MC/DC0%0/2
ref $params{"checksum"} eq "CODE" or $self->{"library"}->can($params{"checksum"})
ref $params{"checksum"} eq "CODE"
$self->{"library"}->can($params{"checksum"})
Truth table0%0/3
A or B
A= ref $params{"checksum"} eq "CODE"B= $self->{"library"}->can($params{"checksum"})
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $self->throw( | |||||||||||||||||||||||||||||||||||||||||
| 257 | "'$params{checksum}' is not a valid checksum calculator, it must be either a coderef or a class method on '$self->{+LIBRARY}'", | ||||||||||||||||||||||||||||||||||||||||||
| 258 | %params, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $self->{+DATABASES}->{$name} = \%params; | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 25 | ▶ | sub instance_dir_user { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
instance_dir_user: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 25 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 25 | ▶ | my $user = $ENV{USER} // $ENV{USERNAME} // 'quickdb'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
($ENV{"USER"} // $ENV{"USERNAME"}) // "quickdb"
$ENV{"USER"} // $ENV{"USERNAME"}
MC/DC100%2/2
($ENV{"USER"} // $ENV{"USERNAME"}) // "quickdb"
$ENV{"USER"}
$ENV{"USERNAME"}
Truth table100%3/3
A // B
A= $ENV{"USER"}B= $ENV{"USERNAME"}
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | # A '/' would send tempdir looking for a subdir that does not exist. Real | ||||||||||||||||||||||||||||||||||||||||||
| 273 | # logins that hit this: 'jdoe@corp.example.com', 'DOMAIN\jdoe'. | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 25 | $user =~ s/[^\w.-]+/_/g; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 25 | ▶ | $user = 'quickdb' unless length $user; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | # The instance dir must hold a unix socket, and sun_path caps at 107 bytes. | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 25 | ▶ | $user = substr($user, 0, 12) if length($user) > 12; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 25 | return $user; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub fetch_db { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fetch_db: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my ($name, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my $spec = $self->{+DATABASES}->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | $self->throw("Invalid database name: $name", %params) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | unless $spec; | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | delete $params{caller}; | |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $from = $self->vivify_db($spec); | |||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my %add_args; | |||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if (my $dir = $self->{+INSTANCE_DIR}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | require File::Temp; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $user = $self->instance_dir_user; | |||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | # $$ because File::Temp draws names from rand(): identically-seeded | ||||||||||||||||||||||||||||||||||||||||||
| 302 | # processes walk the same sequence and recycle freed names, and two of | ||||||||||||||||||||||||||||||||||||||||||
| 303 | # them copying into one dir corrupts the clone. Only 6 X's -- the pid | ||||||||||||||||||||||||||||||||||||||||||
| 304 | # does the work, and the name competes for the 107-byte socket budget. | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $add_args{dir} = File::Temp::tempdir("$user-$$-XXXXXX", CLEANUP => 0, DIR => $dir); | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | return $from->clone(autostart => 1, autostop => 1, cleanup => 1, %add_args, %{$spec->{clone_args} || {}}, %params); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$spec->{'clone_args'} || {}
MC/DC0%0/1
$spec->{'clone_args'} || {}
$spec->{'clone_args'}
Truth table0%0/2
A
A= $spec->{'clone_args'}
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub vivify_db { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vivify_db: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my ($spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my ($db, $csum) = $self->cache_check($spec); | |||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | return $db if $db; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $spec->{built_checksum} = $csum; | |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $dir = "$self->{+CACHE_DIR}/$spec->{name}-$csum"; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $spec->{dir} = $dir; | |||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | # Already built, we can use it. | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if (-e "$dir.READY") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $self->diag("$$ Found existing '$spec->{name}' database at '$dir'..."); | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | return $spec->{db} = $self->reclaim($dir => $spec); | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $lock = "$dir.lock"; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | my $lock_fh = $self->lock($lock); | |||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | # Another process got the lock first and built the db, start the loop over to build it. | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | if (-e "$dir.READY") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | # Unlock immedietly to unblock other processes | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $self->unlock($lock_fh, $lock); | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $self->diag("$$ Previous lock holder built the '$spec->{name}' db..."); | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $db = $self->reclaim($dir => $spec); | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $db = $self->build_db($dir => $spec, stop => 1); | |||||||||||||||||||||||||||||||||||||||||
| 341 | # Unlock AFTER building | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $self->unlock($lock_fh, $lock); | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | $db->stop() if $db->started; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | return $spec->{db} = $db; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | sub cache_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_check: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my ($spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | # If we do not have 'update_checksums' set then we do not re-check every time. | ||||||||||||||||||||||||||||||||||||||||||
| 355 | return ($spec->{db}, $spec->{built_checksum}) | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if $spec->{db} && $spec->{built_checksum} && !$self->{+UPDATE_CHECKSUMS}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$spec->{"db"} and $spec->{"built_checksum"} and not $self->{"update_checksums"}
$spec->{"db"} and $spec->{"built_checksum"}
MC/DC0%0/3
$spec->{"db"} and $spec->{"built_checksum"} and not $self->{"update_checksums"}
$spec->{"db"}
$spec->{"built_checksum"}
not $self->{"update_checksums"}
Truth table0%0/4
A and B and not(C)
A= $spec->{"db"}B= $spec->{"built_checksum"}C= not $self->{"update_checksums"}
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $valid = 1; | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | my $meth = $spec->{checksum} or die "Database '$spec->{name}' has no checksum method"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $csum = $self->{+LIBRARY}->$meth(name => $spec->{name}, qdb => $self, spec => $spec); | |||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $parent_changed = 0; | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if (my $from = $spec->{from}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my ($parent, $psum) = $self->cache_check($self->{+DATABASES}->{$from}); | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | unless ($parent) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $parent_changed = 1; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $valid = 0; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | # Composite checksum | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $self->diag("$$ Combining checksums from '$spec->{name}': '$csum' and parent '$from': '$psum'..."); | |||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $csum = sha1_hex("$psum$csum"); | |||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $self->diag("$$ Combined checksum from '$spec->{name}' and parent '$from': '$csum'."); | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | # shorten the checksum to 10 characters for shorter dir names | ||||||||||||||||||||||||||||||||||||||||||
| 380 | # This is mainly because unix sockets have a max filename of 107 bites. | ||||||||||||||||||||||||||||||||||||||||||
| 381 | # Sometimes the temp dir + other temp dirs before our socket make the | ||||||||||||||||||||||||||||||||||||||||||
| 382 | # length too much. | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $csum = substr($csum, 0, 10); | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $old = $spec->{built_checksum}; | |||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | $valid &&= $old; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$valid &&= $old
MC/DC0%0/2
$valid &&= $old
$valid
$old
Truth table0%0/3
A &&= B
A= $validB= $old
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $valid &&= $spec->{db} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$valid &&= $spec->{"db"} ? 1 : 0
MC/DC0%0/2
$valid &&= $spec->{"db"} ? 1 : 0
$valid
$spec->{"db"} ? 1 : 0
Truth table0%0/3
A &&= B
A= $validB= $spec->{"db"} ? 1 : 0
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | $valid &&= $old eq $csum; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$valid &&= $old eq $csum
MC/DC0%0/2
$valid &&= $old eq $csum
$valid
$old eq $csum
Truth table0%0/3
A &&= B
A= $validB= $old eq $csum
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | $valid &&= !$parent_changed; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$valid &&= !$parent_changed
MC/DC0%0/2
$valid &&= !$parent_changed
$valid
!$parent_changed
Truth table0%0/3
A &&= not(B)
A= $validB= !$parent_changed
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | return ($spec->{db}, $csum) if $valid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | $self->diag("$$ Invalidated '$spec->{name}' due to " . ($parent_changed ? 'parent' : 'checksum') . " change...") | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if $old || $spec->{db}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$old or $spec->{"db"}
MC/DC0%0/2
$old or $spec->{"db"}
$old
$spec->{"db"}
Truth table0%0/3
A or B
A= $oldB= $spec->{"db"}
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | delete $spec->{db}; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | delete $spec->{built_checksum}; | |||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | remove_tree_robust($spec->{dir}) if $self->{+PURGE_OLD}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | delete $spec->{dir}; | |||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | return (undef, $csum); | |||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | ▶ | sub build_db { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_db: called CC=7 SCAR=28.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | my ($dir, $spec, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | # Create the dir, deleting it if it exists. Close retained DBI handles first | ||||||||||||||||||||||||||||||||||||||||||
| 412 | # (essential for SQLite on Windows). If removal still fails, quarantine the | ||||||||||||||||||||||||||||||||||||||||||
| 413 | # entire stale tree before rebuilding. We must never continue in the old | ||||||||||||||||||||||||||||||||||||||||||
| 414 | # directory: doing so feeds stale schema/data to the builder and turns the | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # cleanup problem into misleading errors such as "table already exists". | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | ▶ | if (-d $dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 1 | disconnect_dbi_handles($dir); | |||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | ▶ | unless ($self->_remove_or_quarantine($dir)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my $error = "$!"; | |||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | $error = 'unknown operating-system error' unless length $error; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $self->throw("Could not remove or quarantine stale database directory '$dir': $error"); | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | make_path($dir); | |||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | $spec->{dir} = $dir; | |||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | my $db; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | ▶ | if ($spec->{from}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | $db = $self->build_via_clone($dir, $spec); | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | $db = $self->build_via_driver($dir, $spec); | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | $db->stop if $params{stop}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | $self->diag("$$ Built new db '$spec->{name}', marking as ready!"); | |||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | open(my $ready, '>', "$dir.READY") or die "Could not create ready file '$dir.READY': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | print $ready "1\n"; | |||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | close($ready); | |||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | return $db; | |||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | sub build_via_clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_via_clone: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | my ($dir, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $self->diag("$$ Building new db '$spec->{name}' from existing db '$spec->{from}'..."); | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $from_spec = $self->{+DATABASES}->{$spec->{from}}; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $from = $self->vivify_db($from_spec); | |||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $self->write_clone_stamp($from); | |||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $spec->{driver} = $from_spec->{driver}; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | $spec->{driver_args} //= $from_spec->{driver_args}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$spec->{"driver_args"} //= $from_spec->{"driver_args"}
MC/DC0%0/2
$spec->{"driver_args"} //= $from_spec->{"driver_args"}
$spec->{"driver_args"}
$from_spec->{"driver_args"}
Truth table0%0/3
A //= B
A= $spec->{"driver_args"}B= $from_spec->{"driver_args"}
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | $spec->{clone_args} //= $from_spec->{clone_args}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$spec->{"clone_args"} //= $from_spec->{"clone_args"}
MC/DC0%0/2
$spec->{"clone_args"} //= $from_spec->{"clone_args"}
$spec->{"clone_args"}
$from_spec->{"clone_args"}
Truth table0%0/3
A //= B
A= $spec->{"clone_args"}B= $from_spec->{"clone_args"}
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | my $db = $from->clone(%{$spec->{clone_args} || {}}, dir => $dir, autostart => 0, autostop => 1, verbose => $self->{+VERBOSE}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$spec->{'clone_args'} || {}
MC/DC0%0/1
$spec->{'clone_args'} || {}
$spec->{'clone_args'}
Truth table0%0/2
A
A= $spec->{'clone_args'}
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $db->start(); | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $builder = $spec->{build}; | |||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $self->{+LIBRARY}->$builder($db, name => $spec->{name}, dir => $dir, qdb => $self); | |||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | return $db; | |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | sub build_via_driver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_via_driver: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my ($dir, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $self->diag("$$ Building new base db '$spec->{name}'..."); | |||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | my $db = $spec->{driver}->new( | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | %{$spec->{driver_args} || {}}, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$spec->{'driver_args'} || {}
MC/DC0%0/1
$spec->{'driver_args'} || {}
$spec->{'driver_args'}
Truth table0%0/2
A
A= $spec->{'driver_args'}
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | dir => $dir, | ||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | verbose => $self->{+VERBOSE}, | |||||||||||||||||||||||||||||||||||||||||
| 480 | autostart => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 481 | autostop => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 482 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $db->bootstrap(); | |||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if (my $builder = $spec->{build}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $db->start(); | |||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | $self->{+LIBRARY}->$builder($db, name => $spec->{name}, dir => $dir, qdb => $self); | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | $self->write_clone_stamp($db); | |||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | return $db; | |||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | sub write_clone_stamp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_clone_stamp: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | my ($db) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | # Preserve subsecond resolution (callers use it to detect rapid successive | ||||||||||||||||||||||||||||||||||||||||||
| 501 | # clones), but make the serialized decimal separator locale-independent. | ||||||||||||||||||||||||||||||||||||||||||
| 502 | # Stringifying Time::HiRes::time on Windows may otherwise produce a comma. | ||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $stamp = '' . time(); | |||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $stamp =~ tr/,/./; | |||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | open(my $fh, '>', $db->dir . '/cloned') or die "$!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | print $fh $stamp, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | return $stamp; | |||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | sub unlock { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlock: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my ($lock_fh, $lock) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $self->diag("$$ Releasing lock '$lock'..."); | |||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | flock($lock_fh, LOCK_UN) or die "Could not unlock '$lock': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | close($lock_fh); | |||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | sub lock { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lock: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my ($lock) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | open(my $lh, '>>', $lock) or die "Could not open lock file '$lock': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $self->diag("$$ Acquiring lock '$lock'..."); | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | flock($lh, LOCK_EX) or die "Could not get lock '$lock': $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $self->diag("$$ Lock acquired '$lock'..."); | |||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | seek($lh, 0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | return $lh; | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | sub reclaim { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reclaim: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my ($dir, $spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | return $spec->{driver}->new( | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | %{$spec->{driver_args} || {}}, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$spec->{'driver_args'} || {}
MC/DC0%0/1
$spec->{'driver_args'} || {}
$spec->{'driver_args'}
Truth table0%0/2
A
A= $spec->{'driver_args'}
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | dir => $dir, | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | verbose => $self->{+VERBOSE}, | |||||||||||||||||||||||||||||||||||||||||
| 545 | autostart => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 546 | autostop => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 547 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | sub driver_checksum { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
driver_checksum: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | my $library = shift; | |||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $spec = $params{spec}; | |||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $version = $spec->{driver}->version_string($spec->{driver_args}); | |||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | return sha1_hex($version); | |||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | __END__ | ||||||||||||||||||||||||||||||||||||||||||