| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
13
|
|
|
13
|
|
5059304
|
use v5.14; |
|
|
13
|
|
|
|
|
37
|
|
|
3
|
13
|
|
|
13
|
|
64
|
use warnings; |
|
|
13
|
|
|
|
|
50
|
|
|
|
13
|
|
|
|
|
773
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Test::Load::Helper v1.0.1 { |
|
6
|
|
|
|
|
|
|
|
|
7
|
13
|
|
|
12
|
|
416
|
use Carp qw (croak); |
|
|
12
|
|
|
|
|
42
|
|
|
|
12
|
|
|
|
|
665
|
|
|
8
|
12
|
|
|
12
|
|
72
|
use Path::Tiny qw (); |
|
|
12
|
|
|
|
|
45
|
|
|
|
12
|
|
|
|
|
1140
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $DEFAULT_FILENAME = q (test-helper.pl); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub eval_helper { |
|
13
|
17
|
|
|
17
|
0
|
112
|
my ($class, %args) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
17
|
|
|
|
|
52
|
my $key = $class->inc_key (%args); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
return 1 |
|
18
|
17
|
100
|
|
|
|
176
|
if exists $INC{$key} |
|
19
|
|
|
|
|
|
|
; |
|
20
|
|
|
|
|
|
|
|
|
21
|
15
|
|
|
|
|
31
|
my $file = $args{file}; |
|
22
|
15
|
|
|
|
|
53
|
my $code = $file->slurp_utf8; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
{ |
|
25
|
12
|
|
|
12
|
|
56
|
no strict q (refs); |
|
|
12
|
|
|
|
|
17
|
|
|
|
12
|
|
|
|
|
7055
|
|
|
|
15
|
|
|
|
|
12150
|
|
|
26
|
10
|
|
|
10
|
|
932
|
eval <<"END_OF_EVAL"; |
|
|
10
|
|
|
10
|
|
19
|
|
|
|
10
|
|
|
4
|
|
215
|
|
|
|
10
|
|
|
4
|
|
54
|
|
|
|
10
|
|
|
|
|
16
|
|
|
|
10
|
|
|
|
|
2398
|
|
|
|
4
|
|
|
|
|
466
|
|
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
99
|
|
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
770
|
|
|
|
15
|
|
|
|
|
89
|
|
|
27
|
|
|
|
|
|
|
package $args{into}; |
|
28
|
|
|
|
|
|
|
use strict; |
|
29
|
|
|
|
|
|
|
use warnings; |
|
30
|
|
|
|
|
|
|
#line 1 "$file" |
|
31
|
|
|
|
|
|
|
$code; |
|
32
|
|
|
|
|
|
|
1; |
|
33
|
|
|
|
|
|
|
END_OF_EVAL |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
15
|
100
|
|
|
|
826
|
croak qq (Test::Load::Helper: Error compiling '$file': $@) |
|
37
|
|
|
|
|
|
|
if $@ |
|
38
|
|
|
|
|
|
|
; |
|
39
|
|
|
|
|
|
|
|
|
40
|
14
|
|
|
|
|
54
|
$INC{$key} = "$file"; |
|
41
|
14
|
|
|
|
|
451
|
return 1; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub identify_caller_file { |
|
45
|
19
|
|
|
19
|
0
|
48
|
my ($class, %args) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
19
|
|
|
|
|
24
|
my $level = 0; |
|
48
|
19
|
|
|
|
|
75
|
while (my @info = caller ($level++)) { |
|
49
|
57
|
|
|
|
|
90
|
my $file = $info[1]; |
|
50
|
57
|
100
|
|
|
|
176
|
next if $file eq __FILE__; |
|
51
|
19
|
50
|
|
|
|
485
|
return Path::Tiny::->new ($file) |
|
52
|
|
|
|
|
|
|
if -f $file |
|
53
|
|
|
|
|
|
|
; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
return path ('.'); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub identify_caller_package { |
|
60
|
19
|
|
|
19
|
0
|
45
|
my ($class, %args) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $args{into} |
|
63
|
|
|
|
|
|
|
if exists $args{into} |
|
64
|
19
|
100
|
|
|
|
91
|
; |
|
65
|
|
|
|
|
|
|
|
|
66
|
18
|
|
|
|
|
51
|
my $level = 0; |
|
67
|
18
|
|
|
|
|
144
|
while (my @info = caller ($level++)) { |
|
68
|
36
|
|
|
|
|
51
|
my $package = $info[0]; |
|
69
|
36
|
100
|
|
|
|
138
|
next if $package eq __PACKAGE__; |
|
70
|
18
|
|
|
|
|
74
|
return $package; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
0
|
return q (main); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub identify_helper_file { |
|
77
|
19
|
|
|
19
|
0
|
33
|
my ($class, %args) = @_; |
|
78
|
19
|
|
66
|
|
|
70
|
my $file = $args{file} // $DEFAULT_FILENAME; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $caller_file = exists $args{caller_file} |
|
81
|
|
|
|
|
|
|
? Path::Tiny::->new ($args{caller_file}) |
|
82
|
19
|
50
|
|
|
|
61
|
: $class->identify_caller_file (%args) |
|
83
|
|
|
|
|
|
|
; |
|
84
|
|
|
|
|
|
|
|
|
85
|
19
|
|
|
|
|
846
|
my $caller_dir = $caller_file->parent->absolute; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $root = $ENV{TEST_LOAD_ROOT} |
|
88
|
19
|
100
|
|
|
|
1448
|
? Path::Tiny::->new ($ENV{TEST_LOAD_ROOT})->absolute |
|
89
|
|
|
|
|
|
|
: Path::Tiny::->new (q (/)) |
|
90
|
|
|
|
|
|
|
; |
|
91
|
|
|
|
|
|
|
|
|
92
|
19
|
|
|
|
|
818
|
while (1) { |
|
93
|
30
|
|
|
|
|
75
|
my $candidate = $caller_dir->child ($file); |
|
94
|
|
|
|
|
|
|
|
|
95
|
30
|
100
|
100
|
|
|
846
|
return $candidate |
|
96
|
|
|
|
|
|
|
if $candidate ne $caller_file |
|
97
|
|
|
|
|
|
|
&& $candidate->exists |
|
98
|
|
|
|
|
|
|
; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
last |
|
101
|
13
|
100
|
|
|
|
659
|
if $caller_dir eq $root |
|
102
|
|
|
|
|
|
|
; |
|
103
|
|
|
|
|
|
|
|
|
104
|
11
|
|
|
|
|
93
|
my $parent = $caller_dir->parent; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
last |
|
107
|
11
|
50
|
|
|
|
425
|
if $parent eq $caller_dir |
|
108
|
|
|
|
|
|
|
; |
|
109
|
|
|
|
|
|
|
|
|
110
|
11
|
|
|
|
|
89
|
$caller_dir = $parent; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
2
|
|
|
|
|
122
|
return; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub import { |
|
117
|
19
|
|
|
19
|
|
166
|
my ($class, %args) = @_; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
return |
|
120
|
19
|
50
|
|
|
|
53
|
unless my $caller_package = $class->identify_caller_package (%args) |
|
121
|
|
|
|
|
|
|
; |
|
122
|
|
|
|
|
|
|
|
|
123
|
19
|
100
|
|
|
|
47
|
return 1 |
|
124
|
|
|
|
|
|
|
unless my $helper_file = $class->identify_helper_file (%args) |
|
125
|
|
|
|
|
|
|
; |
|
126
|
|
|
|
|
|
|
|
|
127
|
17
|
|
|
|
|
614
|
$class->eval_helper ( |
|
128
|
|
|
|
|
|
|
into => $caller_package, |
|
129
|
|
|
|
|
|
|
file => $helper_file, |
|
130
|
|
|
|
|
|
|
); |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub inc_key { |
|
134
|
17
|
|
|
17
|
0
|
35
|
my ($class, %args) = @_; |
|
135
|
|
|
|
|
|
|
|
|
136
|
17
|
|
|
|
|
31
|
my $into = $args{into}; |
|
137
|
17
|
|
|
|
|
28
|
my $file = $args{file}; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# File can be loaded into multiple target packages |
|
140
|
17
|
|
|
|
|
41
|
qq (${file}{${into}}); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
__END__ |