File: file-addedby.t

package info (click to toggle)
libdist-zilla-perl 6.033-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,928 kB
  • sloc: perl: 7,282; makefile: 4; sh: 1
file content (75 lines) | stat: -rw-r--r-- 2,196 bytes parent folder | download | duplicates (6)
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
use strict;
use warnings;

use Test::More;
use Test::DZil;
use Test::Deep;
use Test::Fatal;
use Path::Tiny;
use List::Util 'first';

my $tzil = Builder->from_config(
  { dist_root => 't/does_not_exist' },
  {
    add_files => {
      path(qw(source dist.ini)) => simple_ini(
        'GatherDir',       # a file gatherer (adds OnDisk file)
        'PodSyntaxTests',  # a file gatherer (adds InMemory file)
        'Manifest',        # a file gatherer (adds FromCode file)

        # a file munger that changes content
        [ PkgVersion => { finder => ':AllFiles' } ],

        'ExtraTests',      # a file munger that changes filename
      ),
      path(qw(source lib DZT Sample.pm)) => "package DZT::Sample;\n\n1",
    },
  },
);

$tzil->chrome->logger->set_debug(1);
is(
  exception { $tzil->build },
  undef,
  'build proceeds normally',
) or diag 'saw log messages: ', explain $tzil->log_messages;

my $module = first { $_->name eq path(qw(lib DZT Sample.pm)) }
             @{ $tzil->files };

cmp_deeply(
  $module,
  methods(
    added_by => all(
      re(qr/\bencoded_content added by GatherDir \(Dist::Zilla::Plugin::GatherDir line \d+\)(;|$)/),
      re(qr/\bcontent set by PkgVersion \(Dist::Zilla::Plugin::PkgVersion line \d+\)(;|$)/),
    ),
  ),
  'OnDisk file added by GatherDir, set by PkgVersion has correct properties',
);

my $test = first { $_->name eq path(qw(t author-pod-syntax.t)) }
           @{ $tzil->files };

cmp_deeply(
  $test,
  methods(
    added_by => all(
      re(qr/^content added by PodSyntaxTests \(Dist::Zilla::Plugin::InlineFiles line \d+\)(;|$)/),
      re(qr/\bcontent set by ExtraTests \(Dist::Zilla::Plugin::ExtraTests line \d+\)(;|$)/),
      re(qr/\bfilename set by ExtraTests \(Dist::Zilla::Plugin::ExtraTests line \d+\)(;|$)/),
    ),
  ),
  'InMemory file altered by all of PodSyntaxTests, PkgVersion and ExtraTests has correct properties',
);

my $manifest = first { $_->name eq path('MANIFEST') } @{ $tzil->files };
cmp_deeply(
  $manifest,
  methods(
    added_by => re(qr/^bytes from coderef added by Manifest \(Dist::Zilla::Plugin::Manifest line \d+\)$/),
  ),
  'FromCode file added by Manifest has correct properties',
);

done_testing;