line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Workflow::Block; |
2
|
137
|
|
|
137
|
|
714
|
use strict; |
|
137
|
|
|
|
|
247
|
|
|
137
|
|
|
|
|
2888
|
|
3
|
137
|
|
|
137
|
|
501
|
use warnings; |
|
137
|
|
|
|
|
232
|
|
|
137
|
|
|
|
|
2941
|
|
4
|
|
|
|
|
|
|
|
5
|
137
|
|
|
137
|
|
847
|
use Fennec::Util qw/accessors/; |
|
137
|
|
|
|
|
224
|
|
|
137
|
|
|
|
|
710
|
|
6
|
137
|
|
|
137
|
|
25898
|
use Carp qw/croak/; |
|
137
|
|
|
|
|
224
|
|
|
137
|
|
|
|
|
5872
|
|
7
|
137
|
|
|
137
|
|
773
|
use B (); |
|
137
|
|
|
|
|
245
|
|
|
137
|
|
|
|
|
2948
|
|
8
|
137
|
|
|
137
|
|
789
|
use Scalar::Util qw/blessed/; |
|
137
|
|
|
|
|
242
|
|
|
137
|
|
|
|
|
107800
|
|
9
|
|
|
|
|
|
|
require Time::HiRes; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @CARP_NOT = qw{ |
12
|
|
|
|
|
|
|
Test::Workflow |
13
|
|
|
|
|
|
|
Test::Workflow::Meta |
14
|
|
|
|
|
|
|
Test::Workflow::Block |
15
|
|
|
|
|
|
|
Test::Workflow::Layer |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
accessors qw{ |
19
|
|
|
|
|
|
|
name start_line end_line code verbose package diag skip todo should_fail subtype |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
1286
|
|
|
1286
|
0
|
1720
|
my $class = shift; |
24
|
1286
|
|
|
|
|
2358
|
my ( $caller, $name, @args ) = @_; |
25
|
1286
|
|
|
|
|
1395
|
my $code; |
26
|
|
|
|
|
|
|
|
27
|
1286
|
50
|
33
|
|
|
7061
|
croak "You must provide a caller (got: $caller)" |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
28
|
|
|
|
|
|
|
unless $caller && ref $caller && ref $caller eq 'ARRAY' && @$caller; |
29
|
1286
|
50
|
33
|
|
|
3555
|
croak "You must provide a name" |
30
|
|
|
|
|
|
|
unless $name and !ref $name; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# If code is first, grab it |
33
|
1286
|
100
|
66
|
|
|
3284
|
$code = shift(@args) |
34
|
|
|
|
|
|
|
if ref $args[0] |
35
|
|
|
|
|
|
|
&& ref $args[0] eq 'CODE'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# If code is last, grab it |
38
|
1286
|
|
100
|
|
|
2910
|
my $ref = ref $args[-1] || ''; |
39
|
1286
|
100
|
100
|
|
|
3252
|
if ( !$code && $ref eq 'CODE' ) { |
40
|
704
|
|
|
|
|
964
|
$code = pop(@args); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# if code was last, and in key => code form, pop the key |
43
|
704
|
100
|
|
|
|
2028
|
pop(@args) if $args[-1] =~ m/^(code|method|sub)$/; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Code must be a param |
47
|
1286
|
|
|
|
|
2685
|
my %proto = @args; |
48
|
1286
|
|
66
|
|
|
2480
|
$code ||= $proto{code} || $proto{method} || $proto{sub}; |
|
|
|
66
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
1286
|
50
|
33
|
|
|
3455
|
croak "You must provide a codeblock" |
51
|
|
|
|
|
|
|
unless $code |
52
|
|
|
|
|
|
|
&& ref $code eq 'CODE'; |
53
|
|
|
|
|
|
|
|
54
|
1286
|
|
|
|
|
7728
|
my $start_line = B::svref_2object($code)->START->line; |
55
|
1286
|
|
|
|
|
2486
|
my $end_line = $caller->[2]; |
56
|
1286
|
100
|
|
|
|
2274
|
$start_line-- unless $start_line == $end_line; |
57
|
|
|
|
|
|
|
|
58
|
1286
|
100
|
|
|
|
8486
|
%proto = ( |
59
|
|
|
|
|
|
|
%proto, |
60
|
|
|
|
|
|
|
code => $code, |
61
|
|
|
|
|
|
|
name => $name, |
62
|
|
|
|
|
|
|
package => $caller->[0], |
63
|
|
|
|
|
|
|
start_line => $start_line, |
64
|
|
|
|
|
|
|
end_line => $end_line, |
65
|
|
|
|
|
|
|
diag => ( $start_line == $end_line ) |
66
|
|
|
|
|
|
|
? "line $start_line" |
67
|
|
|
|
|
|
|
: "lines $start_line -> $end_line", |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
1286
|
|
|
|
|
4118
|
return bless( \%proto, $class ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub clone_with { |
74
|
79
|
|
|
79
|
0
|
104
|
my $self = shift; |
75
|
79
|
|
|
|
|
186
|
my %params = @_; |
76
|
79
|
|
|
|
|
776
|
bless( {%$self, %params}, blessed($self) ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub run { |
80
|
610
|
|
|
610
|
0
|
1822
|
my $self = shift; |
81
|
610
|
|
|
|
|
1475
|
my ( $instance, $layer ) = @_; |
82
|
610
|
|
|
|
|
4039
|
my $meta = $instance->TEST_WORKFLOW; |
83
|
610
|
|
|
|
|
2216
|
my $name = "Group: " . $self->name; |
84
|
610
|
|
66
|
|
|
6393
|
my $debug = $instance->can('FENNEC') && $instance->FENNEC->debug; |
85
|
|
|
|
|
|
|
|
86
|
610
|
100
|
|
|
|
2708
|
return $meta->skip->( $name, $self->skip ) |
87
|
|
|
|
|
|
|
if $self->skip; |
88
|
|
|
|
|
|
|
|
89
|
606
|
|
|
|
|
1517
|
my $ref = ref $self; |
90
|
606
|
|
|
|
|
5117
|
$ref =~ s/^.*:://; |
91
|
606
|
50
|
|
|
|
1800
|
if ($debug) { |
92
|
0
|
|
|
|
|
0
|
my $collector = Fennec::Runner->new->collector; |
93
|
0
|
|
|
|
|
0
|
my ($sec, $ms) = Time::HiRes::gettimeofday(); |
94
|
0
|
|
|
|
|
0
|
my $msg = sprintf( |
95
|
|
|
|
|
|
|
"FENNEC_DEBUG_BLOCK:PID:%d\0START_LINE:%d\0END_LINE:%d\0TYPE:%s\0NAME:%s\0SEC:%d\0MSEC:%d\0STATE:START\n", |
96
|
|
|
|
|
|
|
$$, |
97
|
|
|
|
|
|
|
$self->start_line, |
98
|
|
|
|
|
|
|
$self->end_line, |
99
|
|
|
|
|
|
|
$self->subtype, |
100
|
|
|
|
|
|
|
$self->name, |
101
|
|
|
|
|
|
|
$sec, |
102
|
|
|
|
|
|
|
$ms, |
103
|
|
|
|
|
|
|
); |
104
|
0
|
|
|
|
|
0
|
$collector->diag($msg); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
606
|
100
|
|
|
|
2023
|
$meta->todo_start->( $self->todo ) |
108
|
|
|
|
|
|
|
if $self->todo; |
109
|
|
|
|
|
|
|
|
110
|
606
|
|
50
|
|
|
16366
|
my $success = eval { $self->code->(@_); 1 } || $self->should_fail || 0; |
111
|
596
|
|
100
|
|
|
3316
|
my $error = $@ || "Error masked!"; |
112
|
596
|
|
|
|
|
1214
|
chomp($error); |
113
|
|
|
|
|
|
|
|
114
|
596
|
100
|
|
|
|
1869
|
$meta->todo_end->() |
115
|
|
|
|
|
|
|
if $self->todo; |
116
|
|
|
|
|
|
|
|
117
|
596
|
50
|
|
|
|
6707
|
if ($debug) { |
118
|
0
|
|
|
|
|
0
|
my $collector = Fennec::Runner->new->collector; |
119
|
0
|
|
|
|
|
0
|
my ($sec, $ms) = Time::HiRes::gettimeofday(); |
120
|
0
|
|
|
|
|
0
|
my $msg = sprintf( |
121
|
|
|
|
|
|
|
"FENNEC_DEBUG_BLOCK:PID:%d\0START_LINE:%d\0END_LINE:%d\0TYPE:%s\0NAME:%s\0SEC:%d\0MSEC:%d\0STATE:END\n", |
122
|
|
|
|
|
|
|
$$, |
123
|
|
|
|
|
|
|
$self->start_line, |
124
|
|
|
|
|
|
|
$self->end_line, |
125
|
|
|
|
|
|
|
$self->subtype, |
126
|
|
|
|
|
|
|
$self->name, |
127
|
|
|
|
|
|
|
$sec, |
128
|
|
|
|
|
|
|
$ms, |
129
|
|
|
|
|
|
|
); |
130
|
0
|
|
|
|
|
0
|
$collector->diag($msg); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
596
|
100
|
66
|
|
|
3923
|
return if $success && !$self->verbose; |
134
|
|
|
|
|
|
|
|
135
|
172
|
|
50
|
|
|
1620
|
$meta->ok->( $success || 0, $name ); |
136
|
172
|
50
|
|
|
|
10536
|
$meta->diag->( " ================================" . "\n Error: " . $error . "\n Package: " . $self->package . "\n Block: '" . $self->name . "' on " . $self->diag . "\n\n" ) unless $success; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
__END__ |