line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow::Build; |
2
|
45
|
|
|
45
|
|
129956
|
use strict; |
|
45
|
|
|
|
|
48
|
|
|
45
|
|
|
|
|
989
|
|
3
|
45
|
|
|
45
|
|
140
|
use warnings; |
|
45
|
|
|
|
|
53
|
|
|
45
|
|
|
|
|
935
|
|
4
|
|
|
|
|
|
|
|
5
|
45
|
|
|
45
|
|
14331
|
use Test2::Workflow::Task::Group; |
|
45
|
|
|
|
|
64
|
|
|
45
|
|
|
|
|
1889
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @BUILD_FIELDS; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
10
|
45
|
|
|
45
|
|
777
|
@BUILD_FIELDS = qw{ |
11
|
|
|
|
|
|
|
primary variant |
12
|
|
|
|
|
|
|
setup teardown |
13
|
|
|
|
|
|
|
variant_setup variant_teardown |
14
|
|
|
|
|
|
|
primary_setup primary_teardown |
15
|
|
|
|
|
|
|
stash |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
45
|
|
|
45
|
|
192
|
use base 'Test2::Workflow::Task'; |
|
45
|
|
|
|
|
38
|
|
|
45
|
|
|
|
|
2675
|
|
20
|
45
|
|
|
45
|
|
156
|
use Test2::Util::HashBase @BUILD_FIELDS, qw/events defaults stack_stop/; |
|
45
|
|
|
|
|
58
|
|
|
45
|
|
|
|
|
163
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init { |
23
|
133
|
|
|
133
|
0
|
1274
|
my $self = shift; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
{ |
26
|
133
|
|
|
|
|
136
|
local $Carp::CarpLevel = $Carp::CarpLevel + 1; |
|
133
|
|
|
|
|
216
|
|
27
|
133
|
|
|
|
|
590
|
$self->SUPER::init(); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
133
|
|
50
|
|
|
2899
|
$self->{$_} ||= [] for @BUILD_FIELDS; |
31
|
133
|
|
50
|
|
|
647
|
$self->{+DEFAULTS} ||= {}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
for my $field (@BUILD_FIELDS) { |
35
|
|
|
|
|
|
|
my $code = sub { |
36
|
777
|
|
|
777
|
|
1872
|
my $self = shift; |
37
|
777
|
|
|
|
|
577
|
push @{$self->{$field}} => @_; |
|
777
|
|
|
|
|
3336
|
|
38
|
|
|
|
|
|
|
}; |
39
|
45
|
|
|
45
|
|
16356
|
no strict 'refs'; |
|
45
|
|
|
|
|
45
|
|
|
45
|
|
|
|
|
15464
|
|
40
|
|
|
|
|
|
|
*{"add_$field"} = $code; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub populated { |
44
|
181
|
|
|
181
|
0
|
202
|
my $self = shift; |
45
|
181
|
|
|
|
|
269
|
for my $field (@BUILD_FIELDS) { |
46
|
237
|
100
|
|
|
|
196
|
return 1 if @{$self->{$field}}; |
|
237
|
|
|
|
|
913
|
|
47
|
|
|
|
|
|
|
} |
48
|
7
|
|
|
|
|
49
|
return 0; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub compile { |
52
|
143
|
|
|
143
|
0
|
156
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
warn "Workflow build '$self->{+NAME}' is empty " . $self->debug . "\n" |
55
|
143
|
50
|
66
|
|
|
343
|
unless $self->populated || $self->{+SKIP}; |
56
|
|
|
|
|
|
|
|
57
|
143
|
|
|
|
|
408
|
my ($primary_setup, $primary_teardown) = @_; |
58
|
143
|
|
100
|
|
|
455
|
$primary_setup ||= []; |
59
|
143
|
|
100
|
|
|
368
|
$primary_teardown ||= []; |
60
|
|
|
|
|
|
|
|
61
|
143
|
|
|
|
|
171
|
my $variant = $self->{+VARIANT}; |
62
|
143
|
|
|
|
|
159
|
my $setup = $self->{+SETUP}; |
63
|
143
|
|
|
|
|
150
|
my $teardown = $self->{+TEARDOWN}; |
64
|
143
|
|
|
|
|
154
|
my $variant_setup = $self->{+VARIANT_SETUP}; |
65
|
143
|
|
|
|
|
148
|
my $variant_teardown = $self->{+VARIANT_TEARDOWN}; |
66
|
|
|
|
|
|
|
|
67
|
143
|
|
|
|
|
170
|
$primary_setup = [@$primary_setup, @{$self->{+PRIMARY_SETUP}}]; |
|
143
|
|
|
|
|
238
|
|
68
|
143
|
|
|
|
|
164
|
$primary_teardown = [@{$self->{+PRIMARY_TEARDOWN}}, @$primary_teardown]; |
|
143
|
|
|
|
|
217
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Get primaries in order. |
71
|
|
|
|
|
|
|
my $primary = [ |
72
|
|
|
|
|
|
|
map { |
73
|
524
|
100
|
|
|
|
2358
|
$_->isa(__PACKAGE__) |
74
|
|
|
|
|
|
|
? $_->compile($primary_setup, $primary_teardown) |
75
|
|
|
|
|
|
|
: $_; |
76
|
143
|
|
|
|
|
138
|
} @{$self->{+PRIMARY}}, |
|
143
|
|
|
|
|
215
|
|
77
|
|
|
|
|
|
|
]; |
78
|
|
|
|
|
|
|
|
79
|
143
|
100
|
66
|
|
|
777
|
if (@$primary_setup || @$primary_teardown) { |
80
|
|
|
|
|
|
|
$primary = [ |
81
|
|
|
|
|
|
|
map { |
82
|
83
|
|
|
|
|
105
|
my $p = $_->clone; |
|
311
|
|
|
|
|
1149
|
|
83
|
311
|
100
|
|
|
|
1546
|
$_->isa('Test2::Workflow::Task::Action') ? Test2::Workflow::Task::Group->new( |
84
|
|
|
|
|
|
|
before => $primary_setup, |
85
|
|
|
|
|
|
|
primary => [ $p ], |
86
|
|
|
|
|
|
|
take => $p, |
87
|
|
|
|
|
|
|
after => $primary_teardown, |
88
|
|
|
|
|
|
|
) : $_; |
89
|
|
|
|
|
|
|
} @$primary |
90
|
|
|
|
|
|
|
]; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Build variants |
94
|
143
|
100
|
|
|
|
498
|
if (@$variant) { |
95
|
|
|
|
|
|
|
$primary = [ |
96
|
|
|
|
|
|
|
map { |
97
|
54
|
|
|
|
|
107
|
my $v = $_->clone; |
|
108
|
|
|
|
|
330
|
|
98
|
108
|
|
|
|
|
319
|
Test2::Workflow::Task::Group->new( |
99
|
|
|
|
|
|
|
before => $variant_setup, |
100
|
|
|
|
|
|
|
primary => $primary, |
101
|
|
|
|
|
|
|
after => $variant_teardown, |
102
|
|
|
|
|
|
|
variant => $v, |
103
|
|
|
|
|
|
|
take => $v, |
104
|
|
|
|
|
|
|
); |
105
|
|
|
|
|
|
|
} @$variant |
106
|
|
|
|
|
|
|
]; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
143
|
100
|
|
|
|
720
|
my %params = map { Test2::Workflow::Task::Group->can($_) ? ($_ => $self->{$_}) : () } keys %$self; |
|
2306
|
|
|
|
|
6286
|
|
110
|
143
|
|
|
|
|
752
|
delete $params{$_} for @BUILD_FIELDS; |
111
|
|
|
|
|
|
|
|
112
|
143
|
|
|
|
|
552
|
return Test2::Workflow::Task::Group->new( |
113
|
|
|
|
|
|
|
%params, |
114
|
|
|
|
|
|
|
before => $setup, |
115
|
|
|
|
|
|
|
after => $teardown, |
116
|
|
|
|
|
|
|
primary => $primary, |
117
|
|
|
|
|
|
|
); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |