This file is indexed.

/usr/share/perl5/Test/DZil.pm is in libdist-zilla-perl 5.043-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
use strict;
use warnings;
package Test::DZil;
# ABSTRACT: tools for testing Dist::Zilla plugins
$Test::DZil::VERSION = '5.043';
use Dist::Zilla::Tester;
use Params::Util qw(_HASH0);
use JSON::MaybeXS;
use Scalar::Util qw(blessed);
use Test::Deep ();
use YAML::Tiny;

use Sub::Exporter -setup => {
  exports => [
    is_filelist =>
    is_yaml     =>
    is_json     =>
    dist_ini    => \'_dist_ini',
    simple_ini  => \'_simple_ini',
    Builder     =>
    Minter      =>
  ],
  groups  => [ default => [ qw(-all) ] ],
};

#pod =head1 DESCRIPTION
#pod
#pod Test::DZil provides routines for writing tests for Dist::Zilla plugins.
#pod
#pod =cut

#pod =func Builder
#pod
#pod =func Minter
#pod
#pod   my $tzil = Builder->from_config(...);
#pod
#pod These return class names that subclass L<Dist::Zilla::Dist::Builder> or
#pod L<Dist::Zilla::Dist::Minter>, respectively, with the L<Dist::Zilla::Tester>
#pod behavior added.
#pod
#pod =func is_filelist
#pod
#pod   is_filelist( \@files_we_have, \@files_we_want, $desc );
#pod
#pod This test assertion compares two arrayrefs of filenames, taking care of slash
#pod normalization and sorting.  C<@files_we_have> may also contain objects that
#pod do L<Dist::Zilla::Role::File>.
#pod
#pod =cut

sub is_filelist {
  my ($have, $want, $comment) = @_;

  my @want = @$want;
  my @have = map { my $str = (blessed $_ and
                              $_->DOES('Dist::Zilla::Role::File'))
                       ? $_->name
                       : $_;
                   $str =~ s{\\}{/}g; $str } @$have;

  local $Test::Builder::Level = $Test::Builder::Level + 1;
  Test::Deep::cmp_bag(\@have, \@want, $comment);
}

#pod =func is_yaml
#pod
#pod   is_yaml( $yaml_string, $want_struct, $comment );
#pod
#pod This test assertion deserializes the given YAML string and does a
#pod C<L<cmp_deeply|Test::Deep/cmp_deeply>>.
#pod
#pod =cut

sub is_yaml {
  my ($yaml, $want, $comment) = @_;

  my $have = YAML::Tiny->read_string($yaml)
    or die "Cannot decode YAML";

  local $Test::Builder::Level = $Test::Builder::Level + 1;
  Test::Deep::cmp_deeply($have->[0], $want, $comment);
}

#pod =func is_json
#pod
#pod   is_json( $json_string, $want_struct, $comment );
#pod
#pod This test assertion deserializes the given JSON string and does a
#pod C<L<cmp_deeply|Test::Deep/cmp_deeply>>.
#pod
#pod =cut

sub is_json {
  my ($json, $want, $comment) = @_;

  my $have = JSON::MaybeXS->new(ascii => 1)->decode($json)
    or die "Cannot decode JSON";

  local $Test::Builder::Level = $Test::Builder::Level + 1;
  Test::Deep::cmp_deeply($have, $want, $comment);
}

sub _build_ini_builder {
  my ($starting_core) = @_;
  $starting_core ||= {};

  sub {
    my (@arg) = @_;
    my $new_core = _HASH0($arg[0]) ? shift(@arg) : {};

    my $core_config = { %$starting_core, %$new_core };

    my $config = '';

    for my $key (sort keys %$core_config) {
      my @values = ref $core_config->{ $key }
                 ? @{ $core_config->{ $key } }
                 : $core_config->{ $key };

      $config .= "$key = $_\n" for grep {defined} @values;
    }

    $config .= "\n" if length $config;

    for my $line (@arg) {
      my @plugin = ref $line ? @$line : ($line, {});
      my $moniker = shift @plugin;
      my $name    = _HASH0($plugin[0]) ? undef : shift @plugin;
      my $payload = shift(@plugin) || {};

      Carp::confess("bogus plugin configuration: too many args") if @plugin;

      $config .= '[' . $moniker;
      $config .= ' / ' . $name if defined $name;
      $config .= "]\n";

      for my $key (sort keys %$payload) {
        my @values = ref $payload->{ $key }
                   ? @{ $payload->{ $key } }
                   : $payload->{ $key };

        $config .= "$key = $_\n" for grep {defined} @values;
      }

      $config .= "\n";
    }

    return $config;
  }
}

#pod =func dist_ini
#pod
#pod   my $ini_text = dist_ini(\%root_config, @plugins);
#pod
#pod This routine returns a string that could be used to populate a simple
#pod F<dist.ini> file.  The C<%root_config> gives data for the "root" section of the
#pod configuration.  To provide a line multiple times, provide an arrayref.  For
#pod example, the root section could read:
#pod
#pod   {
#pod     name   => 'Dist-Sample',
#pod     author => [
#pod       'J. Smith <jsmith@example.com>',
#pod       'Q. Smith <qsmith@example.com>',
#pod     ],
#pod   }
#pod
#pod The root section is optional.
#pod
#pod Plugins can be given in a few ways:
#pod
#pod =begin :list
#pod
#pod = C<"PluginMoniker">
#pod
#pod = C<[ "PluginMoniker" ]>
#pod
#pod These become C<[PluginMoniker]>
#pod
#pod = C<[ "PluginMoniker", "PluginName" ]>
#pod
#pod This becomes C<[PluginMoniker / PluginName]>
#pod
#pod = C<[ "PluginMoniker", { ... } ]>
#pod
#pod = C<[ "PluginMoniker", "PluginName", { ... } ]>
#pod
#pod These use the given hashref as the parameters inside the section, with the same
#pod semantics as the root section.
#pod
#pod =end :list
#pod
#pod =cut

sub _dist_ini {
  _build_ini_builder;
}

#pod =func simple_ini
#pod
#pod This behaves exactly like C<dist_ini>, but it merges any given root config into
#pod a starter config, which means that you can often skip any explicit root config.
#pod The starter config may change slightly over time, but is something like this:
#pod
#pod   {
#pod     name     => 'DZT-Sample',
#pod     abstract => 'Sample DZ Dist',
#pod     version  => '0.001',
#pod     author   => 'E. Xavier Ample <example@example.org>',
#pod     license  => 'Perl_5',
#pod     copyright_holder => 'E. Xavier Ample',
#pod   }
#pod
#pod =cut

sub _simple_ini {
  _build_ini_builder({
    name     => 'DZT-Sample',
    abstract => 'Sample DZ Dist',
    version  => '0.001',
    author   => 'E. Xavier Ample <example@example.org>',
    license  => 'Perl_5',
    copyright_holder => 'E. Xavier Ample',
  });
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

Test::DZil - tools for testing Dist::Zilla plugins

=head1 VERSION

version 5.043

=head1 DESCRIPTION

Test::DZil provides routines for writing tests for Dist::Zilla plugins.

=head1 FUNCTIONS

=head2 Builder

=head2 Minter

  my $tzil = Builder->from_config(...);

These return class names that subclass L<Dist::Zilla::Dist::Builder> or
L<Dist::Zilla::Dist::Minter>, respectively, with the L<Dist::Zilla::Tester>
behavior added.

=head2 is_filelist

  is_filelist( \@files_we_have, \@files_we_want, $desc );

This test assertion compares two arrayrefs of filenames, taking care of slash
normalization and sorting.  C<@files_we_have> may also contain objects that
do L<Dist::Zilla::Role::File>.

=head2 is_yaml

  is_yaml( $yaml_string, $want_struct, $comment );

This test assertion deserializes the given YAML string and does a
C<L<cmp_deeply|Test::Deep/cmp_deeply>>.

=head2 is_json

  is_json( $json_string, $want_struct, $comment );

This test assertion deserializes the given JSON string and does a
C<L<cmp_deeply|Test::Deep/cmp_deeply>>.

=head2 dist_ini

  my $ini_text = dist_ini(\%root_config, @plugins);

This routine returns a string that could be used to populate a simple
F<dist.ini> file.  The C<%root_config> gives data for the "root" section of the
configuration.  To provide a line multiple times, provide an arrayref.  For
example, the root section could read:

  {
    name   => 'Dist-Sample',
    author => [
      'J. Smith <jsmith@example.com>',
      'Q. Smith <qsmith@example.com>',
    ],
  }

The root section is optional.

Plugins can be given in a few ways:

=over 4

=item C<"PluginMoniker">

=item C<[ "PluginMoniker" ]>

These become C<[PluginMoniker]>

=item C<[ "PluginMoniker", "PluginName" ]>

This becomes C<[PluginMoniker / PluginName]>

=item C<[ "PluginMoniker", { ... } ]>

=item C<[ "PluginMoniker", "PluginName", { ... } ]>

These use the given hashref as the parameters inside the section, with the same
semantics as the root section.

=back

=head2 simple_ini

This behaves exactly like C<dist_ini>, but it merges any given root config into
a starter config, which means that you can often skip any explicit root config.
The starter config may change slightly over time, but is something like this:

  {
    name     => 'DZT-Sample',
    abstract => 'Sample DZ Dist',
    version  => '0.001',
    author   => 'E. Xavier Ample <example@example.org>',
    license  => 'Perl_5',
    copyright_holder => 'E. Xavier Ample',
  }

=head1 AUTHOR

Ricardo SIGNES <rjbs@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Ricardo SIGNES.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut