line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::Task; |
2
|
49
|
|
|
49
|
|
356
|
use strict; |
|
49
|
|
|
|
|
109
|
|
|
49
|
|
|
|
|
1344
|
|
3
|
49
|
|
|
49
|
|
234
|
use warnings; |
|
49
|
|
|
|
|
102
|
|
|
49
|
|
|
|
|
2139
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
6
|
|
|
|
|
|
|
|
7
|
49
|
|
|
49
|
|
292
|
use Test2::API(); |
|
49
|
|
|
|
|
83
|
|
|
49
|
|
|
|
|
757
|
|
8
|
49
|
|
|
49
|
|
250
|
use Test2::Event::Exception(); |
|
49
|
|
|
|
|
91
|
|
|
49
|
|
|
|
|
1308
|
|
9
|
|
|
|
|
|
|
|
10
|
49
|
|
|
49
|
|
323
|
use List::Util qw/min max/; |
|
49
|
|
|
|
|
104
|
|
|
49
|
|
|
|
|
3698
|
|
11
|
49
|
|
|
49
|
|
464
|
use Scalar::Util qw/blessed/; |
|
49
|
|
|
|
|
198
|
|
|
49
|
|
|
|
|
2641
|
|
12
|
49
|
|
|
49
|
|
341
|
use Carp qw/croak/; |
|
49
|
|
|
|
|
107
|
|
|
49
|
|
|
|
|
3530
|
|
13
|
|
|
|
|
|
|
our @CARP_NOT = qw/Test2::Util::HashBase/; |
14
|
|
|
|
|
|
|
|
15
|
49
|
|
|
49
|
|
340
|
use base 'Test2::Workflow::BlockBase'; |
|
49
|
|
|
|
|
106
|
|
|
49
|
|
|
|
|
22223
|
|
16
|
49
|
|
|
49
|
|
405
|
use Test2::Util::HashBase qw/name flat async iso todo skip scaffold events is_root/; |
|
49
|
|
|
|
|
134
|
|
|
49
|
|
|
|
|
352
|
|
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; |
|
|
|
|
40
|
|
|
|
22
|
90
|
|
|
|
|
207
|
my $out = $self->$old(@_); |
23
|
90
|
|
|
|
|
360
|
$self->verify_scaffold; |
24
|
90
|
|
|
|
|
270
|
return $out; |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
49
|
|
|
49
|
|
27529
|
no strict 'refs'; |
|
49
|
|
|
|
|
108
|
|
|
49
|
|
|
|
|
1775
|
|
28
|
49
|
|
|
49
|
|
296
|
no warnings 'redefine'; |
|
49
|
|
|
|
|
100
|
|
|
49
|
|
|
|
|
38289
|
|
29
|
|
|
|
|
|
|
*{"set_$attr"} = $new; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub init { |
33
|
1308
|
|
|
1308
|
0
|
9764
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
1308
|
|
100
|
|
|
6616
|
$self->{+EVENTS} ||= []; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
{ |
38
|
1308
|
|
|
|
|
1967
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
|
1308
|
|
|
|
|
2702
|
|
39
|
1308
|
|
|
|
|
3966
|
$self->SUPER::init(); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$self->throw("the 'name' attribute is required") |
43
|
1308
|
50
|
|
|
|
2592
|
unless $self->{+NAME}; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$self->throw("the 'flat' attribute cannot be combined with 'iso' or 'async'") |
46
|
1308
|
50
|
33
|
|
|
5343
|
if $self->{+FLAT} && ($self->{+ISO} || $self->{+ASYNC}); |
|
|
|
66
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
1308
|
|
|
|
|
3537
|
$self->set_subname($self->package . "::<$self->{+NAME}>"); |
49
|
|
|
|
|
|
|
|
50
|
1308
|
|
|
|
|
3524
|
$self->verify_scaffold; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub clone { |
54
|
419
|
|
|
419
|
0
|
693
|
my $self = shift; |
55
|
419
|
|
|
|
|
3294
|
return bless {%$self}, blessed($self); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub verify_scaffold { |
59
|
1398
|
|
|
1398
|
0
|
2235
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
1398
|
100
|
|
|
|
4190
|
return unless $self->{+SCAFFOLD}; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
croak "The 'flat' attribute must be true for scaffolding" |
64
|
217
|
50
|
33
|
|
|
667
|
if defined($self->{+FLAT}) && !$self->{+FLAT}; |
65
|
|
|
|
|
|
|
|
66
|
217
|
|
|
|
|
374
|
$self->{+FLAT} = 1; |
67
|
|
|
|
|
|
|
|
68
|
217
|
|
|
|
|
593
|
for my $attr (ISO, ASYNC, TODO, SKIP) { |
69
|
|
|
|
|
|
|
croak "The '$attr' attribute cannot be used on scaffolding" |
70
|
868
|
50
|
|
|
|
2287
|
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
|
963
|
my $self = shift; |
92
|
663
|
|
|
|
|
1048
|
my ($filter) = @_; |
93
|
|
|
|
|
|
|
|
94
|
663
|
50
|
|
|
|
1194
|
return unless $filter; |
95
|
663
|
50
|
|
|
|
1181
|
return if $self->{+IS_ROOT}; |
96
|
663
|
100
|
|
|
|
1299
|
return if $self->{+SCAFFOLD}; |
97
|
|
|
|
|
|
|
|
98
|
601
|
100
|
|
|
|
1119
|
if (my $name = $filter->{name}) { |
99
|
398
|
|
|
|
|
568
|
my $ok = 0; |
100
|
398
|
50
|
|
|
|
759
|
unless(ref($name)) { |
101
|
398
|
|
66
|
|
|
1466
|
$ok ||= $self->{+NAME} eq $name; |
102
|
398
|
|
66
|
|
|
1053
|
$ok ||= $self->subname eq $name; |
103
|
|
|
|
|
|
|
} |
104
|
398
|
50
|
|
|
|
1191
|
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
|
|
|
|
1631
|
return {skip => "Does not match name filter '$name'"} |
115
|
|
|
|
|
|
|
unless $ok; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
250
|
50
|
|
|
|
477
|
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
|
|
|
|
578
|
if (my $line = $filter->{line}) { |
124
|
203
|
|
|
|
|
478
|
my $lines = $self->lines; |
125
|
|
|
|
|
|
|
|
126
|
203
|
50
|
33
|
|
|
667
|
return {skip => "Does not match line filter '$line' (no lines)"} |
127
|
|
|
|
|
|
|
unless $lines && @$lines; |
128
|
|
|
|
|
|
|
|
129
|
203
|
|
|
|
|
391
|
my $min = min(@$lines); |
130
|
203
|
|
|
|
|
323
|
my $max = max(@$lines); |
131
|
|
|
|
|
|
|
|
132
|
203
|
100
|
100
|
|
|
1144
|
return {skip => "Does not match line filter '$min <= $line <= $max'"} |
133
|
|
|
|
|
|
|
unless $min <= $line && $max >= $line; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
78
|
|
|
|
|
173
|
return; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |