line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Workflow; |
2
|
137
|
|
|
137
|
|
32719
|
use strict; |
|
137
|
|
|
|
|
332
|
|
|
137
|
|
|
|
|
5369
|
|
3
|
137
|
|
|
137
|
|
811
|
use warnings; |
|
137
|
|
|
|
|
334
|
|
|
137
|
|
|
|
|
4672
|
|
4
|
|
|
|
|
|
|
|
5
|
137
|
|
|
137
|
|
6679
|
use Exporter::Declare; |
|
137
|
|
|
|
|
28890
|
|
|
137
|
|
|
|
|
1439
|
|
6
|
137
|
|
|
137
|
|
385213
|
use Test::Workflow::Meta; |
|
137
|
|
|
|
|
485
|
|
|
137
|
|
|
|
|
5460
|
|
7
|
137
|
|
|
137
|
|
165792
|
use Test::Workflow::Test; |
|
137
|
|
|
|
|
440
|
|
|
137
|
|
|
|
|
4818
|
|
8
|
137
|
|
|
137
|
|
1233
|
use Test::Workflow::Layer; |
|
137
|
|
|
|
|
314
|
|
|
137
|
|
|
|
|
5340
|
|
9
|
137
|
|
|
137
|
|
798
|
use List::Util qw/shuffle/; |
|
137
|
|
|
|
|
583
|
|
|
137
|
|
|
|
|
9298
|
|
10
|
137
|
|
|
137
|
|
799
|
use Carp qw/croak/; |
|
137
|
|
|
|
|
290
|
|
|
137
|
|
|
|
|
45103
|
|
11
|
137
|
|
|
137
|
|
846
|
use Scalar::Util qw/blessed/; |
|
137
|
|
|
|
|
317
|
|
|
137
|
|
|
|
|
26998
|
|
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
|
4369
|
|
|
4369
|
|
18341
|
return sub { $meta }; |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
137
|
|
|
137
|
|
915
|
{ no warnings 'once'; @DB::CARP_NOT = qw/ DB Test::Workflow / } |
|
137
|
|
|
|
|
275
|
|
|
137
|
|
|
|
|
165825
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _get_layer { |
35
|
1285
|
|
|
1285
|
|
3624
|
my ( $offset, $sub, $caller ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
1285
|
|
|
|
|
4176
|
my $meta = $caller->[0]->TEST_WORKFLOW; |
38
|
1285
|
100
|
|
|
|
4639
|
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
|
|
|
|
|
4080
|
my $layer = $meta->peek_layer; |
42
|
|
|
|
|
|
|
|
43
|
1281
|
100
|
66
|
|
|
10457
|
if ( blessed($layer) && blessed($layer)->isa('Test::Workflow::Layer') ) { |
44
|
776
|
50
|
|
|
|
2875
|
croak "Layer has already been finalized!" |
45
|
|
|
|
|
|
|
if $layer->finalized; |
46
|
776
|
|
|
|
|
1854
|
return $layer; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
505
|
|
|
|
|
1824
|
return $meta->root_layer; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub with_tests { |
53
|
1
|
|
|
1
|
1
|
1125
|
my @caller = caller; |
54
|
1
|
|
|
|
|
5
|
my $layer = _get_layer( 0, 'with_tests', \@caller ); |
55
|
1
|
|
|
|
|
6
|
$layer->merge_in( \@caller, @_ ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
{ |
59
|
137
|
|
|
137
|
|
892
|
no warnings 'once'; |
|
137
|
|
|
|
|
463
|
|
|
137
|
|
|
|
|
440465
|
|
60
|
|
|
|
|
|
|
*it = \&tests; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub tests { |
64
|
766
|
|
|
766
|
1
|
13472
|
my $name = shift; |
65
|
766
|
|
|
|
|
2435
|
my @caller = caller; |
66
|
766
|
|
|
|
|
19441
|
my $layer = _get_layer( 0, 'tests', \@caller ); |
67
|
762
|
|
|
|
|
3579
|
$layer->add_test( |
68
|
|
|
|
|
|
|
\@caller, |
69
|
|
|
|
|
|
|
$name, |
70
|
|
|
|
|
|
|
verbose => 1, |
71
|
|
|
|
|
|
|
@_ |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
196
|
|
|
196
|
1
|
37398
|
sub describe { _add_child( 'describe', @_ ) } |
76
|
4
|
|
|
4
|
1
|
39
|
sub cases { _add_child( 'case', @_ ) } |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _add_child { |
79
|
200
|
|
|
200
|
|
503
|
my $type = shift; |
80
|
200
|
|
|
|
|
1241
|
my @caller = caller(1); |
81
|
200
|
|
|
|
|
4792
|
my $layer = _get_layer( 1, $type, \@caller ); |
82
|
200
|
|
|
|
|
1133
|
$layer->add_child( \@caller, @_ ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
35
|
|
|
35
|
1
|
618
|
sub case { _add_type( 'case', @_ ) } |
86
|
3
|
|
|
3
|
0
|
45
|
sub before_case { _add_type( 'before_case', @_ ) } |
87
|
58
|
|
|
58
|
1
|
608
|
sub before_each { _add_type( 'before_each', @_ ) } |
88
|
102
|
|
|
102
|
1
|
1688
|
sub before_all { _add_type( 'before_all', @_ ) } |
89
|
6
|
|
|
6
|
1
|
48
|
sub after_each { _add_type( 'after_each', @_ ) } |
90
|
70
|
|
|
70
|
1
|
615
|
sub after_all { _add_type( 'after_all', @_ ) } |
91
|
3
|
|
|
3
|
0
|
33
|
sub after_case { _add_type( 'before_each', @_ ) } |
92
|
30
|
|
|
30
|
1
|
354
|
sub around_each { _add_type( 'around_each', @_ ) } |
93
|
11
|
|
|
11
|
1
|
121
|
sub around_all { _add_type( 'around_all', @_ ) } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _add_type { |
96
|
318
|
|
|
318
|
|
587
|
my $type = shift; |
97
|
318
|
|
|
|
|
678
|
my $meth = "add_$type"; |
98
|
|
|
|
|
|
|
|
99
|
318
|
|
|
|
|
1328
|
my @caller = caller(1); |
100
|
318
|
|
|
|
|
7512
|
my $layer = _get_layer( 1, $type, \@caller ); |
101
|
318
|
|
|
|
|
1638
|
$layer->$meth( \@caller, @_ ); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
1
|
1
|
16
|
sub test_sort { caller->TEST_WORKFLOW->test_sort(@_) } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub run_tests { |
107
|
135
|
|
|
135
|
1
|
372
|
my ($instance) = @_; |
108
|
135
|
100
|
|
|
|
1261
|
unless ($instance) { |
109
|
1
|
|
|
|
|
3
|
my $caller = caller; |
110
|
1
|
50
|
|
|
|
14
|
$instance = $caller->new() if $caller->can('new'); |
111
|
1
|
|
50
|
|
|
14
|
$instance ||= bless( {}, $caller ); |
112
|
|
|
|
|
|
|
} |
113
|
135
|
|
|
|
|
747
|
my $layer = $instance->TEST_WORKFLOW->root_layer; |
114
|
135
|
|
|
|
|
1489
|
my @tests = get_tests( $instance, $layer, 'PACKAGE LEVEL', [], [], [], [], [] ); |
115
|
135
|
|
|
|
|
753
|
$instance->TEST_WORKFLOW->build_complete(1); |
116
|
135
|
|
100
|
|
|
504
|
my $sort = $instance->TEST_WORKFLOW->test_sort || 'rand'; |
117
|
135
|
|
|
|
|
782
|
@tests = order_tests( $sort, @tests ); |
118
|
135
|
|
|
|
|
2367
|
$_->run($instance) for @tests; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub order_tests { |
122
|
752
|
|
|
752
|
0
|
4442
|
my ( $sort, @tests ) = @_; |
123
|
|
|
|
|
|
|
|
124
|
752
|
100
|
|
|
|
10133
|
if ( "$sort" =~ /^sort/ ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
125
|
48
|
|
|
|
|
117
|
@tests = sort { $a->name cmp $b->name } @tests; |
|
87
|
|
|
|
|
278
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
elsif ( "$sort" =~ /^rand/ ) { |
128
|
530
|
|
|
|
|
2808
|
@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
|
1125
|
100
|
|
|
|
3539
|
return sort { |
138
|
752
|
|
|
|
|
4220
|
return 0 if $a->is_wrap == $b->is_wrap; |
139
|
39
|
100
|
|
|
|
325
|
return 1 if $a->is_wrap; |
140
|
26
|
|
|
|
|
91
|
return 0; |
141
|
|
|
|
|
|
|
} @tests; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
#<<< no-tidy |
145
|
|
|
|
|
|
|
sub get_tests { |
146
|
333
|
|
|
333
|
0
|
968
|
my ( $instance, $layer, $name, $before_case, $before_each, $after_each, $around_each, $control, $todo ) = @_; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# get before_each and after_each |
149
|
333
|
|
|
|
|
647
|
push @$before_case => @{ $layer->before_case }; |
|
333
|
|
|
|
|
1404
|
|
150
|
333
|
|
|
|
|
716
|
push @$before_each => @{ $layer->before_each }; |
|
333
|
|
|
|
|
1245
|
|
151
|
333
|
|
|
|
|
177152
|
push @$around_each => @{ $layer->around_each }; |
|
333
|
|
|
|
|
1490
|
|
152
|
333
|
|
|
|
|
637
|
push @$control => @{ $layer->control }; |
|
333
|
|
|
|
|
1257
|
|
153
|
333
|
|
|
|
|
991
|
unshift @$after_each => @{ $layer->after_each }; |
|
333
|
|
|
|
|
1411
|
|
154
|
|
|
|
|
|
|
|
155
|
333
|
|
|
|
|
598
|
my @tests = @{ $layer->test }; |
|
333
|
|
|
|
|
1493
|
|
156
|
|
|
|
|
|
|
|
157
|
333
|
100
|
|
|
|
1110
|
if ($todo) { |
158
|
20
|
|
|
|
|
90
|
$_->todo( $todo ) for @tests |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
333
|
100
|
|
|
|
1667
|
if ( my $specific = $ENV{FENNEC_TEST}) { |
162
|
40
|
|
|
|
|
52
|
@tests = grep { |
163
|
40
|
|
|
|
|
64
|
my $out = 0; |
164
|
40
|
50
|
|
|
|
144
|
if ( $specific =~ m/^\d+$/ ) { |
165
|
0
|
0
|
0
|
|
|
0
|
$out = 1 if $_->start_line <= $specific && $_->end_line >= $specific; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
else { |
168
|
40
|
100
|
|
|
|
132
|
$out = 1 if $_->name eq $specific; |
169
|
|
|
|
|
|
|
} |
170
|
40
|
|
|
|
|
128
|
$out; |
171
|
|
|
|
|
|
|
} @tests; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
333
|
|
|
|
|
578
|
my @cases = @{ $layer->case }; |
|
333
|
|
|
|
|
1244
|
|
175
|
333
|
100
|
|
|
|
1227
|
if ( @cases ) { |
176
|
19
|
|
|
|
|
106
|
my @new_tests; |
177
|
19
|
|
|
|
|
77
|
for my $test ( @tests ) { |
178
|
35
|
|
|
|
|
88
|
for my $case ( @cases ) { |
179
|
79
|
|
|
|
|
471
|
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
|
|
|
|
|
89
|
@tests = @new_tests; |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
else { |
196
|
314
|
|
|
|
|
727
|
@tests = map { Test::Workflow::Test->new( |
|
710
|
|
|
|
|
5281
|
|
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
|
198
|
|
|
|
|
1526
|
push @tests => map { |
207
|
333
|
|
|
|
|
1256
|
my $layer = Test::Workflow::Layer->new; |
208
|
|
|
|
|
|
|
|
209
|
198
|
|
|
|
|
942
|
$instance->TEST_WORKFLOW->push_layer( $layer ); |
210
|
198
|
100
|
|
|
|
1076
|
$_->todo( $todo ) if $todo; |
211
|
198
|
|
|
|
|
918
|
$_->run( $instance, $layer ); |
212
|
|
|
|
|
|
|
|
213
|
198
|
|
|
|
|
764
|
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
|
|
|
|
|
969
|
$instance->TEST_WORKFLOW->pop_layer( $layer ); |
226
|
|
|
|
|
|
|
|
227
|
198
|
100
|
|
|
|
572
|
unless (@tests) { |
228
|
16
|
|
|
|
|
48
|
my $name = $_->name; |
229
|
16
|
|
|
|
|
60
|
my $start = $_->start_line; |
230
|
16
|
|
|
|
|
56
|
my $end = $_->end_line; |
231
|
16
|
50
|
|
|
|
64
|
warn "No tests in block '$name' approx lines $start -> $end\n" |
232
|
|
|
|
|
|
|
unless $ENV{FENNEC_TEST}; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
198
|
|
|
|
|
2546
|
@tests; |
236
|
333
|
|
|
|
|
662
|
} @{ $layer->child }; |
237
|
|
|
|
|
|
|
|
238
|
333
|
|
|
|
|
625
|
my @before_all = @{ $layer->before_all }; |
|
333
|
|
|
|
|
1309
|
|
239
|
333
|
|
|
|
|
605
|
my @after_all = @{ $layer->after_all }; |
|
333
|
|
|
|
|
1112
|
|
240
|
333
|
|
|
|
|
594
|
my @around_all = @{ $layer->around_all }; |
|
333
|
|
|
|
|
1093
|
|
241
|
333
|
|
|
|
|
555
|
my @control = @{ $layer->control }; |
|
333
|
|
|
|
|
1370
|
|
242
|
333
|
50
|
66
|
|
|
4304
|
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
|
|
|
|
|
1093
|
return @tests; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
#>>> |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
1; |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
__END__ |