| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
## no critic (RequireUseStrict) |
|
2
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Test::LocalBrew; |
|
3
|
|
|
|
|
|
|
$Dist::Zilla::Plugin::Test::LocalBrew::VERSION = '0.07'; |
|
4
|
1
|
|
|
1
|
|
794
|
use File::Spec; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use File::Temp qw(tempdir); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
91
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use namespace::clean; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
## use critic (RequireUseStrict) |
|
10
|
1
|
|
|
1
|
|
146
|
use Moose; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
11
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileGatherer', 'Dist::Zilla::Role::TextTemplate'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has brews => ( |
|
14
|
|
|
|
|
|
|
is => 'ro', |
|
15
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
|
16
|
|
|
|
|
|
|
default => sub { [] }, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has notest_deps => ( |
|
20
|
|
|
|
|
|
|
is => 'ro', |
|
21
|
|
|
|
|
|
|
isa => 'Bool', |
|
22
|
|
|
|
|
|
|
default => 0, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has nobrew => ( |
|
26
|
|
|
|
|
|
|
is => 'ro', |
|
27
|
|
|
|
|
|
|
isa => 'Bool', |
|
28
|
|
|
|
|
|
|
default => 0, |
|
29
|
|
|
|
|
|
|
); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub should_test_deps { |
|
32
|
0
|
|
|
0
|
1
|
0
|
my ( $self ) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
return !$self->notest_deps; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub mvp_multivalue_args { |
|
38
|
2
|
|
|
2
|
1
|
52697
|
qw/brews/ |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $template = <<'TEMPLATE'; |
|
42
|
|
|
|
|
|
|
#!perl |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
use strict; |
|
45
|
|
|
|
|
|
|
use warnings; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use FindBin; |
|
48
|
|
|
|
|
|
|
use File::Copy qw(copy); |
|
49
|
|
|
|
|
|
|
use File::Spec; |
|
50
|
|
|
|
|
|
|
use File::Temp; |
|
51
|
|
|
|
|
|
|
use Test::More; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub copy_log_file { |
|
54
|
|
|
|
|
|
|
my ( $home ) = @_; |
|
55
|
|
|
|
|
|
|
my $log_file = File::Spec->catfile($home, '.cpanm', 'build.log'); |
|
56
|
|
|
|
|
|
|
my $tempfile = File::Temp->new( |
|
57
|
|
|
|
|
|
|
SUFFIX => '.log', |
|
58
|
|
|
|
|
|
|
UNLINK => 0, |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
copy($log_file, $tempfile->filename); |
|
61
|
|
|
|
|
|
|
diag("For details, please consult $tempfile") |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub is_dist_root { |
|
65
|
|
|
|
|
|
|
my ( @path ) = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return -e File::Spec->catfile(@path, 'Makefile.PL') || |
|
68
|
|
|
|
|
|
|
-e File::Spec->catfile(@path, 'Build.PL'); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
delete @ENV{qw/AUTHOR_TESTING RELEASE_TESTING PERL5LIB/}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
unless($ENV{'PERLBREW_ROOT'}) { |
|
74
|
|
|
|
|
|
|
plan skip_all => "Environment variable 'PERLBREW_ROOT' not found"; |
|
75
|
|
|
|
|
|
|
exit; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $brew = q[{{$brew || ''}}]; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $cpanm_path = qx(which cpanm 2>/dev/null); |
|
81
|
|
|
|
|
|
|
unless($cpanm_path) { |
|
82
|
|
|
|
|
|
|
plan skip_all => "The 'cpanm' program is required to run this test"; |
|
83
|
|
|
|
|
|
|
exit; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
chomp $cpanm_path; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $perlbrew_bin = File::Spec->catdir($ENV{'PERLBREW_ROOT'}, 'perls', |
|
88
|
|
|
|
|
|
|
$brew, 'bin'); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my ( $env, $status ) = do { |
|
91
|
|
|
|
|
|
|
local $ENV{'SHELL'} = '/bin/bash'; # fool perlbrew |
|
92
|
|
|
|
|
|
|
( scalar(qx(perlbrew env $brew)), $? ) |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
unless($status == 0) { |
|
96
|
|
|
|
|
|
|
plan skip_all => "No such perlbrew environment '$brew'"; |
|
97
|
|
|
|
|
|
|
exit; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my @lines = split /\n/, $env; |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
foreach my $line (@lines) { |
|
103
|
|
|
|
|
|
|
if($line =~ /^\s*export\s+([0-9a-zA-Z_]+)=(.*)$/) { |
|
104
|
|
|
|
|
|
|
my ( $k, $v ) = ( $1, $2 ); |
|
105
|
|
|
|
|
|
|
if($v =~ /^("|')(.*)\1$/) { |
|
106
|
|
|
|
|
|
|
$v = $2; |
|
107
|
|
|
|
|
|
|
$v =~ s!\\(.)!$1!ge; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
$ENV{$k} = $v; |
|
110
|
|
|
|
|
|
|
} elsif($line =~ /^unset\s+([0-9a-zA-Z_]+)/) { |
|
111
|
|
|
|
|
|
|
delete $ENV{$1}; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $pristine_path = qx(perlbrew display-pristine-path); |
|
116
|
|
|
|
|
|
|
chomp $pristine_path; |
|
117
|
|
|
|
|
|
|
$ENV{'PATH'} = join(':', $ENV{'PERLBREW_PATH'}, $pristine_path); |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
plan tests => 1; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $tmpdir = File::Temp->newdir; |
|
122
|
|
|
|
|
|
|
my $tmphome = File::Temp->newdir; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $pid = fork; |
|
125
|
|
|
|
|
|
|
if(!defined $pid) { |
|
126
|
|
|
|
|
|
|
fail "Forking failed!"; |
|
127
|
|
|
|
|
|
|
exit 1; |
|
128
|
|
|
|
|
|
|
} elsif($pid) { |
|
129
|
|
|
|
|
|
|
waitpid $pid, 0; |
|
130
|
|
|
|
|
|
|
ok !$?, "cpanm should successfully install your dist with no issues" or copy_log_file($tmphome->dirname); |
|
131
|
|
|
|
|
|
|
} else { |
|
132
|
|
|
|
|
|
|
close STDIN; |
|
133
|
|
|
|
|
|
|
close STDOUT; |
|
134
|
|
|
|
|
|
|
close STDERR; |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
my @path = File::Spec->splitdir($FindBin::Bin); |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
while(@path && !is_dist_root(@path)) { |
|
139
|
|
|
|
|
|
|
pop @path; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
unless(@path) { |
|
142
|
|
|
|
|
|
|
die "Unable to find dist root\n"; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
chdir File::Spec->catdir(@path); # exit test directory |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# override where cpanm puts its log file |
|
147
|
|
|
|
|
|
|
$ENV{'HOME'} = $tmphome->dirname; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
{{ |
|
150
|
|
|
|
|
|
|
unless($should_test_deps) { |
|
151
|
|
|
|
|
|
|
return <<'END_PERL'; |
|
152
|
|
|
|
|
|
|
system 'perl', $cpanm_path, '--notest', '--installdeps', '-L', $tmpdir->dirname, '.'; |
|
153
|
|
|
|
|
|
|
if($?) { |
|
154
|
|
|
|
|
|
|
exit($? >> 8); |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
END_PERL |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
return ''; |
|
159
|
|
|
|
|
|
|
}} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
system 'perl', $cpanm_path, '-L', $tmpdir->dirname, '.'; |
|
162
|
|
|
|
|
|
|
exit($? >> 8); |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
TEMPLATE |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub gather_files { |
|
167
|
2
|
|
|
2
|
1
|
90255
|
my ( $self ) = @_; |
|
168
|
|
|
|
|
|
|
|
|
169
|
2
|
|
|
|
|
91
|
my $brews = $self->brews; |
|
170
|
|
|
|
|
|
|
|
|
171
|
2
|
50
|
|
|
|
11
|
unless(@$brews) { |
|
172
|
2
|
|
|
|
|
16
|
$self->log_fatal('No perlbrew environments specified in your dist.ini'); |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
foreach my $brew (@$brews) { |
|
176
|
0
|
|
|
|
|
|
$self->add_file(Dist::Zilla::File::InMemory->new( |
|
177
|
|
|
|
|
|
|
name => "xt/release/localbrew-$brew.t", |
|
178
|
|
|
|
|
|
|
content => $self->fill_in_string($template, { |
|
179
|
|
|
|
|
|
|
brew => $brew, |
|
180
|
|
|
|
|
|
|
should_test_deps => $self->should_test_deps, |
|
181
|
|
|
|
|
|
|
}), |
|
182
|
|
|
|
|
|
|
)); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
0
|
0
|
|
|
|
|
if($self->nobrew) { |
|
186
|
0
|
|
|
|
|
|
$self->add_file(Dist::Zilla::File::InMemory->new( |
|
187
|
|
|
|
|
|
|
name => "xt/release/system-localbrew.t", |
|
188
|
|
|
|
|
|
|
content => $self->fill_in_string($template, { |
|
189
|
|
|
|
|
|
|
brew => undef, |
|
190
|
|
|
|
|
|
|
should_test_deps => $self->should_test_deps, |
|
191
|
|
|
|
|
|
|
}), |
|
192
|
|
|
|
|
|
|
)); |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
1
|
|
|
1
|
|
7081
|
no Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
197
|
|
|
|
|
|
|
1; |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=pod |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=encoding UTF-8 |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 NAME |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Test::LocalBrew - Verify that your distribution tests well in a fresh perlbrew |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=head1 VERSION |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
version 0.07 |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
# in your dist.ini |
|
214
|
|
|
|
|
|
|
[Test::LocalBrew] |
|
215
|
|
|
|
|
|
|
brews = first-perlbrew |
|
216
|
|
|
|
|
|
|
brews = second-perlbrew |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
This plugin adds a release test for your module that tests it against a set |
|
221
|
|
|
|
|
|
|
of given perlbrew environments. Any dependencies are installed via cpanminus |
|
222
|
|
|
|
|
|
|
into a temporary local lib, so your perlbrew environments aren't altered. |
|
223
|
|
|
|
|
|
|
This comes in handy when you want to build against a set of "fresh" Perl |
|
224
|
|
|
|
|
|
|
installations (ie. those with only core modules) to make sure all of your |
|
225
|
|
|
|
|
|
|
prerequisites are included correctly. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 brews |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
A list of perlbrew environments to build and test in. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head2 notest_deps |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
If this flag is set, don't test dependency modules. |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head2 nobrew |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
If this flag is set, test against the system perl as well. |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 ISSUES |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=over |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item Relies on the 'which' program to detect cpanm. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=back |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
L<Dist::Zilla>, L<App::perlbrew>, L<App::cpanminus>, L<local::lib> |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=begin comment |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=over |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=item mvp_multivalue_args |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item gather_files |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item should_test_deps |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=back |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=end comment |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 AUTHOR |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Rob Hoelz <rob@hoelz.ro> |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Rob Hoelz. |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
276
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 BUGS |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
|
281
|
|
|
|
|
|
|
https://github.com/hoelzro/dist-zilla-plugin-test-localbrew/issues |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
|
284
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
|
285
|
|
|
|
|
|
|
feature. |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=cut |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
__END__ |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
# ABSTRACT: Verify that your distribution tests well in a fresh perlbrew |
|
292
|
|
|
|
|
|
|
|