| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# file: lib/Test/Dist/Zilla/BuiltFiles.pm |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Copyright © 2015 Van de Bugger |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# This file is part of perl-Test-Dist-Zilla. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# perl-Test-Dist-Zilla is free software: you can redistribute it and/or modify it under the terms |
|
10
|
|
|
|
|
|
|
# of the GNU General Public License as published by the Free Software Foundation, either version |
|
11
|
|
|
|
|
|
|
# 3 of the License, or (at your option) any later version. |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# perl-Test-Dist-Zilla is distributed in the hope that it will be useful, but WITHOUT ANY |
|
14
|
|
|
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15
|
|
|
|
|
|
|
# PURPOSE. See the GNU General Public License for more details. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along with |
|
18
|
|
|
|
|
|
|
# perl-Test-Dist-Zilla. If not, see <http://www.gnu.org/licenses/>. |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
23
|
|
|
|
|
|
|
#pod |
|
24
|
|
|
|
|
|
|
#pod package ManifestTester2; |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod use Test::Deep qw{ cmp_deeply re }; |
|
27
|
|
|
|
|
|
|
#pod use Test::More; |
|
28
|
|
|
|
|
|
|
#pod use Test::Routine; |
|
29
|
|
|
|
|
|
|
#pod use Test::Routine::Util; |
|
30
|
|
|
|
|
|
|
#pod |
|
31
|
|
|
|
|
|
|
#pod with 'Test::Dist::Zilla::Build'; |
|
32
|
|
|
|
|
|
|
#pod with 'Test::Dist::Zilla::BuiltFiles'; |
|
33
|
|
|
|
|
|
|
#pod |
|
34
|
|
|
|
|
|
|
#pod run_me 'A test' => { |
|
35
|
|
|
|
|
|
|
#pod plugins => [ |
|
36
|
|
|
|
|
|
|
#pod 'GatherDir', |
|
37
|
|
|
|
|
|
|
#pod 'Manifest', |
|
38
|
|
|
|
|
|
|
#pod 'MetaJSON', |
|
39
|
|
|
|
|
|
|
#pod ], |
|
40
|
|
|
|
|
|
|
#pod files => { |
|
41
|
|
|
|
|
|
|
#pod 'lib/Dummy.pm' => 'package Dummy; 1;', |
|
42
|
|
|
|
|
|
|
#pod }, |
|
43
|
|
|
|
|
|
|
#pod expected => { |
|
44
|
|
|
|
|
|
|
#pod files => { |
|
45
|
|
|
|
|
|
|
#pod 'MANIFEST' => [ |
|
46
|
|
|
|
|
|
|
#pod 'lib/Dunny.pm', |
|
47
|
|
|
|
|
|
|
#pod 'MANIFEST', |
|
48
|
|
|
|
|
|
|
#pod 'META.json', |
|
49
|
|
|
|
|
|
|
#pod ], |
|
50
|
|
|
|
|
|
|
#pod }, |
|
51
|
|
|
|
|
|
|
#pod }, |
|
52
|
|
|
|
|
|
|
#pod }; |
|
53
|
|
|
|
|
|
|
#pod |
|
54
|
|
|
|
|
|
|
#pod exit( 0 ); |
|
55
|
|
|
|
|
|
|
#pod |
|
56
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
57
|
|
|
|
|
|
|
#pod |
|
58
|
|
|
|
|
|
|
#pod This is a C<Test::Routine>-based role for testing C<Dist::Zilla> and its plugins. It is intended to |
|
59
|
|
|
|
|
|
|
#pod be used in cooperation with C<Test::Dist::Zilla::Build> role. C<Test::Dist::Zilla::Build> builds |
|
60
|
|
|
|
|
|
|
#pod the distribution and checks exception and build messages, while C<Test::Dist::Zilla::BuiltFiles> |
|
61
|
|
|
|
|
|
|
#pod checks built files. |
|
62
|
|
|
|
|
|
|
#pod |
|
63
|
|
|
|
|
|
|
#pod =cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package Test::Dist::Zilla::BuiltFiles; |
|
66
|
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
|
5931
|
use namespace::autoclean; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
7
|
|
|
68
|
1
|
|
|
1
|
|
72
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
26
|
|
|
69
|
1
|
|
|
1
|
|
6
|
use version 0.77; |
|
|
1
|
|
|
|
|
21
|
|
|
|
1
|
|
|
|
|
8
|
|
|
70
|
1
|
|
|
1
|
|
64
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# ABSTRACT: TODO: Test your Dist::Zilla plugin in I<build> action |
|
73
|
|
|
|
|
|
|
our $VERSION = 'v0.4.2'; # VERSION |
|
74
|
|
|
|
|
|
|
|
|
75
|
1
|
|
|
1
|
|
5
|
use Test::Routine; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#~ requires qw{ tzil exception expected }; |
|
78
|
|
|
|
|
|
|
|
|
79
|
1
|
|
|
1
|
|
6702
|
use Test::Deep qw{ cmp_deeply }; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
80
|
1
|
|
|
1
|
|
123
|
use Path::Tiny; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
50
|
|
|
81
|
1
|
|
|
1
|
|
5
|
use Test::More; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
9
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#pod =method BuiltFiles |
|
86
|
|
|
|
|
|
|
#pod |
|
87
|
|
|
|
|
|
|
#pod It is a test routine. It checks built files. Names of files to check should be be enlisted in |
|
88
|
|
|
|
|
|
|
#pod C<files> key of C<expected> hash. Value should be C<HashRef>, keys are filenames, values are file |
|
89
|
|
|
|
|
|
|
#pod content. File content may be specified as C<Str> or C<ArrayRef[Str]>: |
|
90
|
|
|
|
|
|
|
#pod |
|
91
|
|
|
|
|
|
|
#pod run_me { |
|
92
|
|
|
|
|
|
|
#pod ⦠|
|
93
|
|
|
|
|
|
|
#pod expected => { |
|
94
|
|
|
|
|
|
|
#pod files => { |
|
95
|
|
|
|
|
|
|
#pod 'filename1' => "line1\nline2\n", |
|
96
|
|
|
|
|
|
|
#pod 'filename2' => [ |
|
97
|
|
|
|
|
|
|
#pod 'line1', # Should not include newline character. |
|
98
|
|
|
|
|
|
|
#pod 'line2' |
|
99
|
|
|
|
|
|
|
#pod ], |
|
100
|
|
|
|
|
|
|
#pod 'filename3' => undef, # This file should not exist. |
|
101
|
|
|
|
|
|
|
#pod }, |
|
102
|
|
|
|
|
|
|
#pod }, |
|
103
|
|
|
|
|
|
|
#pod }; |
|
104
|
|
|
|
|
|
|
#pod |
|
105
|
|
|
|
|
|
|
#pod For every file the test routine checks the file exists and its actual content matches the expected |
|
106
|
|
|
|
|
|
|
#pod content. If expected content is C<undef>, the file should not exists. |
|
107
|
|
|
|
|
|
|
#pod |
|
108
|
|
|
|
|
|
|
#pod Note: C<BuiltFiles> assumes successful build. If an exception occurred, C<BuiltFiles> skips all the |
|
109
|
|
|
|
|
|
|
#pod checks. |
|
110
|
|
|
|
|
|
|
#pod |
|
111
|
|
|
|
|
|
|
#pod =cut |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
test 'BuiltFiles' => sub { |
|
114
|
1
|
|
|
1
|
|
803
|
my ( $self ) = @_; |
|
115
|
1
|
|
|
|
|
47
|
my $expected = $self->expected; |
|
116
|
1
|
50
|
|
|
|
6
|
if ( not exists( $expected->{ files } ) ) { |
|
117
|
0
|
|
|
|
|
0
|
plan skip_all => 'no expected files specified'; |
|
118
|
|
|
|
|
|
|
}; |
|
119
|
1
|
50
|
|
|
|
41
|
if ( $self->exception ) { |
|
120
|
0
|
|
|
|
|
0
|
plan skip_all => 'exception occurred'; |
|
121
|
|
|
|
|
|
|
}; |
|
122
|
1
|
|
|
|
|
3
|
my @names = keys( %{ $expected->{ files } } ); # Name of files to check. |
|
|
1
|
|
|
|
|
6
|
|
|
123
|
1
|
|
|
|
|
40
|
my $built_in = path( $self->tzil->built_in ); # Build directory. |
|
124
|
1
|
|
|
|
|
79
|
plan 'no_plan'; |
|
125
|
1
|
|
|
|
|
33
|
for my $name ( @names ) { |
|
126
|
5
|
|
|
|
|
2933
|
my $exp = $expected->{ files }->{ $name }; # Expected content. |
|
127
|
5
|
|
|
|
|
19
|
my $file = $built_in->child( $name ); # Actual file. |
|
128
|
5
|
100
|
|
|
|
205
|
if ( defined( $exp ) ) { |
|
129
|
4
|
50
|
|
|
|
14
|
ok( $file->exists, "$name exists" ) and do { |
|
130
|
|
|
|
|
|
|
my $act = ref( $exp ) eq 'ARRAY' ? ( |
|
131
|
|
|
|
|
|
|
# `$file->lines_utf8( { chomp => 1 } )` does not work as expected in |
|
132
|
|
|
|
|
|
|
# `Path::Tiny` 0.068 .. 0.072 (at least), see |
|
133
|
|
|
|
|
|
|
# <https://github.com/dagolden/Path-Tiny/issues/152>. |
|
134
|
|
|
|
|
|
|
# To workaround the problem, `chomp` lines manually. |
|
135
|
4
|
100
|
|
|
|
1723
|
[ do { my @l = $file->lines_utf8(); chomp( @l ); @l; } ] |
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
1785
|
|
|
|
1
|
|
|
|
|
5
|
|
|
136
|
|
|
|
|
|
|
) : ( |
|
137
|
|
|
|
|
|
|
$file->slurp_utf8() |
|
138
|
|
|
|
|
|
|
); |
|
139
|
4
|
50
|
|
|
|
454
|
cmp_deeply( $act, $exp, "$name content" ) or do { |
|
140
|
0
|
0
|
|
|
|
0
|
$self->_anno_text( $name, ref( $act ) ? @$act : $act ); |
|
141
|
|
|
|
|
|
|
}; |
|
142
|
|
|
|
|
|
|
}; |
|
143
|
|
|
|
|
|
|
} else { |
|
144
|
1
|
|
|
|
|
5
|
ok( ! $file->exists, "$name not exist" ); |
|
145
|
|
|
|
|
|
|
}; |
|
146
|
|
|
|
|
|
|
}; |
|
147
|
|
|
|
|
|
|
}; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
156
|
|
|
|
|
|
|
#pod |
|
157
|
|
|
|
|
|
|
#pod =for :list |
|
158
|
|
|
|
|
|
|
#pod = L<Test::Dist::Zilla> |
|
159
|
|
|
|
|
|
|
#pod = L<Test::Dist::Zilla::Build> |
|
160
|
|
|
|
|
|
|
#pod = L<Test::Deep/"$ok = cmp_deeply($got, $expected, $name)"> |
|
161
|
|
|
|
|
|
|
#pod = L<Test::Routine> |
|
162
|
|
|
|
|
|
|
#pod |
|
163
|
|
|
|
|
|
|
#pod =head1 COPYRIGHT AND LICENSE |
|
164
|
|
|
|
|
|
|
#pod |
|
165
|
|
|
|
|
|
|
#pod Copyright (C) 2015 Van de Bugger |
|
166
|
|
|
|
|
|
|
#pod |
|
167
|
|
|
|
|
|
|
#pod License GPLv3+: The GNU General Public License version 3 or later |
|
168
|
|
|
|
|
|
|
#pod <http://www.gnu.org/licenses/gpl-3.0.txt>. |
|
169
|
|
|
|
|
|
|
#pod |
|
170
|
|
|
|
|
|
|
#pod This is free software: you are free to change and redistribute it. There is |
|
171
|
|
|
|
|
|
|
#pod NO WARRANTY, to the extent permitted by law. |
|
172
|
|
|
|
|
|
|
#pod |
|
173
|
|
|
|
|
|
|
#pod |
|
174
|
|
|
|
|
|
|
#pod =cut |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# end of file # |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
__END__ |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=pod |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=encoding UTF-8 |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 NAME |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Test::Dist::Zilla::BuiltFiles - TODO: Test your Dist::Zilla plugin in I<build> action |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 VERSION |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Version v0.4.2, released on 2015-10-31 08:49 UTC. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
package ManifestTester2; |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
use Test::Deep qw{ cmp_deeply re }; |
|
197
|
|
|
|
|
|
|
use Test::More; |
|
198
|
|
|
|
|
|
|
use Test::Routine; |
|
199
|
|
|
|
|
|
|
use Test::Routine::Util; |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
with 'Test::Dist::Zilla::Build'; |
|
202
|
|
|
|
|
|
|
with 'Test::Dist::Zilla::BuiltFiles'; |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
run_me 'A test' => { |
|
205
|
|
|
|
|
|
|
plugins => [ |
|
206
|
|
|
|
|
|
|
'GatherDir', |
|
207
|
|
|
|
|
|
|
'Manifest', |
|
208
|
|
|
|
|
|
|
'MetaJSON', |
|
209
|
|
|
|
|
|
|
], |
|
210
|
|
|
|
|
|
|
files => { |
|
211
|
|
|
|
|
|
|
'lib/Dummy.pm' => 'package Dummy; 1;', |
|
212
|
|
|
|
|
|
|
}, |
|
213
|
|
|
|
|
|
|
expected => { |
|
214
|
|
|
|
|
|
|
files => { |
|
215
|
|
|
|
|
|
|
'MANIFEST' => [ |
|
216
|
|
|
|
|
|
|
'lib/Dunny.pm', |
|
217
|
|
|
|
|
|
|
'MANIFEST', |
|
218
|
|
|
|
|
|
|
'META.json', |
|
219
|
|
|
|
|
|
|
], |
|
220
|
|
|
|
|
|
|
}, |
|
221
|
|
|
|
|
|
|
}, |
|
222
|
|
|
|
|
|
|
}; |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
exit( 0 ); |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
This is a C<Test::Routine>-based role for testing C<Dist::Zilla> and its plugins. It is intended to |
|
229
|
|
|
|
|
|
|
be used in cooperation with C<Test::Dist::Zilla::Build> role. C<Test::Dist::Zilla::Build> builds |
|
230
|
|
|
|
|
|
|
the distribution and checks exception and build messages, while C<Test::Dist::Zilla::BuiltFiles> |
|
231
|
|
|
|
|
|
|
checks built files. |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 BuiltFiles |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
It is a test routine. It checks built files. Names of files to check should be be enlisted in |
|
238
|
|
|
|
|
|
|
C<files> key of C<expected> hash. Value should be C<HashRef>, keys are filenames, values are file |
|
239
|
|
|
|
|
|
|
content. File content may be specified as C<Str> or C<ArrayRef[Str]>: |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
run_me { |
|
242
|
|
|
|
|
|
|
⦠|
|
243
|
|
|
|
|
|
|
expected => { |
|
244
|
|
|
|
|
|
|
files => { |
|
245
|
|
|
|
|
|
|
'filename1' => "line1\nline2\n", |
|
246
|
|
|
|
|
|
|
'filename2' => [ |
|
247
|
|
|
|
|
|
|
'line1', # Should not include newline character. |
|
248
|
|
|
|
|
|
|
'line2' |
|
249
|
|
|
|
|
|
|
], |
|
250
|
|
|
|
|
|
|
'filename3' => undef, # This file should not exist. |
|
251
|
|
|
|
|
|
|
}, |
|
252
|
|
|
|
|
|
|
}, |
|
253
|
|
|
|
|
|
|
}; |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
For every file the test routine checks the file exists and its actual content matches the expected |
|
256
|
|
|
|
|
|
|
content. If expected content is C<undef>, the file should not exists. |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Note: C<BuiltFiles> assumes successful build. If an exception occurred, C<BuiltFiles> skips all the |
|
259
|
|
|
|
|
|
|
checks. |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=over 4 |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item L<Test::Dist::Zilla> |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item L<Test::Dist::Zilla::Build> |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item L<Test::Deep/"$ok = cmp_deeply($got, $expected, $name)"> |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=item L<Test::Routine> |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=back |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=head1 AUTHOR |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
Van de Bugger <van.de.bugger@gmail.com> |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
Copyright (C) 2015 Van de Bugger |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
License GPLv3+: The GNU General Public License version 3 or later |
|
284
|
|
|
|
|
|
|
<http://www.gnu.org/licenses/gpl-3.0.txt>. |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
This is free software: you are free to change and redistribute it. There is |
|
287
|
|
|
|
|
|
|
NO WARRANTY, to the extent permitted by law. |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=cut |