line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::Task; |
2
|
48
|
|
|
48
|
|
92780
|
use strict; |
|
48
|
|
|
|
|
66
|
|
|
48
|
|
|
|
|
1077
|
|
3
|
48
|
|
|
48
|
|
129
|
use warnings; |
|
48
|
|
|
|
|
64
|
|
|
48
|
|
|
|
|
851
|
|
4
|
|
|
|
|
|
|
|
5
|
48
|
|
|
48
|
|
134
|
use Test2::API(); |
|
48
|
|
|
|
|
67
|
|
|
48
|
|
|
|
|
789
|
|
6
|
48
|
|
|
48
|
|
156
|
use Test2::Event::Exception(); |
|
48
|
|
|
|
|
46
|
|
|
48
|
|
|
|
|
927
|
|
7
|
|
|
|
|
|
|
|
8
|
48
|
|
|
48
|
|
140
|
use List::Util qw/min max/; |
|
48
|
|
|
|
|
50
|
|
|
48
|
|
|
|
|
2890
|
|
9
|
48
|
|
|
48
|
|
181
|
use Scalar::Util qw/blessed/; |
|
48
|
|
|
|
|
46
|
|
|
48
|
|
|
|
|
4187
|
|
10
|
48
|
|
|
48
|
|
194
|
use Carp qw/croak/; |
|
48
|
|
|
|
|
59
|
|
|
48
|
|
|
|
|
2399
|
|
11
|
|
|
|
|
|
|
our @CARP_NOT = qw/Test2::Util::HashBase/; |
12
|
|
|
|
|
|
|
|
13
|
48
|
|
|
48
|
|
193
|
use base 'Test2::Workflow::BlockBase'; |
|
48
|
|
|
|
|
49
|
|
|
48
|
|
|
|
|
17590
|
|
14
|
48
|
|
|
48
|
|
306
|
use Test2::Util::HashBase qw/name flat async iso todo skip scaffold events is_root/; |
|
48
|
|
|
|
|
57
|
|
|
48
|
|
|
|
|
247
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
for my $attr (FLAT, ISO, ASYNC, TODO, SKIP, SCAFFOLD) { |
17
|
|
|
|
|
|
|
my $old = __PACKAGE__->can("set_$attr"); |
18
|
|
|
|
|
|
|
my $new = sub { |
19
|
90
|
|
|
90
|
|
45
|
my $self = shift; |
|
|
|
|
74
|
|
|
|
20
|
90
|
|
|
|
|
162
|
my $out = $self->$old(@_); |
21
|
90
|
|
|
|
|
207
|
$self->verify_scaffold; |
22
|
90
|
|
|
|
|
171
|
return $out; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
48
|
|
|
48
|
|
13429
|
no strict 'refs'; |
|
48
|
|
|
|
|
95
|
|
|
48
|
|
|
|
|
1486
|
|
26
|
48
|
|
|
48
|
|
247
|
no warnings 'redefine'; |
|
48
|
|
|
|
|
40
|
|
|
48
|
|
|
|
|
27398
|
|
27
|
|
|
|
|
|
|
*{"set_$attr"} = $new; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub init { |
31
|
1300
|
|
|
1276
|
0
|
4379
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
1300
|
|
100
|
|
|
4568
|
$self->{+EVENTS} ||= []; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
{ |
36
|
1300
|
|
|
|
|
1074
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
|
1300
|
|
|
|
|
1272
|
|
37
|
1300
|
|
|
|
|
2728
|
$self->SUPER::init(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->throw("the 'name' attribute is required") |
41
|
1300
|
50
|
|
|
|
1961
|
unless $self->{+NAME}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->throw("the 'flat' attribute cannot be combined with 'iso' or 'async'") |
44
|
1300
|
50
|
33
|
|
|
2233
|
if $self->{+FLAT} && ($self->{+ISO} || $self->{+ASYNC}); |
|
|
|
66
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
1300
|
|
|
|
|
2694
|
$self->set_subname($self->package . "::<$self->{+NAME}>"); |
47
|
|
|
|
|
|
|
|
48
|
1300
|
|
|
|
|
4120
|
$self->verify_scaffold; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub clone { |
52
|
419
|
|
|
443
|
0
|
349
|
my $self = shift; |
53
|
419
|
|
|
|
|
2131
|
return bless {%$self}, blessed($self); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub verify_scaffold { |
57
|
1390
|
|
|
1356
|
0
|
1061
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
1390
|
100
|
|
|
|
3322
|
return unless $self->{+SCAFFOLD}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
croak "The 'flat' attribute must be true for scaffolding" |
62
|
216
|
50
|
33
|
|
|
400
|
if defined($self->{+FLAT}) && !$self->{+FLAT}; |
63
|
|
|
|
|
|
|
|
64
|
216
|
|
|
|
|
220
|
$self->{+FLAT} = 1; |
65
|
|
|
|
|
|
|
|
66
|
216
|
|
|
|
|
323
|
for my $attr (ISO, ASYNC, TODO, SKIP) { |
67
|
|
|
|
|
|
|
croak "The '$attr' attribute cannot be used on scaffolding" |
68
|
864
|
50
|
|
|
|
1451
|
if $self->{$attr}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub exception { |
73
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
74
|
0
|
|
|
|
|
0
|
my ($err) = @_; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
my $trace = $self->trace; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
Test2::API::test2_stack->top->send( |
79
|
|
|
|
|
|
|
Test2::Event::Exception->new( |
80
|
|
|
|
|
|
|
trace => $trace, |
81
|
|
|
|
|
|
|
error => $err, |
82
|
|
|
|
|
|
|
) |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub filter { |
87
|
663
|
|
|
663
|
0
|
503
|
my $self = shift; |
88
|
663
|
|
|
|
|
444
|
my ($filter) = @_; |
89
|
|
|
|
|
|
|
|
90
|
663
|
50
|
|
|
|
778
|
return unless $filter; |
91
|
663
|
50
|
|
|
|
809
|
return if $self->{+IS_ROOT}; |
92
|
663
|
100
|
|
|
|
819
|
return if $self->{+SCAFFOLD}; |
93
|
|
|
|
|
|
|
|
94
|
601
|
100
|
|
|
|
766
|
if (my $name = $filter->{name}) { |
95
|
398
|
|
|
|
|
283
|
my $ok = 0; |
96
|
398
|
50
|
|
|
|
487
|
unless(ref($name)) { |
97
|
398
|
|
66
|
|
|
952
|
$ok ||= $self->{+NAME} eq $name; |
98
|
398
|
|
66
|
|
|
825
|
$ok ||= $self->subname eq $name; |
99
|
|
|
|
|
|
|
} |
100
|
398
|
50
|
|
|
|
795
|
if (ref($name) eq 'Regexp') { |
|
|
50
|
|
|
|
|
|
101
|
0
|
|
0
|
|
|
0
|
$ok ||= $self->{+NAME} =~ $name; |
102
|
0
|
|
0
|
|
|
0
|
$ok ||= $self->subname =~ $name; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
elsif ($name =~ m{^/}) { |
105
|
0
|
0
|
|
|
|
0
|
my $pattern = eval "qr$name" or die "'$name' does not appear to be a valid pattern"; |
106
|
0
|
|
0
|
|
|
0
|
$ok ||= $self->{+NAME} =~ $pattern; |
107
|
0
|
|
0
|
|
|
0
|
$ok ||= $self->subname =~ $pattern; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
398
|
100
|
|
|
|
1166
|
return {skip => "Does not match name filter '$name'"} |
111
|
|
|
|
|
|
|
unless $ok; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
250
|
50
|
|
|
|
310
|
if (my $file = $filter->{file}) { |
115
|
0
|
0
|
|
|
|
0
|
return {skip => "Does not match file filter '$file'"} |
116
|
|
|
|
|
|
|
unless $self->file eq $file; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
250
|
100
|
|
|
|
326
|
if (my $line = $filter->{line}) { |
120
|
203
|
|
|
|
|
339
|
my $lines = $self->lines; |
121
|
|
|
|
|
|
|
|
122
|
203
|
50
|
33
|
|
|
559
|
return {skip => "Does not match line filter '$line' (no lines)"} |
123
|
|
|
|
|
|
|
unless $lines && @$lines; |
124
|
|
|
|
|
|
|
|
125
|
203
|
|
|
|
|
240
|
my $min = min(@$lines); |
126
|
203
|
|
|
|
|
198
|
my $max = max(@$lines); |
127
|
|
|
|
|
|
|
|
128
|
203
|
100
|
100
|
|
|
909
|
return {skip => "Does not match line filter '$min <= $line <= $max'"} |
129
|
|
|
|
|
|
|
unless $min <= $line && $max >= $line; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
78
|
|
|
|
|
125
|
return; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |