| 1 | package Test2::IPC::Driver::Files; | ||||||||||||||||||||||||||||||||||
| 2 | 102 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 3 | 102 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 102 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 102 | ▶ | BEGIN { require Test2::IPC::Driver; our @ISA = qw(Test2::IPC::Driver) } | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||
| 9 | 102 | ▶ | use Test2::Util::HashBase qw{tempdir event_ids read_ids timeouts tid pid globals}; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 102 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 102 | ▶ | use File::Temp(); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | 102 | ▶ | use Storable(); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 14 | 102 | ▶ | use File::Spec(); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 15 | 102 | ▶ | use POSIX(); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 102 | ▶ | use Test2::Util qw/try get_tid pkg_to_file IS_WIN32 ipc_separator do_rename do_unlink/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | 102 | ▶ | use Test2::Util::Sig qw/try_sig_mask/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 19 | 102 | ▶ | use Test2::API qw/test2_ipc_set_pending/; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | 128 | ▶ | sub is_viable { 1 } | ||||||||||||||||||||||||||||||||
|
Subroutine
is_viable: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | 271 | ▶ | sub init { | ||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 24 | 271 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||
| 26 | my $tmpdir = File::Temp::tempdir( | ||||||||||||||||||||||||||||||||||
| 27 | 271 | ▶ | $ENV{T2_TEMPDIR_TEMPLATE} || "test2" . ipc_separator . $$ . ipc_separator . "XXXXXX", | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'T2_TEMPDIR_TEMPLATE'} || 'test2~' . $$ . '~' . 'XXXXXX'
MC/DC0%0/1
$ENV{'T2_TEMPDIR_TEMPLATE'} || 'test2~' . $$ . '~' . 'XXXXXX'
$ENV{'T2_TEMPDIR_TEMPLATE'}
Truth table50%1/2
A
A= $ENV{'T2_TEMPDIR_TEMPLATE'}
| |||||||||||||||||||||||||||||||||||
| 28 | CLEANUP => 0, | ||||||||||||||||||||||||||||||||||
| 29 | TMPDIR => 1, | ||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 271 | ▶ | $self->abort_trace("Could not get a temp dir") unless $tmpdir; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | 271 | $self->{+TEMPDIR} = File::Spec->canonpath($tmpdir); | |||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||
| 36 | print STDERR "\nIPC Temp Dir: $tmpdir\n\n" | ||||||||||||||||||||||||||||||||||
| 37 | 271 | ▶ | if $ENV{T2_KEEP_TEMPDIR}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | 271 | $self->{+EVENT_IDS} = {}; | |||||||||||||||||||||||||||||||||
| 40 | 271 | $self->{+READ_IDS} = {}; | |||||||||||||||||||||||||||||||||
| 41 | 271 | $self->{+TIMEOUTS} = {}; | |||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 271 | $self->{+TID} = get_tid(); | |||||||||||||||||||||||||||||||||
| 44 | 271 | $self->{+PID} = $$; | |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||
| 46 | 271 | $self->{+GLOBALS} = {}; | |||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||
| 48 | 271 | return $self; | |||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||
| 51 | 1619 | ▶ | sub hub_file { | ||||||||||||||||||||||||||||||||
|
Subroutine
hub_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 52 | 1619 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 53 | 1619 | my ($hid) = @_; | |||||||||||||||||||||||||||||||||
| 54 | 1619 | my $tdir = $self->{+TEMPDIR}; | |||||||||||||||||||||||||||||||||
| 55 | 1619 | return File::Spec->catfile($tdir, "HUB" . ipc_separator . $hid); | |||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | 228 | ▶ | sub event_file { | ||||||||||||||||||||||||||||||||
|
Subroutine
event_file: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 59 | 228 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 60 | 228 | my ($hid, $e) = @_; | |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | 228 | my $tempdir = $self->{+TEMPDIR}; | |||||||||||||||||||||||||||||||||
| 63 | 228 | ▶ | my $type = blessed($e) or $self->abort("'$e' is not a blessed object!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||
| 65 | 227 | ▶ | $self->abort("'$e' is not an event object!") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 66 | unless $type->isa('Test2::Event'); | ||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | 226 | my $tid = get_tid(); | |||||||||||||||||||||||||||||||||
| 69 | 226 | my $eid = $self->{+EVENT_IDS}->{$hid}->{$$}->{$tid} += 1; | |||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | 226 | my @type = split '::', $type; | |||||||||||||||||||||||||||||||||
| 72 | 226 | my $name = join(ipc_separator, $hid, $$, $tid, $eid, @type); | |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||
| 74 | 226 | return File::Spec->catfile($tempdir, $name); | |||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | 811 | ▶ | sub add_hub { | ||||||||||||||||||||||||||||||||
|
Subroutine
add_hub: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 78 | 811 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 79 | 811 | my ($hid) = @_; | |||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | 811 | my $hfile = $self->hub_file($hid); | |||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | 811 | ▶ | $self->abort_trace("File for hub '$hid' already exists") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 84 | if -e $hfile; | ||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||
| 86 | 810 | ▶ | open(my $fh, '>', $hfile) or $self->abort_trace("Could not create hub file '$hid': $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 87 | 810 | ▶ | print $fh "$$\n" . get_tid() . "\n" or $self->abort_trace("Could not write hub file '$hid': $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 88 | 810 | ▶ | close($fh) or $self->abort_trace("Could not write hub file '$hid': $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||
| 91 | 578 | ▶ | sub drop_hub { | ||||||||||||||||||||||||||||||||
|
Subroutine
drop_hub: called CC=19 SCAR=31.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 92 | 578 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 93 | 578 | my ($hid) = @_; | |||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | 578 | my $tdir = $self->{+TEMPDIR}; | |||||||||||||||||||||||||||||||||
| 96 | 578 | my $hfile = $self->hub_file($hid); | |||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | 578 | ▶ | $self->abort_trace("File for hub '$hid' does not exist") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 99 | unless -e $hfile; | ||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||
| 101 | 577 | ▶ | open(my $fh, '<', $hfile) or $self->abort_trace("Could not open hub file '$hid': $!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 102 | 577 | my ($pid, $tid) = <$fh>; | |||||||||||||||||||||||||||||||||
| 103 | 577 | close($fh); | |||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||
| 105 | 577 | ▶ | $self->abort_trace("File for hub '$hid' is empty or truncated, it was not fully written when the hub was created") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $pid and defined $tid
MC/DC50%1/2
defined $pid and defined $tid
defined $pid
defined $tid
Truth table66%2/3
A and B
A= defined $pidB= defined $tid
| |||||||||||||||||||||||||||||||||||
| 106 | unless defined($pid) && defined($tid); | ||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | 576 | ▶ | $self->abort_trace("A hub file can only be closed by the process that started it\nExpected $pid, got $$") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 109 | unless $pid == $$; | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | 576 | ▶ | $self->abort_trace("A hub file can only be closed by the thread that started it\nExpected $tid, got " . get_tid()) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 112 | unless get_tid() == $tid; | ||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||
| 114 | 576 | ▶ | if ($ENV{T2_KEEP_TEMPDIR}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 115 | 1 | my ($ok, $err) = do_rename($hfile, File::Spec->canonpath("$hfile.complete")); | |||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | $self->abort_trace("Could not rename file '$hfile' -> '$hfile.complete': $err") unless $ok | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||
| 118 | else { | ||||||||||||||||||||||||||||||||||
| 119 | 575 | my ($ok, $err) = do_unlink($hfile); | |||||||||||||||||||||||||||||||||
| 120 | 575 | ▶ | $self->abort_trace("Could not remove file for hub '$hid': $err") unless $ok | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||
| 123 | 576 | ▶ | opendir(my $dh, $tdir) or $self->abort_trace("Could not open temp dir!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | 576 | my %bad; | |||||||||||||||||||||||||||||||||
| 126 | 576 | for my $file (readdir($dh)) { | |||||||||||||||||||||||||||||||||
| 127 | 2746 | ▶ | next if $file =~ m{\.complete$}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 128 | 2744 | ▶ | next unless $file =~ m{^$hid}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | 1 | ▶ | eval { $bad{$file} = $self->read_event_file(File::Spec->catfile($tdir, $file)); 1 } or $bad{$file} = $@ || "Unknown error reading file"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$@ || 'Unknown error reading file'
MC/DC0%0/1
$@ || 'Unknown error reading file'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||
| 132 | 576 | closedir($dh); | |||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||
| 134 | 576 | ▶ | return unless keys %bad; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||
| 136 | 1 | my $data; | |||||||||||||||||||||||||||||||||
| 137 | 1 | my $ok = eval { | |||||||||||||||||||||||||||||||||
| 138 | 1 | require JSON::PP; | |||||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | local *UNIVERSAL::TO_JSON = sub { +{ %{$_[0]} } }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 140 | 1 | my $json = JSON::PP->new->ascii->pretty->canonical->allow_unknown->allow_blessed->convert_blessed; | |||||||||||||||||||||||||||||||||
| 141 | 1 | $data = $json->encode(\%bad); | |||||||||||||||||||||||||||||||||
| 142 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | $ok ||= eval { | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ok ||= eval {
do {
require Data::Dumper;
local $Data::Dumper::Sortkeys = 1;
$data = Data::Dumper::Dumper(\%bad);
1
}
}
MC/DC0%0/2
$ok ||= eval {
do {
require Data::Dumper;
local $Data::Dumper::Sortkeys = 1;
$data = Data::Dumper::Dumper(\%bad);
1
}
}
$ok
eval {
do {
require Data::Dumper;
local $Data::Dumper::Sortkeys = 1;
$data = Data::Dumper::Dumper(\%bad);
1
}
}
Truth table33%1/3
A ||= B
A= $okB= eval {
do {
require Data::Dumper;
local $Data::Dumper::Sortkeys = 1;
$data = Data::Dumper::Dumper(\%bad);
1
}
}
| |||||||||||||||||||||||||||||||||||
| 145 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||
| 146 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||
| 147 | 0 | $data = Data::Dumper::Dumper(\%bad); | |||||||||||||||||||||||||||||||||
| 148 | 0 | 1; | |||||||||||||||||||||||||||||||||
| 149 | }; | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | $data = "Could not dump data... sorry." unless defined $data; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||
| 153 | 1 | $self->abort_trace("Not all files from hub '$hid' have been collected!\nHere is the leftover data:\n========================\n$data\n===================\n"); | |||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||
| 156 | 229 | ▶ | sub send { | ||||||||||||||||||||||||||||||||
|
Subroutine
send: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 157 | 229 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 158 | 229 | my ($hid, $e, $global) = @_; | |||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||
| 160 | 229 | my $tempdir = $self->{+TEMPDIR}; | |||||||||||||||||||||||||||||||||
| 161 | 229 | my $hfile = $self->hub_file($hid); | |||||||||||||||||||||||||||||||||
| 162 | 229 | ▶ | my $dest = $global ? 'GLOBAL' : $hid; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||
| 164 | 229 | ▶ | $self->abort(<<" EOT") unless $global || -f $hfile; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$global or -f $hfile
MC/DC100%2/2
$global or -f $hfile
$global
-f $hfile
Truth table100%3/3
A or B
A= $globalB= -f $hfile
| |||||||||||||||||||||||||||||||||||
| 165 | hub '$hid' is not available, failed to send event! | ||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||
| 167 | There was an attempt to send an event to a hub in a parent process or thread, | ||||||||||||||||||||||||||||||||||
| 168 | but that hub appears to be gone. This can happen if you fork, or start a new | ||||||||||||||||||||||||||||||||||
| 169 | thread from inside subtest, and the parent finishes the subtest before the | ||||||||||||||||||||||||||||||||||
| 170 | child returns. | ||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||
| 172 | This can also happen if the parent process is done testing before the child | ||||||||||||||||||||||||||||||||||
| 173 | finishes. Test2 normally waits automatically in the root process, but will not | ||||||||||||||||||||||||||||||||||
| 174 | do so if Test::Builder is loaded for legacy reasons. | ||||||||||||||||||||||||||||||||||
| 175 | EOT | ||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||
| 177 | 228 | my $file = $self->event_file($dest, $e); | |||||||||||||||||||||||||||||||||
| 178 | 226 | my $ready = File::Spec->canonpath("$file.ready"); | |||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||
| 180 | 226 | ▶ | if ($global) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 181 | 45 | my $name = $ready; | |||||||||||||||||||||||||||||||||
| 182 | 45 | $name =~ s{^.*(GLOBAL)}{GLOBAL}; | |||||||||||||||||||||||||||||||||
| 183 | 45 | $self->{+GLOBALS}->{$hid}->{$name}++; | |||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | # Write and rename the file. | ||||||||||||||||||||||||||||||||||
| 187 | 226 | my ($ren_ok, $ren_err); | |||||||||||||||||||||||||||||||||
| 188 | 226 | ▶ | my ($ok, $err) = try_sig_mask(sub { | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 189 | 226 | Storable::store($e, $file); | |||||||||||||||||||||||||||||||||
| 190 | 225 | ($ren_ok, $ren_err) = do_rename("$file", $ready); | |||||||||||||||||||||||||||||||||
| 191 | 226 | }); | |||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||
| 193 | 226 | ▶ | if ($ok) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 194 | 225 | ▶ | $self->abort("Could not rename file '$file' -> '$ready': $ren_err") unless $ren_ok; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 195 | 225 | test2_ipc_set_pending($file); | |||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||
| 197 | else { | ||||||||||||||||||||||||||||||||||
| 198 | 1 | my $src_file = __FILE__; | |||||||||||||||||||||||||||||||||
| 199 | 1 | $err =~ s{ at \Q$src_file\E.*$}{}; | |||||||||||||||||||||||||||||||||
| 200 | 1 | chomp($err); | |||||||||||||||||||||||||||||||||
| 201 | 1 | my $tid = get_tid(); | |||||||||||||||||||||||||||||||||
| 202 | 1 | my $trace = $e->trace->debug; | |||||||||||||||||||||||||||||||||
| 203 | 1 | my $type = blessed($e); | |||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||
| 205 | 1 | $self->abort(<<" EOT"); | |||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | ******************************************************************************* | ||||||||||||||||||||||||||||||||||
| 208 | There was an error writing an event: | ||||||||||||||||||||||||||||||||||
| 209 | Destination: $dest | ||||||||||||||||||||||||||||||||||
| 210 | Origin PID: $$ | ||||||||||||||||||||||||||||||||||
| 211 | Origin TID: $tid | ||||||||||||||||||||||||||||||||||
| 212 | Event Type: $type | ||||||||||||||||||||||||||||||||||
| 213 | Event Trace: $trace | ||||||||||||||||||||||||||||||||||
| 214 | File Name: $file | ||||||||||||||||||||||||||||||||||
| 215 | Ready Name: $ready | ||||||||||||||||||||||||||||||||||
| 216 | Error: $err | ||||||||||||||||||||||||||||||||||
| 217 | ******************************************************************************* | ||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||
| 219 | EOT | ||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | 225 | return 1; | |||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | sub driver_abort { | ||||||||||||||||||||||||||||||||
|
Subroutine
driver_abort: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 226 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 227 | 0 | my ($msg) = @_; | |||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | 0 | local ($@, $!, $?, $^E); | |||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | eval { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 231 | 0 | my $abort = File::Spec->catfile($self->{+TEMPDIR}, "ABORT"); | |||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | open(my $fh, '>>', $abort) or die "Could not open abort file: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 233 | 0 | print $fh $msg, "\n"; | |||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | close($fh) or die "Could not close abort file: $!"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 235 | 0 | 1; | |||||||||||||||||||||||||||||||||
| 236 | } or warn $@; | ||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||
| 239 | 4538 | ▶ | sub cull { | ||||||||||||||||||||||||||||||||
|
Subroutine
cull: called CC=12 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 240 | 4538 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 241 | 4538 | my ($hid) = @_; | |||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | 4538 | my $tempdir = $self->{+TEMPDIR}; | |||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||
| 245 | 4538 | ▶ | opendir(my $dh, $tempdir) or $self->abort("could not open IPC temp dir ($tempdir)!"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||
| 247 | 4538 | my $read = $self->{+READ_IDS}; | |||||||||||||||||||||||||||||||||
| 248 | 4538 | my $timeouts = $self->{+TIMEOUTS}; | |||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||
| 250 | 4538 | my @out; | |||||||||||||||||||||||||||||||||
| 251 | 4538 | for my $info (sort cmp_events map { $self->should_read_event($hid, $_) } readdir($dh)) { | |||||||||||||||||||||||||||||||||
| 252 | 713 | ▶ | unless ($info->{global}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 253 | 696 | ▶ | my $next = $self->{+READ_IDS}->{$info->{hid}}->{$info->{pid}}->{$info->{tid}} ||= 1; | ||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"read_ids"}{$info->{"hid"}}{$info->{"pid"}}{$info->{"tid"}} ||= 1
MC/DC100%1/1
$self->{"read_ids"}{$info->{"hid"}}{$info->{"pid"}}{$info->{"tid"}} ||= 1
$self->{"read_ids"}{$info->{"hid"}}{$info->{"pid"}}{$info->{"tid"}}
Truth table100%2/2
A
A= $self->{"read_ids"}{$info->{"hid"}}{$info->{"pid"}}{$info->{"tid"}}
| |||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||
| 255 | 696 | ▶ | $timeouts->{$info->{file}} ||= time; | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$timeouts{$info->{"file"}} ||= time
MC/DC0%0/1
$$timeouts{$info->{"file"}} ||= time
$$timeouts{$info->{"file"}}
Truth table50%1/2
A
A= $$timeouts{$info->{"file"}}
| |||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||
| 257 | 696 | ▶ | if ($next != $info->{eid}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 258 | # Wait up to N seconds for missing events | ||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | next unless 5 < time - $timeouts->{$info->{file}}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 260 | 0 | $self->abort("Missing event HID: $info->{hid}, PID: $info->{pid}, TID: $info->{tid}, EID: $info->{eid}."); | |||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||
| 263 | 696 | $self->{+READ_IDS}->{$info->{hid}}->{$info->{pid}}->{$info->{tid}} = $info->{eid} + 1; | |||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||
| 266 | 713 | my $full = $info->{full_path}; | |||||||||||||||||||||||||||||||||
| 267 | 713 | my $obj = $self->read_event_file($full); | |||||||||||||||||||||||||||||||||
| 268 | 713 | push @out => $obj; | |||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||
| 270 | # Do not remove global events | ||||||||||||||||||||||||||||||||||
| 271 | 713 | ▶ | next if $info->{global}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||
| 273 | 696 | ▶ | if ($ENV{T2_KEEP_TEMPDIR}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 274 | 1 | my $complete = File::Spec->canonpath("$full.complete"); | |||||||||||||||||||||||||||||||||
| 275 | 1 | my ($ok, $err) = do_rename($full, $complete); | |||||||||||||||||||||||||||||||||
| 276 | 1 | ▶ | $self->abort("Could not rename IPC file '$full', '$complete': $err") unless $ok; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||
| 278 | else { | ||||||||||||||||||||||||||||||||||
| 279 | 695 | my ($ok, $err) = do_unlink("$full"); | |||||||||||||||||||||||||||||||||
| 280 | 695 | ▶ | $self->abort("Could not unlink IPC file '$full': $err") unless $ok; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||
| 284 | 4538 | closedir($dh); | |||||||||||||||||||||||||||||||||
| 285 | 4538 | return @out; | |||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||
| 288 | 4039 | ▶ | sub parse_event_filename { | ||||||||||||||||||||||||||||||||
|
Subroutine
parse_event_filename: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 289 | 4039 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 290 | 4039 | my ($file) = @_; | |||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||
| 292 | # The || is to force 0 in false | ||||||||||||||||||||||||||||||||||
| 293 | 4039 | ▶ | my $complete = substr($file, -9, 9) eq '.complete' || 0 and substr($file, -9, 9, ""); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
substr($file, -9, 9) eq '.complete' || 0
MC/DC100%1/1
substr($file, -9, 9) eq '.complete' || 0
substr($file, -9, 9) eq '.complete'
Truth table100%2/2
A
A= substr($file, -9, 9) eq '.complete'
| |||||||||||||||||||||||||||||||||||
| 294 | 4039 | ▶ | my $ready = substr($file, -6, 6) eq '.ready' || 0 and substr($file, -6, 6, ""); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
substr($file, -6, 6) eq '.ready' || 0
MC/DC100%1/1
substr($file, -6, 6) eq '.ready' || 0
substr($file, -6, 6) eq '.ready'
Truth table100%2/2
A
A= substr($file, -6, 6) eq '.ready'
| |||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||
| 296 | 4039 | my @parts = split ipc_separator, $file; | |||||||||||||||||||||||||||||||||
| 297 | 4039 | ▶ | my ($global, $hid) = $parts[0] eq 'GLOBAL' ? (1, shift @parts) : (0, join ipc_separator, splice(@parts, 0, 4)); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 298 | 4039 | my ($pid, $tid, $eid) = splice(@parts, 0, 3); | |||||||||||||||||||||||||||||||||
| 299 | 4039 | my $type = join '::' => @parts; | |||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||
| 301 | return { | ||||||||||||||||||||||||||||||||||
| 302 | 4039 | file => $file, | |||||||||||||||||||||||||||||||||
| 303 | ready => !!$ready, | ||||||||||||||||||||||||||||||||||
| 304 | complete => !!$complete, | ||||||||||||||||||||||||||||||||||
| 305 | global => $global, | ||||||||||||||||||||||||||||||||||
| 306 | type => $type, | ||||||||||||||||||||||||||||||||||
| 307 | hid => $hid, | ||||||||||||||||||||||||||||||||||
| 308 | pid => $pid, | ||||||||||||||||||||||||||||||||||
| 309 | tid => $tid, | ||||||||||||||||||||||||||||||||||
| 310 | eid => $eid, | ||||||||||||||||||||||||||||||||||
| 311 | }; | ||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||
| 314 | 28191 | ▶ | sub should_read_event { | ||||||||||||||||||||||||||||||||
|
Subroutine
should_read_event: called CC=11 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 315 | 28191 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 316 | 28191 | my ($hid, $file) = @_; | |||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||
| 318 | 28191 | ▶ | return if substr($file, 0, 1) eq '.'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 319 | 19115 | ▶ | return if substr($file, 0, 3) eq 'HUB'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 320 | 4032 | ▶ | CORE::exit(255) if $file eq 'ABORT'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||
| 322 | 4032 | my $parsed = $self->parse_event_filename($file); | |||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||
| 324 | 4032 | ▶ | return if $parsed->{complete}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 325 | 4029 | ▶ | return unless $parsed->{ready}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 326 | 3983 | ▶ | return unless $parsed->{global} || $parsed->{hid} eq $hid; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$parsed->{"global"} or $parsed->{"hid"} eq $hid
MC/DC100%2/2
$parsed->{"global"} or $parsed->{"hid"} eq $hid
$parsed->{"global"}
$parsed->{"hid"} eq $hid
Truth table100%3/3
A or B
A= $parsed->{"global"}B= $parsed->{"hid"} eq $hid
| |||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||
| 328 | 805 | ▶ | return if $parsed->{global} && $self->{+GLOBALS}->{$hid}->{$file}++; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$parsed->{"global"} and $self->{"globals"}{$hid}{$file}++
MC/DC100%2/2
$parsed->{"global"} and $self->{"globals"}{$hid}{$file}++
$parsed->{"global"}
$self->{"globals"}{$hid}{$file}++
Truth table100%3/3
A and B
A= $parsed->{"global"}B= $self->{"globals"}{$hid}{$file}++
| |||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||
| 330 | # Untaint the path. | ||||||||||||||||||||||||||||||||||
| 331 | 717 | my $full = File::Spec->catfile($self->{+TEMPDIR}, $file); | |||||||||||||||||||||||||||||||||
| 332 | 717 | ▶ | ($full) = ($full =~ m/^(.*)$/gs) if ${^TAINT}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | 717 | $parsed->{full_path} = $full; | |||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||
| 336 | 717 | return $parsed; | |||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||
| 339 | 586 | ▶ | sub cmp_events { | ||||||||||||||||||||||||||||||||
|
Subroutine
cmp_events: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 340 | # Globals first | ||||||||||||||||||||||||||||||||||
| 341 | 586 | ▶ | return -1 if $a->{global} && !$b->{global}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Test2::IPC::Driver::Files::a->{"global"} and not $Test2::IPC::Driver::Files::b->{"global"}
MC/DC100%2/2
$Test2::IPC::Driver::Files::a->{"global"} and not $Test2::IPC::Driver::Files::b->{"global"}
$Test2::IPC::Driver::Files::a->{"global"}
not $Test2::IPC::Driver::Files::b->{"global"}
Truth table100%3/3
A and not(B)
A= $Test2::IPC::Driver::Files::a->{"global"}B= not $Test2::IPC::Driver::Files::b->{"global"}
| |||||||||||||||||||||||||||||||||||
| 342 | 579 | ▶ | return 1 if $b->{global} && !$a->{global}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$Test2::IPC::Driver::Files::b->{"global"} and not $Test2::IPC::Driver::Files::a->{"global"}
MC/DC100%2/2
$Test2::IPC::Driver::Files::b->{"global"} and not $Test2::IPC::Driver::Files::a->{"global"}
$Test2::IPC::Driver::Files::b->{"global"}
not $Test2::IPC::Driver::Files::a->{"global"}
Truth table100%3/3
A and not(B)
A= $Test2::IPC::Driver::Files::b->{"global"}B= not $Test2::IPC::Driver::Files::a->{"global"}
| |||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||
| 344 | return $a->{pid} <=> $b->{pid} | ||||||||||||||||||||||||||||||||||
| 345 | || $a->{tid} <=> $b->{tid} | ||||||||||||||||||||||||||||||||||
| 346 | 575 | ▶ | || $a->{eid} <=> $b->{eid}; | ||||||||||||||||||||||||||||||||
|
Condition83%5/6
$Test2::IPC::Driver::Files::a->{'pid'} <=> $Test2::IPC::Driver::Files::b->{'pid'} || $Test2::IPC::Driver::Files::a->{'tid'} <=> $Test2::IPC::Driver::Files::b->{'tid'} || $Test2::IPC::Driver::Files::a->{'eid'} <=> $Test2::IPC::Driver::Files::b->{'eid'}
$Test2::IPC::Driver::Files::a->{"pid"} <=> $Test2::IPC::Driver::Files::b->{"pid"} or $Test2::IPC::Driver::Files::a->{"tid"} <=> $Test2::IPC::Driver::Files::b->{"tid"}
MC/DC0%0/3
$Test2::IPC::Driver::Files::a->{'pid'} <=> $Test2::IPC::Driver::Files::b->{'pid'} || $Test2::IPC::Driver::Files::a->{'tid'} <=> $Test2::IPC::Driver::Files::b->{'tid'} || $Test2::IPC::Driver::Files::a->{'eid'} <=> $Test2::IPC::Driver::Files::b->{'eid'}
$Test2::IPC::Driver::Files::a->{"pid"} <=> $Test2::IPC::Driver::Files::b->{"pid"}
$Test2::IPC::Driver::Files::a->{"tid"} <=> $Test2::IPC::Driver::Files::b->{"tid"}
$Test2::IPC::Driver::Files::a->{'eid'} <=> $Test2::IPC::Driver::Files::b->{'eid'}
Truth table75%3/4
A or B || C
A= $Test2::IPC::Driver::Files::a->{"pid"} <=> $Test2::IPC::Driver::Files::b->{"pid"}B= $Test2::IPC::Driver::Files::a->{"tid"} <=> $Test2::IPC::Driver::Files::b->{"tid"}C= $Test2::IPC::Driver::Files::a->{'eid'} <=> $Test2::IPC::Driver::Files::b->{'eid'}
| |||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||
| 349 | 718 | ▶ | sub read_event_file { | ||||||||||||||||||||||||||||||||
|
Subroutine
read_event_file: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 350 | 718 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 351 | 718 | my ($file) = @_; | |||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||
| 353 | 718 | my $obj = Storable::retrieve($file); | |||||||||||||||||||||||||||||||||
| 354 | 718 | ▶ | $self->abort("Got an unblessed object: '$obj'") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 355 | unless blessed($obj); | ||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||
| 357 | 717 | ▶ | unless ($obj->isa('Test2::Event')) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 358 | 2 | my $pkg = blessed($obj); | |||||||||||||||||||||||||||||||||
| 359 | 2 | my $mod_file = pkg_to_file($pkg); | |||||||||||||||||||||||||||||||||
| 360 | 2 | ▶ | my ($ok, $err) = try { require $mod_file }; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||
| 362 | 2 | ▶ | $self->abort("Event has unknown type ($pkg), tried to load '$mod_file' but failed: $err") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 363 | unless $ok; | ||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | $self->abort("'$obj' is not a 'Test2::Event' object") | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 366 | unless $obj->isa('Test2::Event'); | ||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||
| 369 | 715 | return $obj; | |||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||
| 372 | 42 | ▶ | sub waiting { | ||||||||||||||||||||||||||||||||
|
Subroutine
waiting: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 373 | 42 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 374 | 42 | require Test2::Event::Waiting; | |||||||||||||||||||||||||||||||||
| 375 | 42 | $self->send( | |||||||||||||||||||||||||||||||||
| 376 | GLOBAL => Test2::Event::Waiting->new( | ||||||||||||||||||||||||||||||||||
| 377 | trace => Test2::EventFacet::Trace->new(frame => [caller()]), | ||||||||||||||||||||||||||||||||||
| 378 | ), | ||||||||||||||||||||||||||||||||||
| 379 | 'GLOBAL' | ||||||||||||||||||||||||||||||||||
| 380 | ); | ||||||||||||||||||||||||||||||||||
| 381 | 42 | return; | |||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||
| 384 | 171 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=18 SCAR=29.6
| |||||||||||||||||||||||||||||||||||
| 385 | 171 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||
| 387 | 171 | ▶ | return unless defined $self->pid; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 388 | 170 | ▶ | return unless defined $self->tid; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||
| 390 | 169 | ▶ | return unless $$ == $self->pid; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 391 | 167 | ▶ | return unless get_tid() == $self->tid; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||
| 393 | 166 | my $tempdir = $self->{+TEMPDIR}; | |||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||
| 395 | 166 | my $aborted = 0; | |||||||||||||||||||||||||||||||||
| 396 | 166 | my $abort_file = File::Spec->catfile($self->{+TEMPDIR}, "ABORT"); | |||||||||||||||||||||||||||||||||
| 397 | 166 | ▶ | if (-e $abort_file) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 398 | 0 | $aborted = 1; | |||||||||||||||||||||||||||||||||
| 399 | 0 | my ($ok, $err) = do_unlink($abort_file); | |||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | warn $err unless $ok; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||
| 403 | 166 | ▶ | opendir(my $dh, $tempdir) or $self->abort("Could not open temp dir! ($tempdir)"); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 404 | 166 | ▶ | while(my $file = readdir($dh)) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 405 | 340 | ▶ | next if $file =~ m/^\.+$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 406 | 8 | ▶ | next if $file =~ m/\.complete$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 407 | 6 | my $full = File::Spec->catfile($tempdir, $file); | |||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||
| 409 | 6 | my $sep = ipc_separator; | |||||||||||||||||||||||||||||||||
| 410 | 6 | ▶ | if ($aborted || $file =~ m/^(GLOBAL|HUB$sep)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$aborted or $file =~ /^(GLOBAL|HUB$sep)/
MC/DC50%1/2
$aborted or $file =~ /^(GLOBAL|HUB$sep)/
$aborted
$file =~ /^(GLOBAL|HUB$sep)/
Truth table66%2/3
A or B
A= $abortedB= $file =~ /^(GLOBAL|HUB$sep)/
| |||||||||||||||||||||||||||||||||||
| 411 | 5 | $full =~ m/^(.*)$/; | |||||||||||||||||||||||||||||||||
| 412 | 5 | $full = $1; # Untaint it | |||||||||||||||||||||||||||||||||
| 413 | 5 | ▶ | next if $ENV{T2_KEEP_TEMPDIR}; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 414 | 4 | my ($ok, $err) = do_unlink($full); | |||||||||||||||||||||||||||||||||
| 415 | 4 | ▶ | $self->abort("Could not unlink IPC file '$full': $err") unless $ok; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 416 | 4 | next; | |||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||
| 419 | 1 | $self->abort("Leftover files in the directory ($full)!\n"); | |||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||
| 421 | 165 | closedir($dh); | |||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||
| 423 | 165 | ▶ | if ($ENV{T2_KEEP_TEMPDIR}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 424 | 1 | print STDERR "# Not removing temp dir: $tempdir\n"; | |||||||||||||||||||||||||||||||||
| 425 | 1 | return; | |||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||
| 428 | 164 | my $abort = File::Spec->catfile($self->{+TEMPDIR}, "ABORT"); | |||||||||||||||||||||||||||||||||
| 429 | 164 | ▶ | unlink($abort) if -e $abort; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 430 | 164 | ▶ | rmdir($tempdir) or warn "Could not remove IPC temp dir ($tempdir)"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | 102 | 1; | |||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||
| 435 | __END__ | ||||||||||||||||||||||||||||||||||