File: 01-basic.t

package info (click to toggle)
libdist-zilla-plugin-installguide-perl 1.200013-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 312 kB
  • sloc: perl: 312; makefile: 2
file content (67 lines) | stat: -rw-r--r-- 1,773 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;

use Test::More;
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';
use Test::DZil;
use Test::Fatal;
use Path::Tiny;

my $gathered_files;
{
    package inc::MyGatherer;
    use Moose;
    with 'Dist::Zilla::Role::FileGatherer';

    sub gather_files {
        my $self = shift;
        $gathered_files = $self->zilla->files;
    }
}

my $tzil = Builder->from_config(
    { dist_root => 't/does-not-exist' },
    {
        add_files => {
            path(qw(source dist.ini)) => simple_ini(
                [ GatherDir => ],
                [ MakeMaker => ],
                [ InstallGuide => ],
                [ '=inc::MyGatherer' ],
            ),
            path(qw(source lib Foo Bar.pm)) => "package Foo::Bar;\n1;\n",
        },
    },
);

$tzil->chrome->logger->set_debug(1);
is(
    exception { $tzil->build },
    undef,
    'build proceeds normally',
);

my $build_dir = path($tzil->tempdir)->child('build');
my $file = $build_dir->child('INSTALL');
ok(-e $file, 'INSTALL created');

my $content = $file->slurp_utf8;
unlike($content, qr/[^\S\n]\n/m, 'no trailing whitespace in generated file');

like($content, qr/Makefile.PL/m, 'INSTALL mentions Makefile.PL');
unlike($content, qr/Build.PL/m, 'INSTALL does not mention Build.PL');

like($content, qr{https://www.cpan.org/modules/INSTALL.html}m, 'INSTALL mentions CPAN reference');

unlike($content, qr/DZT::Sample/, 'INSTALL does not mention nonexistent module DZT::Sample');
like($content, qr/cpanm Foo::Bar/, 'INSTALL does mention the main module Foo::Bar');

ok(
    scalar(grep { $_->name eq 'INSTALL' } @$gathered_files),
    'file was created at FileGathering time',
);

diag 'got log messages: ', explain $tzil->log_messages
    if not Test::Builder->new->is_passing;

done_testing;