line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Test::Mock; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1508
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
54
|
|
5
|
2
|
|
|
2
|
|
41
|
use 5.008004; |
|
2
|
|
|
|
|
18
|
|
6
|
2
|
|
|
2
|
|
370
|
use Alien::Build::Plugin; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
14
|
|
7
|
2
|
|
|
2
|
|
13
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
34
|
|
8
|
2
|
|
|
2
|
|
11
|
use Path::Tiny (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
28
|
|
9
|
2
|
|
|
2
|
|
501
|
use File::chdir; |
|
2
|
|
|
|
|
2926
|
|
|
2
|
|
|
|
|
2124
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Mock plugin for testing |
12
|
|
|
|
|
|
|
our $VERSION = '2.45'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'probe'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has 'download'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'extract'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has 'build'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'gather'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub init |
30
|
|
|
|
|
|
|
{ |
31
|
14
|
|
|
14
|
1
|
47
|
my($self, $meta) = @_; |
32
|
|
|
|
|
|
|
|
33
|
14
|
100
|
|
|
|
56
|
if(my $probe = $self->probe) |
34
|
|
|
|
|
|
|
{ |
35
|
8
|
100
|
|
|
|
74
|
if($probe =~ /^(share|system)$/) |
|
|
50
|
|
|
|
|
|
36
|
|
|
|
|
|
|
{ |
37
|
|
|
|
|
|
|
$meta->register_hook( |
38
|
|
|
|
|
|
|
probe => sub { |
39
|
7
|
|
|
7
|
|
19
|
$probe; |
40
|
|
|
|
|
|
|
}, |
41
|
7
|
|
|
|
|
55
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif($probe eq 'die') |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
$meta->register_hook( |
46
|
|
|
|
|
|
|
probe => sub { |
47
|
1
|
|
|
1
|
|
15
|
die "fail"; |
48
|
|
|
|
|
|
|
}, |
49
|
1
|
|
|
|
|
8
|
); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else |
52
|
|
|
|
|
|
|
{ |
53
|
0
|
|
|
|
|
0
|
Carp::croak("usage: plugin 'Test::Mock' => ( probe => $probe ); where $probe is one of share, system or die"); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
14
|
100
|
|
|
|
66
|
if(my $download = $self->download) |
58
|
|
|
|
|
|
|
{ |
59
|
10
|
100
|
|
|
|
66
|
$download = { 'foo-1.00.tar.gz' => _tarball() } unless ref $download eq 'HASH'; |
60
|
|
|
|
|
|
|
$meta->register_hook( |
61
|
|
|
|
|
|
|
download => sub { |
62
|
8
|
|
|
8
|
|
25
|
my($build) = @_; |
63
|
8
|
|
|
|
|
32
|
_fs($build, $download); |
64
|
|
|
|
|
|
|
}, |
65
|
10
|
|
|
|
|
72
|
); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
14
|
100
|
|
|
|
46
|
if(my $extract = $self->extract) |
69
|
|
|
|
|
|
|
{ |
70
|
8
|
100
|
|
|
|
44
|
$extract = { |
71
|
|
|
|
|
|
|
'foo-1.00' => { |
72
|
|
|
|
|
|
|
'configure' => _tarball_configure(), |
73
|
|
|
|
|
|
|
'foo.c' => _tarball_foo_c(), |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
} unless ref $extract eq 'HASH'; |
76
|
|
|
|
|
|
|
$meta->register_hook( |
77
|
|
|
|
|
|
|
extract => sub { |
78
|
10
|
|
|
10
|
|
22
|
my($build) = @_; |
79
|
10
|
|
|
|
|
27
|
_fs($build, $extract); |
80
|
|
|
|
|
|
|
}, |
81
|
8
|
|
|
|
|
45
|
); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
14
|
100
|
|
|
|
53
|
if(my $build = $self->build) |
85
|
|
|
|
|
|
|
{ |
86
|
|
|
|
|
|
|
$build = [ |
87
|
|
|
|
|
|
|
{ |
88
|
|
|
|
|
|
|
'foo.o', => _build_foo_o(), |
89
|
|
|
|
|
|
|
'libfoo.a' => _build_libfoo_a(), |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
{ |
92
|
|
|
|
|
|
|
'lib' => { |
93
|
|
|
|
|
|
|
'libfoo.a' => _build_libfoo_a(), |
94
|
|
|
|
|
|
|
'pkgconfig' => { |
95
|
|
|
|
|
|
|
'foo.pc' => sub { |
96
|
3
|
|
|
3
|
|
95
|
my($build) = @_; |
97
|
3
|
|
|
|
|
11
|
"prefix=$CWD\n" . |
98
|
|
|
|
|
|
|
"exec_prefix=\${prefix}\n" . |
99
|
|
|
|
|
|
|
"libdir=\${prefix}/lib\n" . |
100
|
|
|
|
|
|
|
"includedir=\${prefix}/include\n" . |
101
|
|
|
|
|
|
|
"\n" . |
102
|
|
|
|
|
|
|
"Name: libfoo\n" . |
103
|
|
|
|
|
|
|
"Description: libfoo\n" . |
104
|
|
|
|
|
|
|
"Version: 1.0.0\n" . |
105
|
|
|
|
|
|
|
"Cflags: -I\${includedir}\n" . |
106
|
|
|
|
|
|
|
"Libs: -L\${libdir} -lfoo\n"; |
107
|
|
|
|
|
|
|
}, |
108
|
|
|
|
|
|
|
}, |
109
|
|
|
|
|
|
|
}, |
110
|
|
|
|
|
|
|
}, |
111
|
6
|
100
|
|
|
|
33
|
] unless ref $build eq 'ARRAY'; |
112
|
|
|
|
|
|
|
|
113
|
6
|
|
|
|
|
18
|
my($build_dir, $install_dir) = @$build; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$meta->register_hook( |
116
|
|
|
|
|
|
|
build => sub { |
117
|
4
|
|
|
4
|
|
9
|
my($build) = @_; |
118
|
4
|
|
|
|
|
13
|
_fs($build, $build_dir); |
119
|
4
|
|
|
|
|
1402
|
local $CWD = $build->install_prop->{prefix}; |
120
|
4
|
|
|
|
|
174
|
_fs($build, $install_dir); |
121
|
|
|
|
|
|
|
}, |
122
|
6
|
|
|
|
|
41
|
); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
14
|
100
|
|
|
|
43
|
if(my $gather = $self->gather) |
126
|
|
|
|
|
|
|
{ |
127
|
|
|
|
|
|
|
$meta->register_hook( |
128
|
|
|
|
|
|
|
$_ => sub { |
129
|
4
|
|
|
4
|
|
13
|
my($build) = @_; |
130
|
4
|
100
|
|
|
|
14
|
if(ref $gather eq 'HASH') |
131
|
|
|
|
|
|
|
{ |
132
|
2
|
|
|
|
|
19
|
foreach my $key (keys %$gather) |
133
|
|
|
|
|
|
|
{ |
134
|
4
|
|
|
|
|
13
|
$build->runtime_prop->{$key} = $gather->{$key}; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
else |
138
|
|
|
|
|
|
|
{ |
139
|
2
|
|
|
|
|
8
|
my $prefix = $build->runtime_prop->{prefix}; |
140
|
2
|
|
|
|
|
9
|
$build->runtime_prop->{cflags} = "-I$prefix/include"; |
141
|
2
|
|
|
|
|
42
|
$build->runtime_prop->{libs} = "-L$prefix/lib -lfoo"; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
}, |
144
|
4
|
|
|
|
|
29
|
) for qw( gather_share gather_system ); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub _fs |
149
|
|
|
|
|
|
|
{ |
150
|
42
|
|
|
42
|
|
90
|
my($build, $hash) = @_; |
151
|
|
|
|
|
|
|
|
152
|
42
|
|
|
|
|
188
|
foreach my $key (sort keys %$hash) |
153
|
|
|
|
|
|
|
{ |
154
|
59
|
|
|
|
|
6335
|
my $val = $hash->{$key}; |
155
|
59
|
100
|
|
|
|
220
|
if(ref $val eq 'HASH') |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
156
|
|
|
|
|
|
|
{ |
157
|
16
|
|
|
|
|
666
|
mkdir $key; |
158
|
16
|
|
|
|
|
124
|
local $CWD = $key; |
159
|
16
|
|
|
|
|
862
|
_fs($build,$val); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
elsif(ref $val eq 'CODE') |
162
|
|
|
|
|
|
|
{ |
163
|
3
|
|
|
|
|
15
|
Path::Tiny->new($key)->spew($val->($build)); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
elsif(defined $val) |
166
|
|
|
|
|
|
|
{ |
167
|
40
|
|
|
|
|
149
|
Path::Tiny->new($key)->spew($val); |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub _tarball |
173
|
|
|
|
|
|
|
{ |
174
|
9
|
|
|
9
|
|
104
|
return unpack 'u', <<'EOF'; |
175
|
|
|
|
|
|
|
M'XL(`+DM@5@``^V4P4K$,!"&>YZGF-V]J*SM9#=)#RN^B'BHV;0)U`32U(OX |
176
|
|
|
|
|
|
|
M[D;0*LJREZVRF.\R?TA@)OS\TWI_S4JBJI@/(JJ%P%19+>AKG4"V)4Z;C922 |
177
|
|
|
|
|
|
|
M(;T=6(%BQIDFQB$V(8WB^]X.W>%WQ^[?_S'5,Z']\%]YU]IN#/KT/8[ZO^6? |
178
|
|
|
|
|
|
|
M_B=-C-=<%$BG'^4G_]S_U:)ZL*X:#(!6QN/26(Q&![W |
179
|
|
|
|
|
|
|
M'BD/DO/#^6
|
180
|
|
|
|
|
|
|
D-`&ODGZZN[^$9T`,.H[!(>W@)2^*3":3.3]>`:%LBYL`#@`` |
181
|
|
|
|
|
|
|
` |
182
|
|
|
|
|
|
|
EOF |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub _tarball_configure |
186
|
|
|
|
|
|
|
{ |
187
|
7
|
|
|
7
|
|
29
|
return unpack 'u', <<'EOF'; |
188
|
|
|
|
|
|
|
<(R$O8FEN+W-H"@IE8VAO(")H:2!T:&5R92(["@`` |
189
|
|
|
|
|
|
|
` |
190
|
|
|
|
|
|
|
EOF |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub _tarball_foo_c |
194
|
|
|
|
|
|
|
{ |
195
|
7
|
|
|
7
|
|
40
|
return unpack 'u', <<'EOF'; |
196
|
|
|
|
|
|
|
M(VEN8VQU9&4@/'-T9&EO+F@^"@II;G0*;6%I;BAI;G0@87)G8RP@8VAA
|
197
|
|
|
|
|
|
|
887)G=EM=*0I["B`@
|
198
|
|
|
|
|
|
|
` |
199
|
|
|
|
|
|
|
EOF |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub _build_foo_o |
203
|
|
|
|
|
|
|
{ |
204
|
5
|
|
|
5
|
|
45
|
return unpack 'u', <<'EOF'; |
205
|
|
|
|
|
|
|
MS_KM_@<```$#`````0````0```"P`0```"`````````9````.`$````````` |
206
|
|
|
|
|
|
|
M`````````````````````````&@`````````T`$```````!H``````````<` |
207
|
|
|
|
|
|
|
M```'`````P````````!?7W1E>'0`````````````7U]415A4```````````` |
208
|
|
|
|
|
|
|
M````````````"`````````#0`0``!`````````````````0`@``````````` |
209
|
|
|
|
|
|
|
M`````%]?8V]M<&%C=%]U;G=I;F1?7TQ$````````````````"``````````@ |
210
|
|
|
|
|
|
|
M`````````-@!```#````.`(```$````````"````````````````7U]E:%]F |
211
|
|
|
|
|
|
|
M
|
212
|
|
|
|
|
|
|
M``,```````````````L``&@````````````````D````$``````-"@`````` |
213
|
|
|
|
|
|
|
M`@```!@```!``@```0```%`"```(````"P```%`````````````````````! |
214
|
|
|
|
|
|
|
M`````0`````````````````````````````````````````````````````` |
215
|
|
|
|
|
|
|
M``````````````````!52(GE,
|
216
|
|
|
|
|
|
|
M````````````%``````````!>E(``7@0`1`,!PB0`0``)````!P```"X____ |
217
|
|
|
|
|
|
|
M_____P@``````````$$.$(8"0PT&```````````````!```&`0````\!```` |
218
|
|
|
|
|
|
|
/``````````!?;6%I;@`` |
219
|
|
|
|
|
|
|
` |
220
|
|
|
|
|
|
|
EOF |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub _build_libfoo_a |
224
|
|
|
|
|
|
|
{ |
225
|
10
|
|
|
10
|
|
121
|
return unpack 'u', <<'EOF'; |
226
|
|
|
|
|
|
|
M(3QA
|
227
|
|
|
|
|
|
|
M("`@,3`P-C0T("`T-"`@("`@("`@8`I?7RY364U$148@4T]25$5$``````@` |
228
|
|
|
|
|
|
|
M````````<`````@```!?;6%I;@```",Q+S$R("`@("`@("`@("`Q-3,S,34U |
229
|
|
|
|
|
|
|
M-#8X("`U,#$@("`R,"`@("`Q,#`V-#0@(#8Q,B`@("`@("!@"F9O;RYO```` |
230
|
|
|
|
|
|
|
M`````,_Z[?X'```!`P````$````$````L`$````@````````&0```#@!```` |
231
|
|
|
|
|
|
|
M``````````````````````````````!H`````````-`!````````:``````` |
232
|
|
|
|
|
|
|
M```'````!P````,`````````7U]T97AT`````````````%]?5$585``````` |
233
|
|
|
|
|
|
|
M``````````````````@`````````T`$```0````````````````$`(`````` |
234
|
|
|
|
|
|
|
M``````````!?7V-O;7!A8W1?=6YW:6YD7U],1`````````````````@````` |
235
|
|
|
|
|
|
|
M````(`````````#8`0```P```#@"```!`````````@```````````````%]? |
236
|
|
|
|
|
|
|
M96A?9G)A;64```````!?7U1%6%0`````````````*`````````!````````` |
237
|
|
|
|
|
|
|
M`/@!```#```````````````+``!H````````````````)````!``````#0H` |
238
|
|
|
|
|
|
|
M``````(````8````0`(```$```!0`@``"`````L```!0```````````````` |
239
|
|
|
|
|
|
|
M`````0````$````````````````````````````````````````````````` |
240
|
|
|
|
|
|
|
M````````````````````````54B)Y3'`7<,```````````@````````!```` |
241
|
|
|
|
|
|
|
M`````````````````!0``````````7I2``%X$`$0#`<(D`$``"0````<```` |
242
|
|
|
|
|
|
|
MN/________\(``````````!!#A"&`D,-!@```````````````0``!@$````/ |
243
|
|
|
|
|
|
|
3`0``````````````7VUA:6X````` |
244
|
|
|
|
|
|
|
` |
245
|
|
|
|
|
|
|
EOF |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
1; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
__END__ |