line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::Task; |
2
|
49
|
|
|
49
|
|
388
|
use strict; |
|
49
|
|
|
|
|
116
|
|
|
49
|
|
|
|
|
1353
|
|
3
|
49
|
|
|
49
|
|
245
|
use warnings; |
|
49
|
|
|
|
|
133
|
|
|
49
|
|
|
|
|
1899
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
6
|
|
|
|
|
|
|
|
7
|
49
|
|
|
49
|
|
289
|
use Test2::API(); |
|
49
|
|
|
|
|
120
|
|
|
49
|
|
|
|
|
1044
|
|
8
|
49
|
|
|
49
|
|
274
|
use Test2::Event::Exception(); |
|
49
|
|
|
|
|
87
|
|
|
49
|
|
|
|
|
1088
|
|
9
|
|
|
|
|
|
|
|
10
|
49
|
|
|
49
|
|
299
|
use List::Util qw/min max/; |
|
49
|
|
|
|
|
213
|
|
|
49
|
|
|
|
|
3965
|
|
11
|
49
|
|
|
49
|
|
392
|
use Scalar::Util qw/blessed/; |
|
49
|
|
|
|
|
129
|
|
|
49
|
|
|
|
|
2361
|
|
12
|
49
|
|
|
49
|
|
440
|
use Carp qw/croak/; |
|
49
|
|
|
|
|
110
|
|
|
49
|
|
|
|
|
3300
|
|
13
|
|
|
|
|
|
|
our @CARP_NOT = qw/Test2::Util::HashBase/; |
14
|
|
|
|
|
|
|
|
15
|
49
|
|
|
49
|
|
322
|
use base 'Test2::Workflow::BlockBase'; |
|
49
|
|
|
|
|
155
|
|
|
49
|
|
|
|
|
20427
|
|
16
|
49
|
|
|
49
|
|
335
|
use Test2::Util::HashBase qw/name flat async iso todo skip scaffold events is_root/; |
|
49
|
|
|
|
|
130
|
|
|
49
|
|
|
|
|
313
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
for my $attr (FLAT, ISO, ASYNC, TODO, SKIP, SCAFFOLD) { |
19
|
|
|
|
|
|
|
my $old = __PACKAGE__->can("set_$attr"); |
20
|
|
|
|
|
|
|
my $new = sub { |
21
|
90
|
|
|
90
|
|
153
|
my $self = shift; |
|
|
|
|
70
|
|
|
|
22
|
90
|
|
|
|
|
207
|
my $out = $self->$old(@_); |
23
|
90
|
|
|
|
|
387
|
$self->verify_scaffold; |
24
|
90
|
|
|
|
|
243
|
return $out; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
49
|
|
|
49
|
|
27246
|
no strict 'refs'; |
|
49
|
|
|
|
|
107
|
|
|
49
|
|
|
|
|
1780
|
|
28
|
49
|
|
|
49
|
|
302
|
no warnings 'redefine'; |
|
49
|
|
|
|
|
95
|
|
|
49
|
|
|
|
|
36785
|
|
29
|
|
|
|
|
|
|
*{"set_$attr"} = $new; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
33
|
1308
|
|
|
1308
|
0
|
10443
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
1308
|
|
100
|
|
|
6869
|
$self->{+EVENTS} ||= []; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
{ |
38
|
1308
|
|
|
|
|
1912
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
|
1308
|
|
|
|
|
2327
|
|
39
|
1308
|
|
|
|
|
4744
|
$self->SUPER::init(); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->throw("the 'name' attribute is required") |
43
|
1308
|
50
|
|
|
|
2763
|
unless $self->{+NAME}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->throw("the 'flat' attribute cannot be combined with 'iso' or 'async'") |
46
|
1308
|
50
|
33
|
|
|
6144
|
if $self->{+FLAT} && ($self->{+ISO} || $self->{+ASYNC}); |
|
|
|
66
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
1308
|
|
|
|
|
3691
|
$self->set_subname($self->package . "::<$self->{+NAME}>"); |
49
|
|
|
|
|
|
|
|
50
|
1308
|
|
|
|
|
3527
|
$self->verify_scaffold; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub clone { |
54
|
419
|
|
|
419
|
0
|
709
|
my $self = shift; |
55
|
419
|
|
|
|
|
3849
|
return bless {%$self}, blessed($self); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub verify_scaffold { |
59
|
1398
|
|
|
1398
|
0
|
2335
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
1398
|
100
|
|
|
|
4448
|
return unless $self->{+SCAFFOLD}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
croak "The 'flat' attribute must be true for scaffolding" |
64
|
217
|
50
|
33
|
|
|
643
|
if defined($self->{+FLAT}) && !$self->{+FLAT}; |
65
|
|
|
|
|
|
|
|
66
|
217
|
|
|
|
|
369
|
$self->{+FLAT} = 1; |
67
|
|
|
|
|
|
|
|
68
|
217
|
|
|
|
|
578
|
for my $attr (ISO, ASYNC, TODO, SKIP) { |
69
|
|
|
|
|
|
|
croak "The '$attr' attribute cannot be used on scaffolding" |
70
|
868
|
50
|
|
|
|
2062
|
if $self->{$attr}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub exception { |
75
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
76
|
0
|
|
|
|
|
0
|
my ($err) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
my $hub = Test2::API::test2_stack->top; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
my $trace = $self->trace($hub); |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
$hub->send( |
83
|
|
|
|
|
|
|
Test2::Event::Exception->new( |
84
|
|
|
|
|
|
|
trace => $trace, |
85
|
|
|
|
|
|
|
error => $err, |
86
|
|
|
|
|
|
|
), |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub filter { |
91
|
663
|
|
|
663
|
0
|
970
|
my $self = shift; |
92
|
663
|
|
|
|
|
1143
|
my ($filter) = @_; |
93
|
|
|
|
|
|
|
|
94
|
663
|
50
|
|
|
|
1232
|
return unless $filter; |
95
|
663
|
50
|
|
|
|
1305
|
return if $self->{+IS_ROOT}; |
96
|
663
|
100
|
|
|
|
1306
|
return if $self->{+SCAFFOLD}; |
97
|
|
|
|
|
|
|
|
98
|
601
|
100
|
|
|
|
1246
|
if (my $name = $filter->{name}) { |
99
|
398
|
|
|
|
|
607
|
my $ok = 0; |
100
|
398
|
50
|
|
|
|
837
|
unless(ref($name)) { |
101
|
398
|
|
66
|
|
|
1581
|
$ok ||= $self->{+NAME} eq $name; |
102
|
398
|
|
66
|
|
|
1145
|
$ok ||= $self->subname eq $name; |
103
|
|
|
|
|
|
|
} |
104
|
398
|
50
|
|
|
|
1239
|
if (ref($name) eq 'Regexp') { |
|
|
50
|
|
|
|
|
|
105
|
0
|
|
0
|
|
|
0
|
$ok ||= $self->{+NAME} =~ $name; |
106
|
0
|
|
0
|
|
|
0
|
$ok ||= $self->subname =~ $name; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
elsif ($name =~ m{^/}) { |
109
|
0
|
0
|
|
|
|
0
|
my $pattern = eval "qr$name" or die "'$name' does not appear to be a valid pattern"; |
110
|
0
|
|
0
|
|
|
0
|
$ok ||= $self->{+NAME} =~ $pattern; |
111
|
0
|
|
0
|
|
|
0
|
$ok ||= $self->subname =~ $pattern; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
398
|
100
|
|
|
|
1716
|
return {skip => "Does not match name filter '$name'"} |
115
|
|
|
|
|
|
|
unless $ok; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
250
|
50
|
|
|
|
511
|
if (my $file = $filter->{file}) { |
119
|
0
|
0
|
|
|
|
0
|
return {skip => "Does not match file filter '$file'"} |
120
|
|
|
|
|
|
|
unless $self->file eq $file; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
250
|
100
|
|
|
|
501
|
if (my $line = $filter->{line}) { |
124
|
203
|
|
|
|
|
453
|
my $lines = $self->lines; |
125
|
|
|
|
|
|
|
|
126
|
203
|
50
|
33
|
|
|
714
|
return {skip => "Does not match line filter '$line' (no lines)"} |
127
|
|
|
|
|
|
|
unless $lines && @$lines; |
128
|
|
|
|
|
|
|
|
129
|
203
|
|
|
|
|
450
|
my $min = min(@$lines); |
130
|
203
|
|
|
|
|
356
|
my $max = max(@$lines); |
131
|
|
|
|
|
|
|
|
132
|
203
|
100
|
100
|
|
|
1236
|
return {skip => "Does not match line filter '$min <= $line <= $max'"} |
133
|
|
|
|
|
|
|
unless $min <= $line && $max >= $line; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
78
|
|
|
|
|
217
|
return; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |