line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::Task; |
2
|
49
|
|
|
49
|
|
404
|
use strict; |
|
49
|
|
|
|
|
155
|
|
|
49
|
|
|
|
|
1421
|
|
3
|
49
|
|
|
49
|
|
242
|
use warnings; |
|
49
|
|
|
|
|
81
|
|
|
49
|
|
|
|
|
1713
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
6
|
|
|
|
|
|
|
|
7
|
49
|
|
|
49
|
|
276
|
use Test2::API(); |
|
49
|
|
|
|
|
129
|
|
|
49
|
|
|
|
|
1143
|
|
8
|
49
|
|
|
49
|
|
345
|
use Test2::Event::Exception(); |
|
49
|
|
|
|
|
99
|
|
|
49
|
|
|
|
|
1316
|
|
9
|
|
|
|
|
|
|
|
10
|
49
|
|
|
49
|
|
319
|
use List::Util qw/min max/; |
|
49
|
|
|
|
|
86
|
|
|
49
|
|
|
|
|
3912
|
|
11
|
49
|
|
|
49
|
|
351
|
use Scalar::Util qw/blessed/; |
|
49
|
|
|
|
|
98
|
|
|
49
|
|
|
|
|
2360
|
|
12
|
49
|
|
|
49
|
|
480
|
use Carp qw/croak/; |
|
49
|
|
|
|
|
272
|
|
|
49
|
|
|
|
|
3772
|
|
13
|
|
|
|
|
|
|
our @CARP_NOT = qw/Test2::Util::HashBase/; |
14
|
|
|
|
|
|
|
|
15
|
49
|
|
|
49
|
|
402
|
use base 'Test2::Workflow::BlockBase'; |
|
49
|
|
|
|
|
223
|
|
|
49
|
|
|
|
|
21837
|
|
16
|
49
|
|
|
49
|
|
377
|
use Test2::Util::HashBase qw/name flat async iso todo skip scaffold events is_root/; |
|
49
|
|
|
|
|
130
|
|
|
49
|
|
|
|
|
318
|
|
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
|
|
144
|
my $self = shift; |
|
|
|
|
80
|
|
|
|
22
|
90
|
|
|
|
|
216
|
my $out = $self->$old(@_); |
23
|
90
|
|
|
|
|
396
|
$self->verify_scaffold; |
24
|
90
|
|
|
|
|
207
|
return $out; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
49
|
|
|
49
|
|
27075
|
no strict 'refs'; |
|
49
|
|
|
|
|
180
|
|
|
49
|
|
|
|
|
1867
|
|
28
|
49
|
|
|
49
|
|
307
|
no warnings 'redefine'; |
|
49
|
|
|
|
|
100
|
|
|
49
|
|
|
|
|
38895
|
|
29
|
|
|
|
|
|
|
*{"set_$attr"} = $new; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
33
|
1308
|
|
|
1308
|
0
|
9341
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
1308
|
|
100
|
|
|
6025
|
$self->{+EVENTS} ||= []; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
{ |
38
|
1308
|
|
|
|
|
1804
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
|
1308
|
|
|
|
|
2048
|
|
39
|
1308
|
|
|
|
|
3654
|
$self->SUPER::init(); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->throw("the 'name' attribute is required") |
43
|
1308
|
50
|
|
|
|
2530
|
unless $self->{+NAME}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->throw("the 'flat' attribute cannot be combined with 'iso' or 'async'") |
46
|
1308
|
50
|
33
|
|
|
5312
|
if $self->{+FLAT} && ($self->{+ISO} || $self->{+ASYNC}); |
|
|
|
66
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
1308
|
|
|
|
|
3415
|
$self->set_subname($self->package . "::<$self->{+NAME}>"); |
49
|
|
|
|
|
|
|
|
50
|
1308
|
|
|
|
|
3595
|
$self->verify_scaffold; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub clone { |
54
|
419
|
|
|
419
|
0
|
635
|
my $self = shift; |
55
|
419
|
|
|
|
|
2946
|
return bless {%$self}, blessed($self); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub verify_scaffold { |
59
|
1398
|
|
|
1398
|
0
|
2167
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
1398
|
100
|
|
|
|
4008
|
return unless $self->{+SCAFFOLD}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
croak "The 'flat' attribute must be true for scaffolding" |
64
|
217
|
50
|
33
|
|
|
670
|
if defined($self->{+FLAT}) && !$self->{+FLAT}; |
65
|
|
|
|
|
|
|
|
66
|
217
|
|
|
|
|
335
|
$self->{+FLAT} = 1; |
67
|
|
|
|
|
|
|
|
68
|
217
|
|
|
|
|
600
|
for my $attr (ISO, ASYNC, TODO, SKIP) { |
69
|
|
|
|
|
|
|
croak "The '$attr' attribute cannot be used on scaffolding" |
70
|
868
|
50
|
|
|
|
1929
|
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
|
994
|
my $self = shift; |
92
|
663
|
|
|
|
|
1030
|
my ($filter) = @_; |
93
|
|
|
|
|
|
|
|
94
|
663
|
50
|
|
|
|
1383
|
return unless $filter; |
95
|
663
|
50
|
|
|
|
1302
|
return if $self->{+IS_ROOT}; |
96
|
663
|
100
|
|
|
|
1210
|
return if $self->{+SCAFFOLD}; |
97
|
|
|
|
|
|
|
|
98
|
601
|
100
|
|
|
|
1167
|
if (my $name = $filter->{name}) { |
99
|
398
|
|
|
|
|
586
|
my $ok = 0; |
100
|
398
|
50
|
|
|
|
819
|
unless(ref($name)) { |
101
|
398
|
|
66
|
|
|
1490
|
$ok ||= $self->{+NAME} eq $name; |
102
|
398
|
|
66
|
|
|
1042
|
$ok ||= $self->subname eq $name; |
103
|
|
|
|
|
|
|
} |
104
|
398
|
50
|
|
|
|
1192
|
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
|
|
|
|
1637
|
return {skip => "Does not match name filter '$name'"} |
115
|
|
|
|
|
|
|
unless $ok; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
250
|
50
|
|
|
|
567
|
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
|
|
|
|
508
|
if (my $line = $filter->{line}) { |
124
|
203
|
|
|
|
|
459
|
my $lines = $self->lines; |
125
|
|
|
|
|
|
|
|
126
|
203
|
50
|
33
|
|
|
662
|
return {skip => "Does not match line filter '$line' (no lines)"} |
127
|
|
|
|
|
|
|
unless $lines && @$lines; |
128
|
|
|
|
|
|
|
|
129
|
203
|
|
|
|
|
438
|
my $min = min(@$lines); |
130
|
203
|
|
|
|
|
317
|
my $max = max(@$lines); |
131
|
|
|
|
|
|
|
|
132
|
203
|
100
|
100
|
|
|
1181
|
return {skip => "Does not match line filter '$min <= $line <= $max'"} |
133
|
|
|
|
|
|
|
unless $min <= $line && $max >= $line; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
78
|
|
|
|
|
186
|
return; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |