| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Workflow; |
|
2
|
137
|
|
|
137
|
|
59688
|
use strict; |
|
|
137
|
|
|
|
|
263
|
|
|
|
137
|
|
|
|
|
3256
|
|
|
3
|
137
|
|
|
137
|
|
572
|
use warnings; |
|
|
137
|
|
|
|
|
215
|
|
|
|
137
|
|
|
|
|
3236
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
137
|
|
|
137
|
|
1098
|
use Exporter::Declare; |
|
|
137
|
|
|
|
|
18608
|
|
|
|
137
|
|
|
|
|
925
|
|
|
6
|
137
|
|
|
137
|
|
273263
|
use Test::Workflow::Meta; |
|
|
137
|
|
|
|
|
309
|
|
|
|
137
|
|
|
|
|
3295
|
|
|
7
|
137
|
|
|
137
|
|
46865
|
use Test::Workflow::Test; |
|
|
137
|
|
|
|
|
334
|
|
|
|
137
|
|
|
|
|
3147
|
|
|
8
|
137
|
|
|
137
|
|
649
|
use Test::Workflow::Layer; |
|
|
137
|
|
|
|
|
238
|
|
|
|
137
|
|
|
|
|
2342
|
|
|
9
|
137
|
|
|
137
|
|
587
|
use List::Util qw/shuffle/; |
|
|
137
|
|
|
|
|
199
|
|
|
|
137
|
|
|
|
|
5213
|
|
|
10
|
137
|
|
|
137
|
|
759
|
use Carp qw/croak/; |
|
|
137
|
|
|
|
|
296
|
|
|
|
137
|
|
|
|
|
5067
|
|
|
11
|
137
|
|
|
137
|
|
735
|
use Scalar::Util qw/blessed/; |
|
|
137
|
|
|
|
|
235
|
|
|
|
137
|
|
|
|
|
16465
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @CARP_NOT = qw/ Test::Workflow Test::Workflow::Test /; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
default_exports qw/ |
|
16
|
|
|
|
|
|
|
tests run_tests |
|
17
|
|
|
|
|
|
|
describe it |
|
18
|
|
|
|
|
|
|
cases case |
|
19
|
|
|
|
|
|
|
before_case after_case |
|
20
|
|
|
|
|
|
|
before_each after_each around_each |
|
21
|
|
|
|
|
|
|
before_all after_all around_all |
|
22
|
|
|
|
|
|
|
with_tests |
|
23
|
|
|
|
|
|
|
test_sort |
|
24
|
|
|
|
|
|
|
/; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
gen_default_export TEST_WORKFLOW => sub { |
|
27
|
|
|
|
|
|
|
my ( $class, $importer ) = @_; |
|
28
|
|
|
|
|
|
|
my $meta = Test::Workflow::Meta->new($importer); |
|
29
|
4381
|
|
|
4381
|
|
12370
|
return sub { $meta }; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
137
|
|
|
137
|
|
4066
|
{ no warnings 'once'; @DB::CARP_NOT = qw/ DB Test::Workflow / } |
|
|
137
|
|
|
|
|
2349
|
|
|
|
137
|
|
|
|
|
26264
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _get_layer { |
|
35
|
1285
|
|
|
1285
|
|
2032
|
my ( $offset, $sub, $caller ) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
1285
|
|
|
|
|
2770
|
my $meta = $caller->[0]->TEST_WORKFLOW; |
|
38
|
1285
|
100
|
|
|
|
2647
|
croak "$sub() can only be used within a describe or case block, or at the package level." |
|
39
|
|
|
|
|
|
|
if $meta->build_complete; |
|
40
|
|
|
|
|
|
|
|
|
41
|
1281
|
|
|
|
|
2805
|
my $layer = $meta->peek_layer; |
|
42
|
|
|
|
|
|
|
|
|
43
|
1281
|
100
|
66
|
|
|
5591
|
if ( blessed($layer) && blessed($layer)->isa('Test::Workflow::Layer') ) { |
|
44
|
776
|
50
|
|
|
|
1591
|
croak "Layer has already been finalized!" |
|
45
|
|
|
|
|
|
|
if $layer->finalized; |
|
46
|
776
|
|
|
|
|
1506
|
return $layer; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
505
|
|
|
|
|
1064
|
return $meta->root_layer; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub with_tests { |
|
53
|
1
|
|
|
1
|
1
|
680
|
my @caller = caller; |
|
54
|
1
|
|
|
|
|
4
|
my $layer = _get_layer( 0, 'with_tests', \@caller ); |
|
55
|
1
|
|
|
|
|
6
|
$layer->merge_in( \@caller, @_ ); |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{ |
|
59
|
137
|
|
|
137
|
|
800
|
no warnings 'once'; |
|
|
137
|
|
|
|
|
208
|
|
|
|
137
|
|
|
|
|
161618
|
|
|
60
|
|
|
|
|
|
|
*it = \&tests; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub tests { |
|
64
|
766
|
|
|
766
|
1
|
11965
|
my $name = shift; |
|
65
|
766
|
|
|
|
|
1753
|
my @caller = caller; |
|
66
|
766
|
|
|
|
|
11992
|
my $layer = _get_layer( 0, 'tests', \@caller ); |
|
67
|
762
|
|
|
|
|
2083
|
$layer->add_test( |
|
68
|
|
|
|
|
|
|
\@caller, |
|
69
|
|
|
|
|
|
|
$name, |
|
70
|
|
|
|
|
|
|
verbose => 1, |
|
71
|
|
|
|
|
|
|
@_ |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
196
|
|
|
196
|
1
|
24034
|
sub describe { _add_child( 'describe', @_ ) } |
|
76
|
4
|
|
|
4
|
1
|
43
|
sub cases { _add_child( 'case', @_ ) } |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _add_child { |
|
79
|
200
|
|
|
200
|
|
330
|
my $type = shift; |
|
80
|
200
|
|
|
|
|
598
|
my @caller = caller(1); |
|
81
|
200
|
|
|
|
|
3441
|
my $layer = _get_layer( 1, $type, \@caller ); |
|
82
|
200
|
|
|
|
|
672
|
$layer->add_child( \@caller, @_ ); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
35
|
|
|
35
|
1
|
530
|
sub case { _add_type( 'case', @_ ) } |
|
86
|
3
|
|
|
3
|
0
|
27
|
sub before_case { _add_type( 'before_case', @_ ) } |
|
87
|
58
|
|
|
58
|
1
|
599
|
sub before_each { _add_type( 'before_each', @_ ) } |
|
88
|
102
|
|
|
102
|
1
|
1947
|
sub before_all { _add_type( 'before_all', @_ ) } |
|
89
|
6
|
|
|
6
|
1
|
41
|
sub after_each { _add_type( 'after_each', @_ ) } |
|
90
|
70
|
|
|
70
|
1
|
411
|
sub after_all { _add_type( 'after_all', @_ ) } |
|
91
|
3
|
|
|
3
|
0
|
24
|
sub after_case { _add_type( 'before_each', @_ ) } |
|
92
|
30
|
|
|
30
|
1
|
258
|
sub around_each { _add_type( 'around_each', @_ ) } |
|
93
|
11
|
|
|
11
|
1
|
99
|
sub around_all { _add_type( 'around_all', @_ ) } |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _add_type { |
|
96
|
318
|
|
|
318
|
|
473
|
my $type = shift; |
|
97
|
318
|
|
|
|
|
547
|
my $meth = "add_$type"; |
|
98
|
|
|
|
|
|
|
|
|
99
|
318
|
|
|
|
|
815
|
my @caller = caller(1); |
|
100
|
318
|
|
|
|
|
4930
|
my $layer = _get_layer( 1, $type, \@caller ); |
|
101
|
318
|
|
|
|
|
1435
|
$layer->$meth( \@caller, @_ ); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
1
|
|
|
1
|
1
|
82
|
sub test_sort { caller->TEST_WORKFLOW->test_sort(@_) } |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub run_tests { |
|
107
|
135
|
|
|
135
|
1
|
319
|
my ($instance) = @_; |
|
108
|
135
|
100
|
|
|
|
1000
|
unless ($instance) { |
|
109
|
1
|
|
|
|
|
2
|
my $caller = caller; |
|
110
|
1
|
50
|
|
|
|
12
|
$instance = $caller->new() if $caller->can('new'); |
|
111
|
1
|
|
50
|
|
|
9
|
$instance ||= bless( {}, $caller ); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
135
|
|
|
|
|
548
|
my $layer = $instance->TEST_WORKFLOW->root_layer; |
|
114
|
135
|
|
|
|
|
730
|
my @tests = get_tests( $instance, $layer, 'PACKAGE LEVEL', [], [], [], [], [] ); |
|
115
|
135
|
|
|
|
|
465
|
$instance->TEST_WORKFLOW->build_complete(1); |
|
116
|
135
|
|
100
|
|
|
334
|
my $sort = $instance->TEST_WORKFLOW->test_sort || 'rand'; |
|
117
|
135
|
|
|
|
|
770
|
@tests = order_tests( $sort, @tests ); |
|
118
|
135
|
|
|
|
|
932
|
$_->run($instance) for @tests; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub order_tests { |
|
122
|
756
|
|
|
756
|
0
|
3199
|
my ( $sort, @tests ) = @_; |
|
123
|
|
|
|
|
|
|
|
|
124
|
756
|
100
|
|
|
|
9703
|
if ( "$sort" =~ /^sort/ ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
125
|
48
|
|
|
|
|
107
|
@tests = sort { $a->name cmp $b->name } @tests; |
|
|
87
|
|
|
|
|
144
|
|
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
elsif ( "$sort" =~ /^rand/ ) { |
|
128
|
534
|
|
|
|
|
2816
|
@tests = shuffle @tests; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
elsif ( ref $sort eq 'CODE' ) { |
|
131
|
0
|
|
|
|
|
0
|
@tests = $sort->(@tests); |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
elsif ( $sort !~ /^ord/ ) { |
|
134
|
0
|
|
|
|
|
0
|
croak "'$sort' is not a recognized option to test_sort"; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
return sort { |
|
138
|
756
|
100
|
|
|
|
3137
|
return 0 if $a->is_wrap == $b->is_wrap; |
|
|
1125
|
|
|
|
|
2163
|
|
|
139
|
49
|
100
|
|
|
|
310
|
return 1 if $a->is_wrap; |
|
140
|
36
|
|
|
|
|
170
|
return 0; |
|
141
|
|
|
|
|
|
|
} @tests; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
#<<< no-tidy |
|
145
|
|
|
|
|
|
|
sub get_tests { |
|
146
|
333
|
|
|
333
|
0
|
1018
|
my ( $instance, $layer, $name, $before_case, $before_each, $after_each, $around_each, $control, $todo ) = @_; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# get before_each and after_each |
|
149
|
333
|
|
|
|
|
526
|
push @$before_case => @{ $layer->before_case }; |
|
|
333
|
|
|
|
|
904
|
|
|
150
|
333
|
|
|
|
|
520
|
push @$before_each => @{ $layer->before_each }; |
|
|
333
|
|
|
|
|
893
|
|
|
151
|
333
|
|
|
|
|
546
|
push @$around_each => @{ $layer->around_each }; |
|
|
333
|
|
|
|
|
837
|
|
|
152
|
333
|
|
|
|
|
565
|
push @$control => @{ $layer->control }; |
|
|
333
|
|
|
|
|
794
|
|
|
153
|
333
|
|
|
|
|
541
|
unshift @$after_each => @{ $layer->after_each }; |
|
|
333
|
|
|
|
|
717
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
333
|
|
|
|
|
468
|
my @tests = @{ $layer->test }; |
|
|
333
|
|
|
|
|
819
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
333
|
100
|
|
|
|
743
|
if ($todo) { |
|
158
|
20
|
|
|
|
|
60
|
$_->todo( $todo ) for @tests |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
333
|
100
|
|
|
|
917
|
if ( my $specific = $ENV{FENNEC_TEST}) { |
|
162
|
|
|
|
|
|
|
@tests = grep { |
|
163
|
40
|
|
|
|
|
60
|
my $out = 0; |
|
|
40
|
|
|
|
|
44
|
|
|
164
|
40
|
50
|
|
|
|
104
|
if ( $specific =~ m/^\d+$/ ) { |
|
165
|
0
|
0
|
0
|
|
|
0
|
$out = 1 if $_->start_line <= $specific && $_->end_line >= $specific; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
else { |
|
168
|
40
|
100
|
|
|
|
116
|
$out = 1 if $_->name eq $specific; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
40
|
|
|
|
|
92
|
$out; |
|
171
|
|
|
|
|
|
|
} @tests; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
333
|
|
|
|
|
478
|
my @cases = @{ $layer->case }; |
|
|
333
|
|
|
|
|
710
|
|
|
175
|
333
|
100
|
|
|
|
777
|
if ( @cases ) { |
|
176
|
19
|
|
|
|
|
33
|
my @new_tests; |
|
177
|
19
|
|
|
|
|
65
|
for my $test ( @tests ) { |
|
178
|
35
|
|
|
|
|
69
|
for my $case ( @cases ) { |
|
179
|
79
|
|
|
|
|
245
|
push @new_tests => Test::Workflow::Test->new( |
|
180
|
|
|
|
|
|
|
setup => [ @$before_case, $case, @$before_each ], |
|
181
|
|
|
|
|
|
|
tests => [ |
|
182
|
|
|
|
|
|
|
$test->clone_with( |
|
183
|
|
|
|
|
|
|
name => "'" . $case->name . "' x '" . $test->name . "'" |
|
184
|
|
|
|
|
|
|
) |
|
185
|
|
|
|
|
|
|
], |
|
186
|
|
|
|
|
|
|
teardown => [ @$after_each ], |
|
187
|
|
|
|
|
|
|
around => [ @$around_each ], |
|
188
|
|
|
|
|
|
|
control => [ @$control ], |
|
189
|
|
|
|
|
|
|
block_name => $name, |
|
190
|
|
|
|
|
|
|
); |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
} |
|
193
|
19
|
|
|
|
|
86
|
@tests = @new_tests; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
else { |
|
196
|
314
|
|
|
|
|
725
|
@tests = map { Test::Workflow::Test->new( |
|
|
710
|
|
|
|
|
2928
|
|
|
197
|
|
|
|
|
|
|
setup => [ @$before_each ], |
|
198
|
|
|
|
|
|
|
tests => [ $_ ], |
|
199
|
|
|
|
|
|
|
teardown => [ @$after_each ], |
|
200
|
|
|
|
|
|
|
around => [ @$around_each ], |
|
201
|
|
|
|
|
|
|
control => [ @$control ], |
|
202
|
|
|
|
|
|
|
block_name => $name, |
|
203
|
|
|
|
|
|
|
)} @tests; |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
push @tests => map { |
|
207
|
198
|
|
|
|
|
793
|
my $layer = Test::Workflow::Layer->new; |
|
208
|
|
|
|
|
|
|
|
|
209
|
198
|
|
|
|
|
581
|
$instance->TEST_WORKFLOW->push_layer( $layer ); |
|
210
|
198
|
100
|
|
|
|
472
|
$_->todo( $todo ) if $todo; |
|
211
|
198
|
|
|
|
|
726
|
$_->run( $instance, $layer ); |
|
212
|
|
|
|
|
|
|
|
|
213
|
198
|
|
|
|
|
618
|
my @tests = get_tests( |
|
214
|
|
|
|
|
|
|
$instance, |
|
215
|
|
|
|
|
|
|
$layer, |
|
216
|
|
|
|
|
|
|
$_->name, |
|
217
|
|
|
|
|
|
|
[@$before_case], |
|
218
|
|
|
|
|
|
|
[@$before_each], |
|
219
|
|
|
|
|
|
|
[@$after_each], |
|
220
|
|
|
|
|
|
|
[@$around_each], |
|
221
|
|
|
|
|
|
|
[@$control], |
|
222
|
|
|
|
|
|
|
$_->todo, |
|
223
|
|
|
|
|
|
|
); |
|
224
|
|
|
|
|
|
|
|
|
225
|
198
|
|
|
|
|
565
|
$instance->TEST_WORKFLOW->pop_layer( $layer ); |
|
226
|
|
|
|
|
|
|
|
|
227
|
198
|
100
|
|
|
|
376
|
unless (@tests) { |
|
228
|
16
|
|
|
|
|
40
|
my $name = $_->name; |
|
229
|
16
|
|
|
|
|
40
|
my $start = $_->start_line; |
|
230
|
16
|
|
|
|
|
68
|
my $end = $_->end_line; |
|
231
|
|
|
|
|
|
|
warn "No tests in block '$name' approx lines $start -> $end\n" |
|
232
|
16
|
50
|
|
|
|
44
|
unless $ENV{FENNEC_TEST}; |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
|
|
235
|
198
|
|
|
|
|
1462
|
@tests; |
|
236
|
333
|
|
|
|
|
630
|
} @{ $layer->child }; |
|
|
333
|
|
|
|
|
915
|
|
|
237
|
|
|
|
|
|
|
|
|
238
|
333
|
|
|
|
|
589
|
my @before_all = @{ $layer->before_all }; |
|
|
333
|
|
|
|
|
779
|
|
|
239
|
333
|
|
|
|
|
517
|
my @after_all = @{ $layer->after_all }; |
|
|
333
|
|
|
|
|
698
|
|
|
240
|
333
|
|
|
|
|
428
|
my @around_all = @{ $layer->around_all }; |
|
|
333
|
|
|
|
|
728
|
|
|
241
|
333
|
|
|
|
|
418
|
my @control = @{ $layer->control }; |
|
|
333
|
|
|
|
|
620
|
|
|
242
|
333
|
50
|
66
|
|
|
2615
|
return Test::Workflow::Test->new( |
|
|
|
|
66
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
243
|
|
|
|
|
|
|
setup => [ @before_all ], |
|
244
|
|
|
|
|
|
|
tests => [ @tests ], |
|
245
|
|
|
|
|
|
|
teardown => [ @after_all ], |
|
246
|
|
|
|
|
|
|
around => [ @around_all ], |
|
247
|
|
|
|
|
|
|
control => [ @control ], |
|
248
|
|
|
|
|
|
|
block_name => $name, |
|
249
|
|
|
|
|
|
|
is_wrap => 1, |
|
250
|
|
|
|
|
|
|
) if @before_all || @after_all || @around_all || @control; |
|
251
|
|
|
|
|
|
|
|
|
252
|
231
|
|
|
|
|
854
|
return @tests; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
#>>> |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
1; |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
__END__ |