| 1 | package Test2::Workflow::Runner; | ||||||||||||||||||||||||||||||||||||||||
| 2 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 3 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||
| 5 | 36 | our $VERSION = '1.302226'; | |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||
| 7 | 36 | ▶ | use Test2::API(); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 8 | 36 | ▶ | use Test2::Todo(); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 9 | 36 | ▶ | use Test2::AsyncSubtest(); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||
| 11 | 36 | ▶ | use Test2::Util qw/get_tid CAN_REALLY_FORK/; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||
| 13 | 36 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 14 | 36 | ▶ | use Time::HiRes qw/sleep/; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 15 | 36 | ▶ | use List::Util qw/shuffle min/; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 16 | 36 | ▶ | use Carp qw/confess/; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||
| 18 | 36 | ▶ | use Test2::Util::HashBase qw{ | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 19 | stack no_fork no_threads max slots pid tid rand subtests filter | ||||||||||||||||||||||||||||||||||||||||
| 20 | 36 | }; | |||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||
| 22 | 36 | ▶ | use overload( | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 23 | 'fallback' => 1, | ||||||||||||||||||||||||||||||||||||||||
| 24 | 154 | ▶ | '&{}' => sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 25 | 154 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||
| 27 | 154 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 28 | 154 | @_ = ($self); | |||||||||||||||||||||||||||||||||||||||
| 29 | 154 | goto &run; | |||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||
| 31 | 154 | }, | |||||||||||||||||||||||||||||||||||||||
| 32 | 36 | ); | |||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||
| 34 | 44 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=15 SCAR=33.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 35 | 44 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||
| 37 | 44 | $self->{+STACK} = []; | |||||||||||||||||||||||||||||||||||||||
| 38 | 44 | $self->{+SUBTESTS} = []; | |||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||
| 40 | 44 | $self->{+PID} = $$; | |||||||||||||||||||||||||||||||||||||||
| 41 | 44 | $self->{+TID} = get_tid(); | |||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||
| 43 | 44 | ▶ | $self->{+NO_FORK} ||= $ENV{T2_WORKFLOW_NO_FORK} || !CAN_REALLY_FORK(); | ||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$self->{"no_fork"} ||= $ENV{"T2_WORKFLOW_NO_FORK"} || !&CAN_REALLY_FORK()
$ENV{'T2_WORKFLOW_NO_FORK'} || !&CAN_REALLY_FORK()
MC/DC0%0/3
$self->{"no_fork"} ||= $ENV{"T2_WORKFLOW_NO_FORK"} || !&CAN_REALLY_FORK()
$self->{"no_fork"}
$ENV{'T2_WORKFLOW_NO_FORK'}
!&CAN_REALLY_FORK()
Truth table0%0/4
A ||= B || not(C)
A= $self->{"no_fork"}B= $ENV{'T2_WORKFLOW_NO_FORK'}C= !&CAN_REALLY_FORK()
| |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||
| 45 | 44 | my $can_thread = Test2::AsyncSubtest->CAN_REALLY_THREAD(); | |||||||||||||||||||||||||||||||||||||||
| 46 | 44 | ▶ | my $should_thread = ($ENV{T2_WORKFLOW_USE_THREADS} || $ENV{T2_DO_THREAD_TESTS}) && !$ENV{T2_WORKFLOW_NO_THREADS}; | ||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
($ENV{'T2_WORKFLOW_USE_THREADS'} || $ENV{'T2_DO_THREAD_TESTS'}) && !$ENV{'T2_WORKFLOW_NO_THREADS'}
$ENV{"T2_WORKFLOW_USE_THREADS"} or $ENV{"T2_DO_THREAD_TESTS"}
MC/DC0%0/3
($ENV{'T2_WORKFLOW_USE_THREADS'} || $ENV{'T2_DO_THREAD_TESTS'}) && !$ENV{'T2_WORKFLOW_NO_THREADS'}
$ENV{"T2_WORKFLOW_USE_THREADS"}
$ENV{"T2_DO_THREAD_TESTS"}
!$ENV{'T2_WORKFLOW_NO_THREADS'}
Truth table20%1/5
A or B && not(C)
A= $ENV{"T2_WORKFLOW_USE_THREADS"}B= $ENV{"T2_DO_THREAD_TESTS"}C= !$ENV{'T2_WORKFLOW_NO_THREADS'}
| |||||||||||||||||||||||||||||||||||||||||
| 47 | 44 | ▶ | $self->{+NO_THREADS} ||= !($can_thread && $should_thread); | ||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$self->{"no_threads"} ||= !($can_thread && $should_thread)
$can_thread && $should_thread
MC/DC0%0/3
$self->{"no_threads"} ||= !($can_thread && $should_thread)
$self->{"no_threads"}
$can_thread
$should_thread
Truth table0%0/4
A ||= not(B && C)
A= $self->{"no_threads"}B= $can_threadC= $should_thread
| |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||
| 49 | 44 | ▶ | $self->{+RAND} = 1 unless defined $self->{+RAND}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||
| 51 | 44 | my @max = grep {defined $_} $self->{+MAX}, $ENV{T2_WORKFLOW_ASYNC}; | |||||||||||||||||||||||||||||||||||||||
| 52 | 44 | ▶ | my $max = @max ? min(@max) : 3; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 53 | 44 | $self->{+MAX} = $max; | |||||||||||||||||||||||||||||||||||||||
| 54 | 44 | ▶ | $self->{+SLOTS} = [] if $max; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||
| 56 | 44 | ▶ | unless(defined($self->{+FILTER})) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 57 | 35 | ▶ | if (my $raw = $ENV{T2_WORKFLOW}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my ($file, $line, $name); | |||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($raw =~ m/^(.*)\s+(\d+)$/) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ($file, $line) = ($1, $2); | |||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||
| 62 | elsif($raw =~ m/^(\d+)$/) { | ||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $line = $1; | |||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||
| 65 | else { | ||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $name = $raw; | |||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->{+FILTER} = { | |||||||||||||||||||||||||||||||||||||||
| 70 | file => $file, | ||||||||||||||||||||||||||||||||||||||||
| 71 | line => $line, | ||||||||||||||||||||||||||||||||||||||||
| 72 | name => $name, | ||||||||||||||||||||||||||||||||||||||||
| 73 | }; | ||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||
| 77 | 44 | ▶ | if (my $task = delete $self->{task}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 78 | 9 | $self->push_task($task); | |||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||
| 82 | 250 | ▶ | sub is_local { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_local: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 83 | 250 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 84 | 250 | ▶ | return 0 unless $self->{+PID} == $$; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 85 | 232 | ▶ | return 0 unless $self->{+TID} == get_tid(); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 86 | 232 | return 1; | |||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||
| 89 | 187 | ▶ | sub send_event { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_event: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 90 | 187 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 91 | 187 | my ($type, %params) = @_; | |||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||
| 93 | 187 | my $class; | |||||||||||||||||||||||||||||||||||||||
| 94 | 187 | ▶ | if ($type =~ m/\+(.*)$/) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $class = $1; | |||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||
| 97 | else { | ||||||||||||||||||||||||||||||||||||||||
| 98 | 187 | $class = "Test2::Event::$type"; | |||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||
| 101 | 187 | my $hub = Test2::API::test2_stack()->top(); | |||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||
| 103 | 187 | my $e = $class->new( | |||||||||||||||||||||||||||||||||||||||
| 104 | trace => Test2::Util::Trace->new( | ||||||||||||||||||||||||||||||||||||||||
| 105 | frame => [caller(0)], | ||||||||||||||||||||||||||||||||||||||||
| 106 | buffered => $hub->buffered, | ||||||||||||||||||||||||||||||||||||||||
| 107 | nested => $hub->nested, | ||||||||||||||||||||||||||||||||||||||||
| 108 | hid => $hub->hid, | ||||||||||||||||||||||||||||||||||||||||
| 109 | huuid => $hub->uuid, | ||||||||||||||||||||||||||||||||||||||||
| 110 | #cid => $self->{+CID}, | ||||||||||||||||||||||||||||||||||||||||
| 111 | #uuid => $self->{+UUID}, | ||||||||||||||||||||||||||||||||||||||||
| 112 | ), | ||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||
| 114 | %params, | ||||||||||||||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||
| 117 | 187 | $hub->send($e); | |||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||
| 120 | 495 | ▶ | sub current_subtest { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_subtest: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 121 | 495 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 122 | 495 | ▶ | my $stack = $self->{+STACK} or return undef; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||
| 124 | 495 | for my $state (reverse @$stack) { | |||||||||||||||||||||||||||||||||||||||
| 125 | 961 | ▶ | next unless $state->{subtest}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 126 | 436 | return $state->{subtest}; | |||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||
| 129 | 59 | return undef; | |||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||
| 132 | 196 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=49 SCAR=40.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 133 | 196 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||
| 135 | 196 | my $stack = $self->stack; | |||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||
| 137 | 196 | my $c = 0; | |||||||||||||||||||||||||||||||||||||||
| 138 | 196 | ▶ | while (@$stack) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 139 | 3164 | $self->cull; | |||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||
| 141 | 3164 | my $state = $stack->[-1]; | |||||||||||||||||||||||||||||||||||||||
| 142 | 3164 | my $task = $state->{task}; | |||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||
| 144 | 3164 | ▶ | unless($state->{started}++) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 145 | 885 | my $skip = $task->skip; | |||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||
| 147 | 885 | my $filter; | |||||||||||||||||||||||||||||||||||||||
| 148 | 885 | ▶ | if (my $f = $self->{+FILTER}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 149 | 649 | my $in_var = grep { $_->{filter_satisfied} } @$stack; | |||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||
| 151 | 649 | ▶ | $filter = $task->filter($f) unless $in_var; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 152 | 649 | ▶ | $state->{filter_satisfied} = 1 if $filter->{satisfied}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||
| 155 | 885 | ▶ | $skip ||= $filter->{skip} if $filter; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$skip ||= $filter->{"skip"}
MC/DC50%1/2
$skip ||= $filter->{"skip"}
$skip
$filter->{"skip"}
Truth table66%2/3
A ||= B
A= $skipB= $filter->{"skip"}
| |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||
| 157 | 885 | ▶ | if ($skip) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 158 | 101 | $state->{ended}++; | |||||||||||||||||||||||||||||||||||||||
| 159 | 101 | ▶ | $self->send_event( | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$skip || $filter
MC/DC0%0/2
$skip || $filter
$skip
$filter
Truth table33%1/3
A || B
A= $skipB= $filter
| |||||||||||||||||||||||||||||||||||||||||
| 160 | 'Skip', | ||||||||||||||||||||||||||||||||||||||||
| 161 | reason => $skip || $filter, | ||||||||||||||||||||||||||||||||||||||||
| 162 | name => $task->name, | ||||||||||||||||||||||||||||||||||||||||
| 163 | pass => 1, | ||||||||||||||||||||||||||||||||||||||||
| 164 | effective_pass => 1, | ||||||||||||||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||||||||||||||
| 166 | 101 | pop @$stack; | |||||||||||||||||||||||||||||||||||||||
| 167 | 101 | next; | |||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||
| 170 | 784 | ▶ | if ($task->flat) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 171 | 495 | my $st = $self->current_subtest; | |||||||||||||||||||||||||||||||||||||||
| 172 | 495 | ▶ | my $hub = $st ? $st->hub : Test2::API::test2_stack->top; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||
| 174 | 495 | ▶ | $state->{todo} = Test2::Todo->new(reason => $task->todo, hub => $hub) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 175 | if $task->todo; | ||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||
| 177 | 495 | $hub->send($_) for @{$task->events}; | |||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||
| 179 | else { | ||||||||||||||||||||||||||||||||||||||||
| 180 | 289 | my $st = Test2::AsyncSubtest->new( | |||||||||||||||||||||||||||||||||||||||
| 181 | name => $task->name, | ||||||||||||||||||||||||||||||||||||||||
| 182 | frame => $task->frame, | ||||||||||||||||||||||||||||||||||||||||
| 183 | ); | ||||||||||||||||||||||||||||||||||||||||
| 184 | 289 | $state->{subtest} = $st; | |||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||
| 186 | 289 | ▶ | $state->{todo} = Test2::Todo->new(reason => $task->todo, hub => $st->hub) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 187 | if $task->todo; | ||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||
| 189 | 289 | for my $e (@{$task->events}) { | |||||||||||||||||||||||||||||||||||||||
| 190 | 1 | my $hub = $st->hub; | |||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | $e->trace->{buffered} = $hub->buffered; | |||||||||||||||||||||||||||||||||||||||
| 193 | 1 | $e->trace->{nested} = $hub->nested; | |||||||||||||||||||||||||||||||||||||||
| 194 | 1 | $e->trace->{hid} = $hub->hid; | |||||||||||||||||||||||||||||||||||||||
| 195 | 1 | $e->trace->{huuid} = $hub->uuid; | |||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | $hub->send($e); | |||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||
| 200 | 289 | my $slot = $self->isolate($state); | |||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||
| 202 | # if we forked/threaded then this state has ended here. | ||||||||||||||||||||||||||||||||||||||||
| 203 | 289 | ▶ | if (defined($slot)) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 204 | 100 | ▶ | push @{$self->{+SUBTESTS}} => [$st, $task] unless $st->finished; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 205 | 100 | $state->{subtest} = undef; | |||||||||||||||||||||||||||||||||||||||
| 206 | 100 | $state->{ended} = 1; | |||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||
| 211 | 3063 | ▶ | if ($state->{ended}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 212 | 749 | ▶ | $state->{todo}->end() if $state->{todo}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 213 | 749 | ▶ | $state->{subtest}->stop() if $state->{subtest}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||
| 215 | 749 | ▶ | return if $state->{in_thread}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 216 | 749 | ▶ | if(my $guard = delete $state->{in_fork}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 217 | 22 | $state->{subtest}->detach; | |||||||||||||||||||||||||||||||||||||||
| 218 | 22 | $guard->dismiss; | |||||||||||||||||||||||||||||||||||||||
| 219 | 22 | exit 0; | |||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||
| 222 | 727 | pop @$stack; | |||||||||||||||||||||||||||||||||||||||
| 223 | 727 | next; | |||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||
| 226 | 2314 | ▶ | if($state->{subtest} && !$state->{subtest_started}++) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$state->{"subtest"} and not $state->{"subtest_started"}++
MC/DC100%2/2
$state->{"subtest"} and not $state->{"subtest_started"}++
$state->{"subtest"}
not $state->{"subtest_started"}++
Truth table100%3/3
A and not(B)
A= $state->{"subtest"}B= not $state->{"subtest_started"}++
| |||||||||||||||||||||||||||||||||||||||||
| 227 | 189 | push @{$self->{+SUBTESTS}} => [$state->{subtest}, $task]; | |||||||||||||||||||||||||||||||||||||||
| 228 | 189 | $state->{subtest}->start(); | |||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||
| 231 | 2314 | ▶ | if ($task->isa('Test2::Workflow::Task::Action')) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 232 | 481 | $state->{PID} = $$; | |||||||||||||||||||||||||||||||||||||||
| 233 | 481 | my $ok = eval { $task->code->($self); 1 }; | |||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||
| 235 | 481 | ▶ | unless ($state->{PID} == $$) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | print STDERR "Task '" . $task->name . "' started in pid $state->{PID}, but ended in pid $$, did you forget to exit after forking?\n"; | |||||||||||||||||||||||||||||||||||||||
| 237 | 0 | exit 255; | |||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||
| 240 | 481 | ▶ | $task->exception($@) unless $ok; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 241 | 481 | $state->{ended} = 1; | |||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||
| 243 | 481 | next; | |||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||
| 246 | 1833 | ▶ | if (!$state->{stage} || $state->{stage} eq 'BEFORE') { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition66%2/3
not $state->{"stage"} or $state->{"stage"} eq "BEFORE"
MC/DC50%1/2
not $state->{"stage"} or $state->{"stage"} eq "BEFORE"
not $state->{"stage"}
$state->{"stage"} eq "BEFORE"
Truth table66%2/3
not(A) or B
A= not $state->{"stage"}B= $state->{"stage"} eq "BEFORE"
| |||||||||||||||||||||||||||||||||||||||||
| 247 | 515 | ▶ | $state->{before} = (defined $state->{before}) ? $state->{before} : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||
| 249 | 515 | ▶ | if (my $add = $task->before->[$state->{before}++]) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 250 | 312 | ▶ | if ($add->around) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 251 | 154 | $state->{PID} = $$; | |||||||||||||||||||||||||||||||||||||||
| 252 | 154 | my $ok = eval { $add->code->($self); 1 }; | |||||||||||||||||||||||||||||||||||||||
| 253 | 154 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||
| 254 | 154 | ▶ | my $complete = $state->{stage} && $state->{stage} eq 'AFTER'; | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$state->{'stage'} && $state->{'stage'} eq 'AFTER'
MC/DC0%0/2
$state->{'stage'} && $state->{'stage'} eq 'AFTER'
$state->{'stage'}
$state->{'stage'} eq 'AFTER'
Truth table33%1/3
A && B
A= $state->{'stage'}B= $state->{'stage'} eq 'AFTER'
| |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||
| 256 | 154 | ▶ | unless ($state->{PID} == $$) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | print STDERR "Task '" . $task->name . "' started in pid $state->{PID}, but ended in pid $$, did you forget to exit after forking?\n"; | |||||||||||||||||||||||||||||||||||||||
| 258 | 0 | exit 255; | |||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||
| 261 | 154 | ▶ | unless($ok && $complete) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ok and $complete
MC/DC0%0/2
$ok and $complete
$ok
$complete
Truth table33%1/3
A and B
A= $okB= $complete
| |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | $state->{ended} = 1; | |||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $state->{stage} = 'AFTER'; | |||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | $task->exception($ok ? "'around' task failed to continue into the workflow chain.\n" : $err); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||
| 267 | else { | ||||||||||||||||||||||||||||||||||||||||
| 268 | 158 | $self->push_task($add); | |||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||
| 271 | else { | ||||||||||||||||||||||||||||||||||||||||
| 272 | 203 | $state->{stage} = 'VARIANT'; | |||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||
| 275 | elsif ($state->{stage} eq 'VARIANT') { | ||||||||||||||||||||||||||||||||||||||||
| 276 | 203 | ▶ | if (my $v = $task->variant) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 277 | 60 | $self->push_task($v); | |||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||
| 279 | 203 | $state->{stage} = 'PRIMARY'; | |||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||
| 281 | elsif ($state->{stage} eq 'PRIMARY') { | ||||||||||||||||||||||||||||||||||||||||
| 282 | 641 | ▶ | unless (defined $state->{order}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 283 | 203 | ▶ | my $rand = defined($task->rand) ? $task->rand : $self->rand; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 284 | 203 | $state->{order} = [0 .. scalar(@{$task->primary}) - 1]; | |||||||||||||||||||||||||||||||||||||||
| 285 | 203 | ▶ | @{$state->{order}} = shuffle(@{$state->{order}}) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 286 | if $rand; | ||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||
| 288 | 641 | my $num = shift @{$state->{order}}; | |||||||||||||||||||||||||||||||||||||||
| 289 | 641 | ▶ | if (defined $num) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 290 | 473 | $self->push_task($task->primary->[$num]); | |||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||||||||||||||
| 293 | 168 | $state->{stage} = 'AFTER'; | |||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||
| 296 | elsif ($state->{stage} eq 'AFTER') { | ||||||||||||||||||||||||||||||||||||||||
| 297 | 474 | ▶ | $state->{after} = (defined $state->{after}) ? $state->{after} : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 298 | 474 | ▶ | if (my $add = $task->after->[$state->{after}++]) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 299 | 306 | ▶ | return if $add->around; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 300 | 152 | $self->push_task($add); | |||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||
| 302 | else { | ||||||||||||||||||||||||||||||||||||||||
| 303 | 168 | $state->{ended} = 1; | |||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||
| 308 | 20 | $self->finish; | |||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||
| 311 | 885 | ▶ | sub push_task { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
push_task: called CC=6 SCAR=18.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 312 | 885 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 313 | 885 | my ($task) = @_; | |||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||
| 315 | 885 | ▶ | confess "No Task!" unless $task; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 316 | 885 | ▶ | confess "Bad Task ($task)!" unless blessed($task) && $task->isa('Test2::Workflow::Task'); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($task) and $task->isa("Test2::Workflow::Task")
MC/DC0%0/2
builtin::blessed($task) and $task->isa("Test2::Workflow::Task")
builtin::blessed($task)
$task->isa("Test2::Workflow::Task")
Truth table33%1/3
A and B
A= builtin::blessed($task)B= $task->isa("Test2::Workflow::Task")
| |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||
| 318 | 885 | ▶ | if ($task->isa('Test2::Workflow::Build')) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 319 | confess "Can only push a Build instance when initializing the stack" | ||||||||||||||||||||||||||||||||||||||||
| 320 | 9 | ▶ | if @{$self->{+STACK}}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 321 | 9 | $task = $task->compile(); | |||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||
| 324 | 885 | push @{$self->{+STACK}} => { | |||||||||||||||||||||||||||||||||||||||
| 325 | task => $task, | ||||||||||||||||||||||||||||||||||||||||
| 326 | name => $task->name, | ||||||||||||||||||||||||||||||||||||||||
| 327 | }; | ||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||
| 330 | 8 | ▶ | sub add_mock { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_mock: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 331 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 332 | 8 | my ($mock) = @_; | |||||||||||||||||||||||||||||||||||||||
| 333 | 8 | my $stack = $self->{+STACK}; | |||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||
| 335 | 8 | ▶ | confess "Nothing on the stack!" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$stack and @$stack
MC/DC0%0/2
$stack and @$stack
$stack
@$stack
Truth table33%1/3
A and B
A= $stackB= @$stack
| |||||||||||||||||||||||||||||||||||||||||
| 336 | unless $stack && @$stack; | ||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||
| 338 | 8 | my ($state) = grep { !$_->{task}->scaffold} reverse @$stack; | |||||||||||||||||||||||||||||||||||||||
| 339 | 8 | push @{$state->{mocks}} => $mock; | |||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||
| 342 | 289 | ▶ | sub isolate { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
isolate: called CC=18 SCAR=30.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 343 | 289 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 344 | 289 | my ($state) = @_; | |||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||
| 346 | 289 | ▶ | return if $state->{task}->skip; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||
| 348 | 289 | my $iso = $state->{task}->iso; | |||||||||||||||||||||||||||||||||||||||
| 349 | 289 | my $async = $state->{task}->async; | |||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||
| 351 | # No need to isolate | ||||||||||||||||||||||||||||||||||||||||
| 352 | 289 | ▶ | return undef unless $iso || $async; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$iso or $async
MC/DC50%1/2
$iso or $async
$iso
$async
Truth table66%2/3
A or B
A= $isoB= $async
| |||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||
| 354 | # Cannot isolate | ||||||||||||||||||||||||||||||||||||||||
| 355 | 125 | ▶ | unless($self->{+MAX} && $self->is_local) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"max"} and $self->is_local
MC/DC50%1/2
$self->{"max"} and $self->is_local
$self->{"max"}
$self->is_local
Truth table66%2/3
A and B
A= $self->{"max"}B= $self->is_local
| |||||||||||||||||||||||||||||||||||||||||
| 356 | # async does not NEED to be isolated | ||||||||||||||||||||||||||||||||||||||||
| 357 | 9 | ▶ | return undef unless $iso; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||
| 360 | # Wait for a slot, if max is set to 0 then we will not find a slot, instead | ||||||||||||||||||||||||||||||||||||||||
| 361 | # we use '0'. We need to return a defined value to let the stack know that | ||||||||||||||||||||||||||||||||||||||||
| 362 | # the task has ended. | ||||||||||||||||||||||||||||||||||||||||
| 363 | 125 | my $slot = 0; | |||||||||||||||||||||||||||||||||||||||
| 364 | 125 | ▶ | while($self->{+MAX} && $self->is_local) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"max"} and $self->is_local
MC/DC50%1/2
$self->{"max"} and $self->is_local
$self->{"max"}
$self->is_local
Truth table66%2/3
A and B
A= $self->{"max"}B= $self->is_local
| |||||||||||||||||||||||||||||||||||||||||
| 365 | 116 | $self->cull; | |||||||||||||||||||||||||||||||||||||||
| 366 | 116 | for my $s (1 .. $self->{+MAX}) { | |||||||||||||||||||||||||||||||||||||||
| 367 | 171 | my $st = $self->{+SLOTS}->[$s]; | |||||||||||||||||||||||||||||||||||||||
| 368 | 171 | ▶ | next if $st && !$st->finished; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$st and not $st->finished
MC/DC100%2/2
$st and not $st->finished
$st
not $st->finished
Truth table100%3/3
A and not(B)
A= $stB= not $st->finished
| |||||||||||||||||||||||||||||||||||||||||
| 369 | 116 | $self->{+SLOTS}->[$s] = undef; | |||||||||||||||||||||||||||||||||||||||
| 370 | 116 | $slot = $s; | |||||||||||||||||||||||||||||||||||||||
| 371 | 116 | last; | |||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||
| 373 | 116 | ▶ | last if $slot; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | sleep(0.02); | |||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||
| 377 | my $st = $state->{subtest} | ||||||||||||||||||||||||||||||||||||||||
| 378 | 125 | ▶ | or confess "Cannot isolate a task without a subtest"; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||
| 380 | 125 | ▶ | if (!$self->no_fork) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 381 | 111 | my $out = $st->fork; | |||||||||||||||||||||||||||||||||||||||
| 382 | 111 | ▶ | if (blessed($out)) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 383 | 25 | $state->{in_fork} = $out; | |||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||
| 385 | # drop back out to complete the task. | ||||||||||||||||||||||||||||||||||||||||
| 386 | 25 | return undef; | |||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||
| 388 | else { | ||||||||||||||||||||||||||||||||||||||||
| 389 | $self->send_event( | ||||||||||||||||||||||||||||||||||||||||
| 390 | 'Note', | ||||||||||||||||||||||||||||||||||||||||
| 391 | message => "Forked PID $out to run: " . $state->{task}->name, | ||||||||||||||||||||||||||||||||||||||||
| 392 | 86 | ); | |||||||||||||||||||||||||||||||||||||||
| 393 | 86 | $state->{pid} = $out; | |||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||
| 396 | elsif (!$self->no_threads) { | ||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $state->{in_thread} = 1; | |||||||||||||||||||||||||||||||||||||||
| 398 | 0 | my $thr = $st->run_thread(\&run, $self); | |||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $state->{thread} = $thr; | |||||||||||||||||||||||||||||||||||||||
| 400 | 0 | delete $state->{in_thread}; | |||||||||||||||||||||||||||||||||||||||
| 401 | $self->send_event( | ||||||||||||||||||||||||||||||||||||||||
| 402 | 'Note', | ||||||||||||||||||||||||||||||||||||||||
| 403 | message => "Started Thread-ID " . $thr->tid . " to run: " . $state->{task}->name, | ||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ); | |||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||
| 406 | else { | ||||||||||||||||||||||||||||||||||||||||
| 407 | 14 | $st->finish(skip => "No isolation method available"); | |||||||||||||||||||||||||||||||||||||||
| 408 | 14 | return 0; | |||||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||
| 411 | 86 | ▶ | if($slot) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 412 | 80 | $self->{+SLOTS}->[$slot] = $st; | |||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||
| 414 | else { | ||||||||||||||||||||||||||||||||||||||||
| 415 | 6 | $st->finish; | |||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||
| 418 | 86 | return $slot; | |||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||
| 421 | 3656 | ▶ | sub cull { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
cull: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 422 | 3656 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||
| 424 | 3656 | ▶ | my $subtests = delete $self->{+SUBTESTS} || return; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $self->{'subtests'} || (return)
MC/DC0%0/1
delete $self->{'subtests'} || (return)
delete $self->{'subtests'}
Truth table50%1/2
A
A= delete $self->{'subtests'}
| |||||||||||||||||||||||||||||||||||||||||
| 425 | 3656 | my @new; | |||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||
| 427 | # Cull subtests in reverse order, Nested subtests end before their parents. | ||||||||||||||||||||||||||||||||||||||||
| 428 | 3656 | for my $set (reverse @$subtests) { | |||||||||||||||||||||||||||||||||||||||
| 429 | 9451 | my ($st, $task) = @$set; | |||||||||||||||||||||||||||||||||||||||
| 430 | 9451 | ▶ | next if $st->finished; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 431 | 9451 | ▶ | if (!$st->active && $st->ready) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $st->active and $st->ready
MC/DC100%2/2
not $st->active and $st->ready
not $st->active
$st->ready
Truth table100%3/3
not(A) and B
A= not $st->activeB= $st->ready
| |||||||||||||||||||||||||||||||||||||||||
| 432 | 213 | $st->finish(); | |||||||||||||||||||||||||||||||||||||||
| 433 | 213 | next; | |||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||
| 436 | # Use unshift to preserve order. | ||||||||||||||||||||||||||||||||||||||||
| 437 | 9238 | unshift @new => $set; | |||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||
| 440 | 3656 | $self->{+SUBTESTS} = \@new; | |||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||
| 442 | 3656 | return; | |||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||
| 445 | 20 | ▶ | sub finish { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 446 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 447 | 20 | ▶ | while(@{$self->{+SUBTESTS}}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 448 | 376 | $self->cull; | |||||||||||||||||||||||||||||||||||||||
| 449 | 376 | ▶ | sleep(0.02) if @{$self->{+SUBTESTS}}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||
| 453 | 36 | 1; | |||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||
| 455 | __END__ | ||||||||||||||||||||||||||||||||||||||||