line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::Task; |
2
|
48
|
|
|
48
|
|
131335
|
use strict; |
|
48
|
|
|
|
|
57
|
|
|
48
|
|
|
|
|
989
|
|
3
|
48
|
|
|
48
|
|
133
|
use warnings; |
|
48
|
|
|
|
|
43
|
|
|
48
|
|
|
|
|
793
|
|
4
|
|
|
|
|
|
|
|
5
|
48
|
|
|
48
|
|
125
|
use Test2::API(); |
|
48
|
|
|
|
|
59
|
|
|
48
|
|
|
|
|
510
|
|
6
|
48
|
|
|
48
|
|
137
|
use Test2::Event::Exception(); |
|
48
|
|
|
|
|
56
|
|
|
48
|
|
|
|
|
625
|
|
7
|
|
|
|
|
|
|
|
8
|
48
|
|
|
48
|
|
122
|
use List::Util qw/min max/; |
|
48
|
|
|
|
|
49
|
|
|
48
|
|
|
|
|
2858
|
|
9
|
48
|
|
|
48
|
|
193
|
use Scalar::Util qw/blessed/; |
|
48
|
|
|
|
|
50
|
|
|
48
|
|
|
|
|
1622
|
|
10
|
48
|
|
|
48
|
|
157
|
use Carp qw/croak/; |
|
48
|
|
|
|
|
49
|
|
|
48
|
|
|
|
|
2007
|
|
11
|
|
|
|
|
|
|
our @CARP_NOT = qw/Test2::Util::HashBase/; |
12
|
|
|
|
|
|
|
|
13
|
48
|
|
|
48
|
|
152
|
use base 'Test2::Workflow::BlockBase'; |
|
48
|
|
|
|
|
49
|
|
|
48
|
|
|
|
|
15940
|
|
14
|
48
|
|
|
48
|
|
217
|
use Test2::Util::HashBase qw/name flat async iso todo skip scaffold events is_root/; |
|
48
|
|
|
|
|
59
|
|
|
48
|
|
|
|
|
291
|
|
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
|
|
54
|
my $self = shift; |
|
|
|
|
60
|
|
|
|
20
|
90
|
|
|
|
|
171
|
my $out = $self->$old(@_); |
21
|
90
|
|
|
|
|
216
|
$self->verify_scaffold; |
22
|
90
|
|
|
|
|
126
|
return $out; |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
48
|
|
|
48
|
|
12738
|
no strict 'refs'; |
|
48
|
|
|
|
|
44
|
|
|
48
|
|
|
|
|
1184
|
|
26
|
48
|
|
|
48
|
|
161
|
no warnings 'redefine'; |
|
48
|
|
|
|
|
40
|
|
|
48
|
|
|
|
|
25205
|
|
27
|
|
|
|
|
|
|
*{"set_$attr"} = $new; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub init { |
31
|
1300
|
|
|
1300
|
0
|
4453
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
1300
|
|
100
|
|
|
4673
|
$self->{+EVENTS} ||= []; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
{ |
36
|
1300
|
|
|
|
|
1004
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
|
1300
|
|
|
|
|
1248
|
|
37
|
1300
|
|
|
|
|
2847
|
$self->SUPER::init(); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->throw("the 'name' attribute is required") |
41
|
1300
|
50
|
|
|
|
1830
|
unless $self->{+NAME}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->throw("the 'flat' attribute cannot be combined with 'iso' or 'async'") |
44
|
1300
|
50
|
33
|
|
|
2290
|
if $self->{+FLAT} && ($self->{+ISO} || $self->{+ASYNC}); |
|
|
|
66
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
1300
|
|
|
|
|
2673
|
$self->set_subname($self->package . "::<$self->{+NAME}>"); |
47
|
|
|
|
|
|
|
|
48
|
1300
|
|
|
|
|
4190
|
$self->verify_scaffold; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub clone { |
52
|
419
|
|
|
419
|
0
|
320
|
my $self = shift; |
53
|
419
|
|
|
|
|
2244
|
return bless {%$self}, blessed($self); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub verify_scaffold { |
57
|
1390
|
|
|
1390
|
0
|
1107
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
1390
|
100
|
|
|
|
3536
|
return unless $self->{+SCAFFOLD}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
croak "The 'flat' attribute must be true for scaffolding" |
62
|
216
|
50
|
33
|
|
|
450
|
if defined($self->{+FLAT}) && !$self->{+FLAT}; |
63
|
|
|
|
|
|
|
|
64
|
216
|
|
|
|
|
191
|
$self->{+FLAT} = 1; |
65
|
|
|
|
|
|
|
|
66
|
216
|
|
|
|
|
372
|
for my $attr (ISO, ASYNC, TODO, SKIP) { |
67
|
|
|
|
|
|
|
croak "The '$attr' attribute cannot be used on scaffolding" |
68
|
864
|
50
|
|
|
|
1462
|
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
|
418
|
my $self = shift; |
88
|
663
|
|
|
|
|
437
|
my ($filter) = @_; |
89
|
|
|
|
|
|
|
|
90
|
663
|
50
|
|
|
|
757
|
return unless $filter; |
91
|
663
|
50
|
|
|
|
986
|
return if $self->{+IS_ROOT}; |
92
|
663
|
100
|
|
|
|
862
|
return if $self->{+SCAFFOLD}; |
93
|
|
|
|
|
|
|
|
94
|
601
|
100
|
|
|
|
770
|
if (my $name = $filter->{name}) { |
95
|
398
|
|
|
|
|
279
|
my $ok = 0; |
96
|
398
|
50
|
|
|
|
507
|
unless(ref($name)) { |
97
|
398
|
|
66
|
|
|
926
|
$ok ||= $self->{+NAME} eq $name; |
98
|
398
|
|
66
|
|
|
829
|
$ok ||= $self->subname eq $name; |
99
|
|
|
|
|
|
|
} |
100
|
398
|
50
|
|
|
|
918
|
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
|
|
|
|
1220
|
return {skip => "Does not match name filter '$name'"} |
111
|
|
|
|
|
|
|
unless $ok; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
250
|
50
|
|
|
|
300
|
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
|
|
|
|
329
|
if (my $line = $filter->{line}) { |
120
|
203
|
|
|
|
|
338
|
my $lines = $self->lines; |
121
|
|
|
|
|
|
|
|
122
|
203
|
50
|
33
|
|
|
554
|
return {skip => "Does not match line filter '$line' (no lines)"} |
123
|
|
|
|
|
|
|
unless $lines && @$lines; |
124
|
|
|
|
|
|
|
|
125
|
203
|
|
|
|
|
236
|
my $min = min(@$lines); |
126
|
203
|
|
|
|
|
193
|
my $max = max(@$lines); |
127
|
|
|
|
|
|
|
|
128
|
203
|
100
|
100
|
|
|
933
|
return {skip => "Does not match line filter '$min <= $line <= $max'"} |
129
|
|
|
|
|
|
|
unless $min <= $line && $max >= $line; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
78
|
|
|
|
|
137
|
return; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |