| 1 | package Test2::API::Instance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 463 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 458 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 455 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 455 | our @CARP_NOT = qw/Test2::API Test2::API::Instance Test2::IPC::Driver Test2::Formatter/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 455 | ▶ | use Carp qw/confess carp/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 455 | ▶ | use Scalar::Util qw/reftype/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 455 | ▶ | use Test2::Util qw/get_tid USE_THREADS CAN_FORK pkg_to_file try/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 455 | ▶ | use Test2::EventFacet::Trace(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 455 | ▶ | use Test2::API::Stack(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 455 | ▶ | use Test2::Util::HashBase qw{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | _pid _tid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | no_wait | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | finalized loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ipc stack formatter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | contexts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | add_uuid_via | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | -preload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ipc_disabled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ipc_polling | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | ipc_drivers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ipc_timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | formatters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | exit_callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | post_load_callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | context_acquire_callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | context_init_callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | context_release_callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | pre_subtest_callbacks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | trace_stamps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 455 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | sub DEFAULT_IPC_TIMEOUT() { 30 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | sub test2_enable_trace_stamps { $_[0]->{+TRACE_STAMPS} = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test2_enable_trace_stamps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | sub test2_disable_trace_stamps { $_[0]->{+TRACE_STAMPS} = 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test2_disable_trace_stamps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub test2_trace_stamps_enabled { $_[0]->{+TRACE_STAMPS} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test2_trace_stamps_enabled: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 382 | ▶ | sub pid { $_[0]->{+_PID} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 358 | ▶ | sub tid { $_[0]->{+_TID} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # Wrap around the getters that should call _finalize. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 455 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 455 | for my $finalizer (IPC, FORMATTER) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 910 | my $orig = __PACKAGE__->can($finalizer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1987 | ▶ | my $new = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1987 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1987 | ▶ | $self->_finalize unless $self->{+FINALIZED}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1981 | $self->$orig; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 910 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 455 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 455 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 910 | *{$finalizer} = $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 330 | ▶ | sub has_ipc { !!$_[0]->{+IPC} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_ipc: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 553 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 553 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 553 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 455 | my ($ref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 455 | $$ref = $class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 507 | ▶ | sub init { $_[0]->reset } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub start_preload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_preload: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | confess "preload cannot be started, Test2::API has already been initialized" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | if $self->{+FINALIZED} || $self->{+LOADED}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"finalized"} or $self->{"loaded"}
MC/DC0%0/2
$self->{"finalized"} or $self->{"loaded"}
$self->{"finalized"}
$self->{"loaded"}
Truth table33%1/3
A or B
A= $self->{"finalized"}B= $self->{"loaded"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | return $self->{+PRELOAD} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | ▶ | sub stop_preload { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stop_preload: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | return 0 unless $self->{+PRELOAD}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | $self->{+PRELOAD} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | $self->post_preload_reset(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | ▶ | sub post_preload_reset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post_preload_reset: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | delete $self->{+_PID}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | delete $self->{+_TID}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | $self->{+ADD_UUID_VIA} = undef unless exists $self->{+ADD_UUID_VIA}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | $self->{+CONTEXTS} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | $self->{+FORMATTERS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | $self->{+FINALIZED} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | $self->{+IPC} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | $self->{+IPC_DISABLED} = $ENV{T2_NO_IPC} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | $self->{+IPC_TIMEOUT} = DEFAULT_IPC_TIMEOUT() unless defined $self->{+IPC_TIMEOUT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | $self->{+LOADED} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | $self->{+STACK} ||= Test2::API::Stack->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"stack"} ||= "Test2::API::Stack"->new
MC/DC0%0/2
$self->{"stack"} ||= "Test2::API::Stack"->new
$self->{"stack"}
"Test2::API::Stack"->new
Truth table33%1/3
A ||= B
A= $self->{"stack"}B= "Test2::API::Stack"->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 564 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 564 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 564 | delete $self->{+_PID}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 564 | delete $self->{+_TID}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 564 | ▶ | $self->{+TRACE_STAMPS} = $ENV{T2_TRACE_STAMPS} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'T2_TRACE_STAMPS'} || 0
MC/DC0%0/1
$ENV{'T2_TRACE_STAMPS'} || 0
$ENV{'T2_TRACE_STAMPS'}
Truth table50%1/2
A
A= $ENV{'T2_TRACE_STAMPS'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 564 | $self->{+ADD_UUID_VIA} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 564 | $self->{+CONTEXTS} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 564 | $self->{+IPC_DRIVERS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 564 | $self->{+IPC_POLLING} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 564 | $self->{+FORMATTERS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 564 | $self->{+FORMATTER} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 564 | $self->{+FINALIZED} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 564 | $self->{+IPC} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 564 | ▶ | $self->{+IPC_DISABLED} = $ENV{T2_NO_IPC} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 564 | ▶ | $self->{+IPC_TIMEOUT} = DEFAULT_IPC_TIMEOUT() unless defined $self->{+IPC_TIMEOUT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 564 | $self->{+NO_WAIT} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 564 | $self->{+LOADED} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 564 | $self->{+EXIT_CALLBACKS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 564 | $self->{+POST_LOAD_CALLBACKS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 564 | $self->{+CONTEXT_ACQUIRE_CALLBACKS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 564 | $self->{+CONTEXT_INIT_CALLBACKS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 564 | $self->{+CONTEXT_RELEASE_CALLBACKS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 564 | $self->{+PRE_SUBTEST_CALLBACKS} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 564 | $self->{+STACK} = Test2::API::Stack->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 493 | ▶ | sub _finalize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finalize: called CC=22 SCAR=31.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 493 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 493 | my ($caller) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 493 | ▶ | $caller ||= [caller(1)]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$caller ||= [caller 1]
MC/DC0%0/1
$caller ||= [caller 1]
$caller
Truth table50%1/2
A
A= $caller
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | confess "Attempt to initialize Test2::API during preload" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 493 | ▶ | if $self->{+PRELOAD}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 493 | $self->{+FINALIZED} = $caller; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 493 | ▶ | $self->{+_PID} = $$ unless defined $self->{+_PID}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 493 | ▶ | $self->{+_TID} = get_tid() unless defined $self->{+_TID}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 493 | ▶ | unless ($self->{+FORMATTER}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 488 | my ($formatter, $source); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 488 | ▶ | if ($ENV{T2_FORMATTER}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 34 | $source = "set by the 'T2_FORMATTER' environment variable"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 34 | ▶ | if ($ENV{T2_FORMATTER} =~ m/^(\+)?(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 34 | ▶ | $formatter = $1 ? $2 : "Test2::Formatter::$2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $formatter = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 454 | elsif (@{$self->{+FORMATTERS}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 179 | ($formatter) = @{$self->{+FORMATTERS}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 179 | $source = "Most recently added"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 275 | $formatter = 'Test2::Formatter::TAP'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 275 | $source = 'default formatter'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 488 | ▶ | unless (ref($formatter) || $formatter->can('write')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $formatter or $formatter->can("write")
MC/DC50%1/2
ref $formatter or $formatter->can("write")
ref $formatter
$formatter->can("write")
Truth table66%2/3
A or B
A= ref $formatterB= $formatter->can("write")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 276 | my $file = pkg_to_file($formatter); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 276 | ▶ | my ($ok, $err) = try { require $file }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 276 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 5 | my $line = "* COULD NOT LOAD FORMATTER '$formatter' ($source) *"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | my $border = '*' x length($line); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 5 | die "\n\n $border\n $line\n $border\n\n$err"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 483 | $self->{+FORMATTER} = $formatter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # Turn on IPC if threads are on, drivers are registered, or the Test2::IPC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # module is loaded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 488 | ▶ | return if $self->{+IPC_DISABLED}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 484 | ▶ | return unless USE_THREADS || $INC{'Test2/IPC.pm'} || @{$self->{+IPC_DRIVERS}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$INC{"Test2/IPC.pm"} or @{$self->{"ipc_drivers"};}
MC/DC100%2/2
$INC{"Test2/IPC.pm"} or @{$self->{"ipc_drivers"};}
$INC{"Test2/IPC.pm"}
@{$self->{"ipc_drivers"};}
Truth table100%3/3
A or B
A= $INC{"Test2/IPC.pm"}B= @{$self->{"ipc_drivers"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # Turn on polling by default, people expect it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 129 | $self->enable_ipc_polling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 129 | ▶ | unless (@{$self->{+IPC_DRIVERS}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 126 | ▶ | my ($ok, $error) = try { require Test2::IPC::Driver::Files }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 126 | ▶ | die $error unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 126 | push @{$self->{+IPC_DRIVERS}} => 'Test2::IPC::Driver::Files'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 129 | for my $driver (@{$self->{+IPC_DRIVERS}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 129 | ▶ | next unless $driver->can('is_viable') && $driver->is_viable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$driver->can("is_viable") and $driver->is_viable
MC/DC50%1/2
$driver->can("is_viable") and $driver->is_viable
$driver->can("is_viable")
$driver->is_viable
Truth table66%2/3
A and B
A= $driver->can("is_viable")B= $driver->is_viable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 128 | ▶ | $self->{+IPC} = $driver->new or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 128 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | die "IPC has been requested, but no viable drivers were found. Aborting...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 11 | ▶ | sub formatter_set { $_[0]->{+FORMATTER} ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
formatter_set: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 183 | ▶ | sub add_formatter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_formatter: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 183 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 183 | my ($formatter) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 183 | unshift @{$self->{+FORMATTERS}} => $formatter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 183 | ▶ | return unless $self->{+FINALIZED}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # Why is the @CARP_NOT entry not enough? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | local %Carp::Internal = %Carp::Internal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | $Carp::Internal{'Test2::Formatter'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | carp "Formatter $formatter loaded too late to be used as the global formatter"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 186 | ▶ | sub add_context_acquire_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_context_acquire_callback: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 186 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 186 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 186 | ▶ | my $rtype = reftype($code) || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($code) || ''
MC/DC0%0/1
builtin::reftype($code) || ''
builtin::reftype($code)
Truth table50%1/2
A
A= builtin::reftype($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 186 | ▶ | confess "Context-acquire callbacks must be coderefs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$code and $rtype eq "CODE"
MC/DC0%0/2
$code and $rtype eq "CODE"
$code
$rtype eq "CODE"
Truth table33%1/3
A and B
A= $codeB= $rtype eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | unless $code && $rtype eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 186 | push @{$self->{+CONTEXT_ACQUIRE_CALLBACKS}} => $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 133 | ▶ | sub add_context_init_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_context_init_callback: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 133 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 133 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 133 | ▶ | my $rtype = reftype($code) || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($code) || ''
MC/DC0%0/1
builtin::reftype($code) || ''
builtin::reftype($code)
Truth table50%1/2
A
A= builtin::reftype($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 133 | ▶ | confess "Context-init callbacks must be coderefs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$code and $rtype eq "CODE"
MC/DC0%0/2
$code and $rtype eq "CODE"
$code
$rtype eq "CODE"
Truth table33%1/3
A and B
A= $codeB= $rtype eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | unless $code && $rtype eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 133 | push @{$self->{+CONTEXT_INIT_CALLBACKS}} => $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | ▶ | sub add_context_release_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_context_release_callback: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 5 | ▶ | my $rtype = reftype($code) || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($code) || ''
MC/DC0%0/1
builtin::reftype($code) || ''
builtin::reftype($code)
Truth table50%1/2
A
A= builtin::reftype($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 5 | ▶ | confess "Context-release callbacks must be coderefs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$code and $rtype eq "CODE"
MC/DC0%0/2
$code and $rtype eq "CODE"
$code
$rtype eq "CODE"
Truth table33%1/3
A and B
A= $codeB= $rtype eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | unless $code && $rtype eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 5 | push @{$self->{+CONTEXT_RELEASE_CALLBACKS}} => $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 403 | ▶ | sub add_post_load_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_post_load_callback: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 403 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 403 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 403 | ▶ | my $rtype = reftype($code) || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($code) || ''
MC/DC0%0/1
builtin::reftype($code) || ''
builtin::reftype($code)
Truth table50%1/2
A
A= builtin::reftype($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 403 | ▶ | confess "Post-load callbacks must be coderefs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$code and $rtype eq "CODE"
MC/DC50%1/2
$code and $rtype eq "CODE"
$code
$rtype eq "CODE"
Truth table66%2/3
A and B
A= $codeB= $rtype eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | unless $code && $rtype eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 398 | push @{$self->{+POST_LOAD_CALLBACKS}} => $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 398 | ▶ | $code->() if $self->{+LOADED}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 17 | ▶ | sub add_pre_subtest_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_pre_subtest_callback: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 17 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 17 | ▶ | my $rtype = reftype($code) || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($code) || ''
MC/DC0%0/1
builtin::reftype($code) || ''
builtin::reftype($code)
Truth table50%1/2
A
A= builtin::reftype($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 17 | ▶ | confess "Pre-subtest callbacks must be coderefs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$code and $rtype eq "CODE"
MC/DC50%1/2
$code and $rtype eq "CODE"
$code
$rtype eq "CODE"
Truth table66%2/3
A and B
A= $codeB= $rtype eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | unless $code && $rtype eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 12 | push @{$self->{+PRE_SUBTEST_CALLBACKS}} => $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 754 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 754 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 754 | ▶ | unless ($self->{+LOADED}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | confess "Attempt to initialize Test2::API during preload" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 474 | ▶ | if $self->{+PRELOAD}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 474 | ▶ | $self->{+_PID} = $$ unless defined $self->{+_PID}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 474 | ▶ | $self->{+_TID} = get_tid() unless defined $self->{+_TID}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # This is for https://github.com/Test-More/test-more/issues/16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # and https://rt.perl.org/Public/Bug/Display.html?id=127774 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # END blocks run in reverse order. This insures the END block is loaded | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # as late as possible. It will not solve all cases, but it helps. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 451 | ▶ | eval "END { Test2::API::test2_set_is_end() }; 1" or die $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
END: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 474 | $self->{+LOADED} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 474 | $_->() for @{$self->{+POST_LOAD_CALLBACKS}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 754 | return $self->{+LOADED}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 694 | ▶ | sub add_exit_callback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_exit_callback: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 694 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 694 | my ($code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 694 | ▶ | my $rtype = reftype($code) || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
builtin::reftype($code) || ''
MC/DC0%0/1
builtin::reftype($code) || ''
builtin::reftype($code)
Truth table50%1/2
A
A= builtin::reftype($code)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 694 | ▶ | confess "End callbacks must be coderefs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$code and $rtype eq "CODE"
MC/DC50%1/2
$code and $rtype eq "CODE"
$code
$rtype eq "CODE"
Truth table66%2/3
A and B
A= $codeB= $rtype eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | unless $code && $rtype eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 689 | push @{$self->{+EXIT_CALLBACKS}} => $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 4 | ▶ | sub ipc_disable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ipc_disable: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | confess "Attempt to disable IPC after it has been initialized" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | ▶ | if $self->{+IPC}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | $self->{+IPC_DISABLED} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 9 | ▶ | sub add_ipc_driver { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_ipc_driver: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 9 | my ($driver) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 9 | unshift @{$self->{+IPC_DRIVERS}} => $driver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 9 | ▶ | return unless $self->{+FINALIZED}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # Why is the @CARP_NOT entry not enough? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | local %Carp::Internal = %Carp::Internal; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | $Carp::Internal{'Test2::IPC::Driver'} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | carp "IPC driver $driver loaded too late to be used as the global ipc driver"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 132 | ▶ | sub enable_ipc_polling { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enable_ipc_polling: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 132 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 132 | ▶ | $self->{+_PID} = $$ unless defined $self->{+_PID}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 132 | ▶ | $self->{+_TID} = get_tid() unless defined $self->{+_TID}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | $self->add_context_init_callback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # This is called every time a context is created, it needs to be fast. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # $_[0] is a context object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 2123 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 2123 | ▶ | return unless $self->{+IPC_POLLING}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 2121 | ▶ | return unless $self->{+IPC}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 2121 | ▶ | return unless $self->{+IPC}->pending(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2121 | return $_[0]->{hub}->cull; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 132 | ▶ | ) unless defined $self->ipc_polling; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 132 | $self->set_ipc_polling(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | sub get_ipc_pending { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_ipc_pending: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | return -1 unless $self->{+IPC}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $self->{+IPC}->pending(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | sub _check_pid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_pid: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my ($pid) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | return kill(0, $pid); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 225 | ▶ | sub set_ipc_pending { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_ipc_pending: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 225 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 225 | ▶ | return unless $self->{+IPC}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 219 | my ($val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 219 | ▶ | confess "value is required for set_ipc_pending" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | unless $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 219 | $self->{+IPC}->set_pending($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 3 | ▶ | sub disable_ipc_polling { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disable_ipc_polling: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 3 | ▶ | return unless defined $self->{+IPC_POLLING}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 2 | $self->{+IPC_POLLING} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 53 | ▶ | sub _ipc_wait { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ipc_wait: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 53 | my ($timeout) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 53 | my $fail = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 53 | ▶ | $timeout = DEFAULT_IPC_TIMEOUT() unless defined $timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 53 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 53 | ▶ | if (CAN_FORK) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 53 | ▶ | local $SIG{ALRM} = sub { die "Timeout waiting on child processes" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 53 | alarm $timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 53 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 70 | my $pid = CORE::wait(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 69 | my $err = $?; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 69 | ▶ | last if $pid == -1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 17 | ▶ | next unless $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 9 | $fail++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 9 | my $sig = $err & 127; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 9 | my $exit = $err >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 9 | warn "Process $pid did not exit cleanly (wstat: $err, exit: $exit, sig: $sig)\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 52 | alarm 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 52 | if (USE_THREADS) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | my $start = time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | while (1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | last unless threads->list(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | die "Timeout waiting on child thread" if time - $start >= $timeout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | sleep 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | for my $t (threads->list) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # threads older than 1.34 do not have this :-( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | next if $t->can('is_joinable') && !$t->is_joinable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | $t->join; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # In older threads we cannot check if a thread had an error unless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | # we control it and its return. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | my $err = $t->can('error') ? $t->error : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | next unless $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | my $tid = $t->tid(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | $fail++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | chomp($err); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | warn "Thread $tid did not end cleanly: $err\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 52 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 53 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 53 | ▶ | return 0 if $ok && !$fail; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ok and not $fail
MC/DC100%2/2
$ok and not $fail
$ok
not $fail
Truth table100%3/3
A and not(B)
A= $okB= not $fail
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 10 | ▶ | warn $error unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 10 | return 255; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 489 | ▶ | sub set_exit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_exit: called CC=39 SCAR=37.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 489 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 489 | ▶ | return if $self->{+PRELOAD}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 489 | my $exit = $?; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 489 | my $new_exit = $exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 489 | ▶ | if ($INC{'Test/Builder.pm'} && $Test::Builder::VERSION ne $Test2::API::VERSION) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$INC{"Test/Builder.pm"} and $Test::Builder::VERSION ne $Test2::API::VERSION
MC/DC100%2/2
$INC{"Test/Builder.pm"} and $Test::Builder::VERSION ne $Test2::API::VERSION
$INC{"Test/Builder.pm"}
$Test::Builder::VERSION ne $Test2::API::VERSION
Truth table100%3/3
A and B
A= $INC{"Test/Builder.pm"}B= $Test::Builder::VERSION ne $Test2::API::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 3 | print STDERR <<" EOT"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | ******************************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | * * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | * Test::Builder -- Test2::API version mismatch detected * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | * * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | ******************************************************************************** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | Test2::API Version: $Test2::API::VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | Test::Builder Version: $Test::Builder::VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | This is not a supported configuration, you will have problems. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | EOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 489 | for my $ctx (values %{$self->{+CONTEXTS}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 66 | ▶ | next unless $ctx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | next if $ctx->_aborted && ${$ctx->_aborted}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ctx->_aborted and ${$ctx->_aborted;}
MC/DC0%0/2
$ctx->_aborted and ${$ctx->_aborted;}
$ctx->_aborted
${$ctx->_aborted;}
Truth table33%1/3
A and B
A= $ctx->_abortedB= ${$ctx->_aborted;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # Only worry about contexts in this PID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 1 | ▶ | my $trace = $ctx->trace || next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ctx->trace || (next)
MC/DC0%0/1
$ctx->trace || (next)
$ctx->trace
Truth table50%1/2
A
A= $ctx->trace
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 1 | ▶ | next unless $trace->pid && $trace->pid == $$; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$trace->pid and $trace->pid == $$
MC/DC0%0/2
$trace->pid and $trace->pid == $$
$trace->pid
$trace->pid == $$
Truth table33%1/3
A and B
A= $trace->pidB= $trace->pid == $$
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # Do not worry about contexts that have no hub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | ▶ | my $hub = $ctx->hub || next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ctx->hub || (next)
MC/DC0%0/1
$ctx->hub || (next)
$ctx->hub
Truth table50%1/2
A
A= $ctx->hub
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # Do not worry if the state came to a sudden end. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1 | ▶ | next if $hub->bailed_out; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | ▶ | next if defined $hub->skip_reason; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # now we worry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 1 | $trace->alert("context object was never released! This means a testing tool is behaving very badly"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 1 | $exit = 255; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 1 | $new_exit = 255; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 489 | ▶ | if (!defined($self->{+_PID}) or !defined($self->{+_TID}) or $self->{+_PID} != $$ or $self->{+_TID} != get_tid()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
not defined $self->{"_pid"} && defined $self->{"_tid"} or $self->{"_pid"} != $$ or $self->{"_tid"} != 0
not defined $self->{"_pid"} && defined $self->{"_tid"} or $self->{"_pid"} != $$
defined $self->{'_pid'} && defined $self->{'_tid'}
MC/DC50%2/4
not defined $self->{"_pid"} && defined $self->{"_tid"} or $self->{"_pid"} != $$ or $self->{"_tid"} != 0
defined $self->{'_pid'}
defined $self->{'_tid'}
$self->{"_pid"} != $$
$self->{"_tid"} != 0
Truth table60%3/5
not(A && B) or C or D
A= defined $self->{'_pid'}B= defined $self->{'_tid'}C= $self->{"_pid"} != $$D= $self->{"_tid"} != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 78 | $? = $exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 78 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 411 | ▶ | my @hubs = $self->{+STACK} ? $self->{+STACK}->all : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 411 | ▶ | if (@hubs and $self->{+IPC} and !$self->{+NO_WAIT}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@hubs and $self->{"ipc"} and not $self->{"no_wait"}
@hubs and $self->{"ipc"}
MC/DC66%2/3
@hubs and $self->{"ipc"} and not $self->{"no_wait"}
@hubs
$self->{"ipc"}
not $self->{"no_wait"}
Truth table75%3/4
A and B and not(C)
A= @hubsB= $self->{"ipc"}C= not $self->{"no_wait"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 42 | local $?; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 42 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 42 | for my $hub (reverse @hubs) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 42 | ▶ | my $ipc = $hub->ipc or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 42 | ▶ | next if $seen{$ipc}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 42 | $ipc->waiting(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 42 | my $ipc_exit = _ipc_wait($self->{+IPC_TIMEOUT}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 42 | ▶ | $new_exit ||= $ipc_exit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$new_exit ||= $ipc_exit
MC/DC100%2/2
$new_exit ||= $ipc_exit
$new_exit
$ipc_exit
Truth table100%3/3
A ||= B
A= $new_exitB= $ipc_exit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # None of this is necessary if we never got a root hub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 411 | ▶ | if(my $root = shift @hubs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 405 | my $trace = Test2::EventFacet::Trace->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | frame => [__PACKAGE__, __FILE__, 0, __PACKAGE__ . '::END'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | detail => __PACKAGE__ . ' END Block finalization', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 405 | my $ctx = Test2::API::Context->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | trace => $trace, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | hub => $root, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 405 | ▶ | if (@hubs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 6 | $ctx->diag("Test ended with extra hubs on the stack!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 6 | $new_exit = 255; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 405 | ▶ | unless ($root->no_ending) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 386 | local $?; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 386 | ▶ | $root->finalize($trace) unless $root->ended; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 386 | $_->($ctx, $exit, \$new_exit) for @{$self->{+EXIT_CALLBACKS}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 386 | ▶ | $new_exit ||= $root->failed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$new_exit ||= $root->failed
MC/DC100%2/2
$new_exit ||= $root->failed
$new_exit
$root->failed
Truth table100%3/3
A ||= B
A= $new_exitB= $root->failed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 386 | ▶ | $new_exit ||= 255 unless $root->is_passing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$new_exit ||= 255
MC/DC100%1/1
$new_exit ||= 255
$new_exit
Truth table100%2/2
A
A= $new_exit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 411 | ▶ | $new_exit = 255 if $new_exit > 255; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 411 | ▶ | if ($new_exit && eval { require Test2::API::Breakage; 1 }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$new_exit and eval {
do {
require Test2::API::Breakage;
1
}
}
MC/DC50%1/2
$new_exit and eval {
do {
require Test2::API::Breakage;
1
}
}
$new_exit
eval {
do {
require Test2::API::Breakage;
1
}
}
Truth table66%2/3
A and B
A= $new_exitB= eval {
do {
require Test2::API::Breakage;
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 38 | my @warn = Test2::API::Breakage->report(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 38 | ▶ | if (@warn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 3 | print STDERR "\nYou have loaded versions of test modules known to have problems with Test2.\nThis could explain some test failures.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 3 | print STDERR "$_\n" for @warn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 3 | print STDERR "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 411 | $? = $new_exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 455 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||