line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Workflow; |
2
|
44
|
|
|
44
|
|
204442
|
use strict; |
|
44
|
|
|
|
|
45
|
|
|
44
|
|
|
|
|
875
|
|
3
|
44
|
|
|
44
|
|
122
|
use warnings; |
|
44
|
|
|
|
|
25
|
|
|
44
|
|
|
|
|
1692
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = "0.000017"; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/parse_args current_build build root_build init_root build_stack/; |
8
|
44
|
|
|
44
|
|
132
|
use base 'Exporter'; |
|
44
|
|
|
|
|
45
|
|
|
44
|
|
|
|
|
2164
|
|
9
|
|
|
|
|
|
|
|
10
|
44
|
|
|
44
|
|
13091
|
use Test2::Workflow::Build; |
|
44
|
|
|
|
|
64
|
|
|
44
|
|
|
|
|
818
|
|
11
|
44
|
|
|
44
|
|
177
|
use Test2::Workflow::Task::Group; |
|
44
|
|
|
|
|
43
|
|
|
44
|
|
|
|
|
1094
|
|
12
|
44
|
|
|
44
|
|
115
|
use Test2::API qw/intercept/; |
|
44
|
|
|
|
|
43
|
|
|
44
|
|
|
|
|
1553
|
|
13
|
44
|
|
|
44
|
|
141
|
use Scalar::Util qw/blessed/; |
|
44
|
|
|
|
|
44
|
|
|
44
|
|
|
|
|
24165
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub parse_args { |
16
|
734
|
|
|
734
|
1
|
1281
|
my %input = @_; |
17
|
734
|
|
|
|
|
837
|
my $args = delete $input{args}; |
18
|
734
|
|
|
|
|
613
|
my %out; |
19
|
|
|
|
|
|
|
my %props; |
20
|
|
|
|
|
|
|
|
21
|
734
|
|
33
|
|
|
1539
|
my $caller = $out{frame} = $input{caller} || caller(defined $input{level} ? $input{level} : 1); |
22
|
734
|
|
|
|
|
934
|
delete @input{qw/caller level/}; |
23
|
|
|
|
|
|
|
|
24
|
734
|
|
|
|
|
903
|
for my $arg (@$args) { |
25
|
1692
|
100
|
|
|
|
2939
|
if (my $r = ref($arg)) { |
26
|
958
|
100
|
|
|
|
1674
|
if ($r eq 'HASH') { |
|
|
50
|
|
|
|
|
|
27
|
224
|
|
|
|
|
533
|
%props = (%props, %$arg); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif ($r eq 'CODE') { |
30
|
|
|
|
|
|
|
die "Code is already set, did you provide multiple code blocks at $caller->[1] line $caller->[2].\n" |
31
|
734
|
50
|
|
|
|
1114
|
if $out{code}; |
32
|
|
|
|
|
|
|
|
33
|
734
|
|
|
|
|
798
|
$out{code} = $arg |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
else { |
36
|
0
|
|
|
|
|
0
|
die "Not sure what to do with $arg at $caller->[1] line $caller->[2].\n"; |
37
|
|
|
|
|
|
|
} |
38
|
958
|
|
|
|
|
1155
|
next; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
734
|
50
|
|
|
|
1822
|
if ($arg =~ m/^\d+$/) { |
42
|
0
|
|
|
|
|
0
|
push @{$out{lines}} => $arg; |
|
0
|
|
|
|
|
0
|
|
43
|
0
|
|
|
|
|
0
|
next; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
die "Name is already set to '$out{name}', cannot set to '$arg', did you specify multiple names at $caller->[1] line $caller->[2].\n" |
47
|
734
|
50
|
|
|
|
1113
|
if $out{name}; |
48
|
|
|
|
|
|
|
|
49
|
734
|
|
|
|
|
924
|
$out{name} = $arg; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
die "a name must be provided, and must be truthy at $caller->[1] line $caller->[2].\n" |
53
|
734
|
50
|
|
|
|
1062
|
unless $out{name}; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
die "a codeblock must be provided at $caller->[1] line $caller->[2].\n" |
56
|
734
|
50
|
|
|
|
1031
|
unless $out{code}; |
57
|
|
|
|
|
|
|
|
58
|
734
|
|
|
|
|
3027
|
return { %props, %out, %input }; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
my %ROOT_BUILDS; |
63
|
|
|
|
|
|
|
my @BUILD_STACK; |
64
|
|
|
|
|
|
|
|
65
|
835
|
|
|
835
|
1
|
1870
|
sub root_build { $ROOT_BUILDS{$_[0]} } |
66
|
725
|
100
|
|
725
|
1
|
2994
|
sub current_build { @BUILD_STACK ? $BUILD_STACK[-1] : undef } |
67
|
642
|
|
|
642
|
0
|
1000
|
sub build_stack { @BUILD_STACK } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub init_root { |
70
|
42
|
|
|
42
|
1
|
127
|
my ($pkg, %args) = @_; |
71
|
42
|
|
33
|
|
|
356
|
$ROOT_BUILDS{$pkg} ||= Test2::Workflow::Build->new( |
72
|
|
|
|
|
|
|
name => $pkg, |
73
|
|
|
|
|
|
|
flat => 1, |
74
|
|
|
|
|
|
|
iso => 0, |
75
|
|
|
|
|
|
|
async => 0, |
76
|
|
|
|
|
|
|
is_root => 1, |
77
|
|
|
|
|
|
|
%args, |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
42
|
|
|
|
|
326
|
return $ROOT_BUILDS{$pkg}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub build { |
84
|
91
|
|
|
91
|
1
|
239
|
my %params = @_; |
85
|
91
|
|
|
|
|
208
|
my $args = parse_args(%params); |
86
|
|
|
|
|
|
|
|
87
|
91
|
|
|
|
|
593
|
my $build = Test2::Workflow::Build->new(%$args); |
88
|
|
|
|
|
|
|
|
89
|
91
|
100
|
|
|
|
382
|
return $build if $args->{skip}; |
90
|
|
|
|
|
|
|
|
91
|
86
|
|
|
|
|
85
|
push @BUILD_STACK => $build; |
92
|
|
|
|
|
|
|
|
93
|
86
|
|
|
|
|
82
|
my ($ok, $err); |
94
|
|
|
|
|
|
|
my $events = intercept { |
95
|
86
|
100
|
|
86
|
|
56348
|
my $todo = $args->{todo} ? Test2::Todo->new(reason => $args->{todo}) : undef; |
96
|
86
|
|
|
|
|
329
|
$ok = eval { $args->{code}->(); 1 }; |
|
86
|
|
|
|
|
183
|
|
|
81
|
|
|
|
|
121
|
|
97
|
86
|
|
|
|
|
2150
|
$err = $@; |
98
|
86
|
100
|
|
|
|
230
|
$todo->end if $todo; |
99
|
86
|
|
|
|
|
466
|
}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Clear the stash |
102
|
86
|
|
|
|
|
36175
|
$build->{stash} = []; |
103
|
86
|
|
|
|
|
313
|
$build->set_events($events); |
104
|
|
|
|
|
|
|
|
105
|
86
|
|
|
|
|
1117
|
pop @BUILD_STACK; |
106
|
|
|
|
|
|
|
|
107
|
86
|
100
|
|
|
|
205
|
unless($ok) { |
108
|
5
|
|
|
|
|
35
|
my $hub = Test2::API::test2_stack->top; |
109
|
5
|
|
|
|
|
45
|
my $count = @$events; |
110
|
5
|
50
|
|
|
|
50
|
my $list = $count |
111
|
|
|
|
|
|
|
? "Overview of unseen events:\n" . join "" => map " " . blessed($_) . " " . $_->trace->debug . "\n", @$events |
112
|
|
|
|
|
|
|
: ""; |
113
|
5
|
|
|
|
|
205
|
die <<" EOT"; |
114
|
|
|
|
|
|
|
Exception in build '$args->{name}' with $count unseen event(s). |
115
|
|
|
|
|
|
|
$err |
116
|
|
|
|
|
|
|
$list |
117
|
|
|
|
|
|
|
EOT |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
81
|
|
|
|
|
315
|
return $build; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |