| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test2::Tools::Defer; |
|
2
|
156
|
|
|
156
|
|
81695
|
use strict; |
|
|
156
|
|
|
|
|
340
|
|
|
|
156
|
|
|
|
|
4563
|
|
|
3
|
156
|
|
|
156
|
|
747
|
use warnings; |
|
|
156
|
|
|
|
|
361
|
|
|
|
156
|
|
|
|
|
6096
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.000156'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
156
|
|
|
156
|
|
929
|
use Carp qw/croak/; |
|
|
156
|
|
|
|
|
334
|
|
|
|
156
|
|
|
|
|
7161
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
156
|
|
|
156
|
|
2229
|
use Test2::Util qw/get_tid/; |
|
|
156
|
|
|
|
|
27041
|
|
|
|
156
|
|
|
|
|
7636
|
|
|
10
|
156
|
|
|
|
|
12947
|
use Test2::API qw{ |
|
11
|
|
|
|
|
|
|
test2_add_callback_exit |
|
12
|
|
|
|
|
|
|
test2_pid test2_tid |
|
13
|
156
|
|
|
156
|
|
2234
|
}; |
|
|
156
|
|
|
|
|
130586
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw/def do_def/; |
|
16
|
156
|
|
|
156
|
|
1172
|
use base 'Exporter'; |
|
|
156
|
|
|
|
|
406
|
|
|
|
156
|
|
|
|
|
98417
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %TODO; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub def { |
|
21
|
54
|
|
|
54
|
1
|
737
|
my ($func, @args) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
54
|
|
|
|
|
381
|
my @caller = caller(0); |
|
24
|
|
|
|
|
|
|
|
|
25
|
54
|
|
100
|
|
|
252
|
$TODO{$caller[0]} ||= []; |
|
26
|
54
|
|
|
|
|
88
|
push @{$TODO{$caller[0]}} => [$func, \@args, \@caller]; |
|
|
54
|
|
|
|
|
382
|
|
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub do_def { |
|
30
|
11
|
|
|
11
|
1
|
80401
|
my $for = caller; |
|
31
|
11
|
100
|
|
|
|
303
|
my $tests = delete $TODO{$for} or croak "No tests to run!"; |
|
32
|
|
|
|
|
|
|
|
|
33
|
10
|
|
|
|
|
39
|
for my $test (@$tests) { |
|
34
|
51
|
|
|
|
|
948
|
my ($func, $args, $caller) = @$test; |
|
35
|
|
|
|
|
|
|
|
|
36
|
51
|
|
|
|
|
170
|
my ($pkg, $file, $line) = @$caller; |
|
37
|
|
|
|
|
|
|
|
|
38
|
51
|
|
|
|
|
221
|
chomp(my $eval = <<" EOT"); |
|
39
|
|
|
|
|
|
|
package $pkg; |
|
40
|
|
|
|
|
|
|
# line $line "(eval in Test2::Tools::Defer) $file" |
|
41
|
|
|
|
|
|
|
\&$func(\@\$args); |
|
42
|
|
|
|
|
|
|
1; |
|
43
|
|
|
|
|
|
|
EOT |
|
44
|
|
|
|
|
|
|
|
|
45
|
51
|
100
|
|
|
|
4696
|
eval $eval and next; |
|
46
|
1
|
|
|
|
|
27
|
chomp(my $error = $@); |
|
47
|
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
762
|
require Data::Dumper; |
|
49
|
1
|
|
|
|
|
7059
|
chomp(my $td = Data::Dumper::Dumper($args)); |
|
50
|
1
|
|
|
|
|
81
|
$td =~ s/^\$VAR1 =/\$args: /; |
|
51
|
1
|
|
|
|
|
21
|
die <<" EOT"; |
|
52
|
|
|
|
|
|
|
Exception: $error |
|
53
|
|
|
|
|
|
|
--eval-- |
|
54
|
|
|
|
|
|
|
$eval |
|
55
|
|
|
|
|
|
|
-------- |
|
56
|
|
|
|
|
|
|
Tool: $func |
|
57
|
|
|
|
|
|
|
Caller: $caller->[0], $caller->[1], $caller->[2] |
|
58
|
|
|
|
|
|
|
$td |
|
59
|
|
|
|
|
|
|
EOT |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
9
|
|
|
|
|
271
|
return; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _verify { |
|
66
|
105
|
|
|
105
|
|
5035
|
my ($context, $exit, $new_exit) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
105
|
|
|
|
|
325
|
my $not_ok = 0; |
|
69
|
105
|
|
|
|
|
1582
|
for my $pkg (keys %TODO) { |
|
70
|
3
|
|
|
|
|
8
|
my $tests = delete $TODO{$pkg}; |
|
71
|
3
|
|
|
|
|
12
|
my $caller = $tests->[0]->[-1]; |
|
72
|
3
|
100
|
|
|
|
17
|
print STDOUT "not ok - deferred tests were not run!\n" unless $not_ok++; |
|
73
|
3
|
|
|
|
|
10
|
print STDERR "# '$pkg' has deferred tests that were never run!\n"; |
|
74
|
3
|
|
|
|
|
12
|
print STDERR "# $caller->[1] at line $caller->[2]\n"; |
|
75
|
3
|
|
100
|
|
|
22
|
$$new_exit ||= 255; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
test2_add_callback_exit(\&_verify); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |