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
|
use strict;
use warnings;
use Test::More 0.96;
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';
use Test::Deep;
use Test::DZil;
use Path::Tiny;
use Test::Fatal;
use File::pushd 'pushd';
my $tzil = Builder->from_config(
{ dist_root => 'does-not-exist' },
{
add_files => {
path(qw(source dist.ini)) => simple_ini(
'GatherDir',
[ 'MakeMaker::Awesome' => { eumm_version => '6.01' } ],
[ Prereqs => { 'Foo::Bar' => '1.20', perl => '5.006' } ],
[ Prereqs => BuildRequires => { 'Builder::Bob' => '9.901' } ],
[ Prereqs => TestRequires => { 'Test::Deet' => '7',
perl => '5.008' } ],
),
path(qw(source lib DZT Sample.pm)) => 'package DZT::Sample; 1',
path(qw(source t basic.t)) => 'warn "here is a test";',
path(qw(source t more.t)) => 'warn "here is another test";',
},
},
);
$tzil->chrome->logger->set_debug(1);
$tzil->build;
my $makemaker = $tzil->plugin_named('MakeMaker::Awesome');
my %want = (
DISTNAME => 'DZT-Sample',
NAME => 'DZT::Sample',
ABSTRACT => 'Sample DZ Dist',
VERSION => '0.001',
AUTHOR => 'E. Xavier Ample <example@example.org>',
LICENSE => 'perl',
MIN_PERL_VERSION => '5.008',
PREREQ_PM => {
'Foo::Bar' => '1.20'
},
BUILD_REQUIRES => {
'Builder::Bob' => '9.901',
},
TEST_REQUIRES => {
'Test::Deet' => '7',
},
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '6.01'
},
# EXE_FILES omitted
test => { TESTS => 't/*.t' },
);
cmp_deeply(
{ $makemaker->WriteMakefile_args },
\%want,
'correct makemaker args generated',
);
my $content = $tzil->slurp_file('build/Makefile.PL');
unlike($content, qr/[^\S\n]\n/, 'no trailing whitespace in generated file');
like(
$content,
qr/\A# This Makefile\.PL for DZT-Sample was generated by
# Dist::Zilla::Plugin::MakeMaker::Awesome $Dist::Zilla::Plugin::MakeMaker::Awesome::VERSION\.
# Don't edit it but the dist\.ini and plugins used to construct it\.
use strict;
use warnings;
use 5\.008;
use ExtUtils::MakeMaker 6\.01;
my \%WriteMakefileArgs = \(/,
'Makefile.PL header looks correct',
);
my $WriteMakefileArgs = $makemaker->_dump_as(\%want, '*WriteMakefileArgs');
like(
$content,
qr/\Q$WriteMakefileArgs\E/,
'arguments are dumped to Makefile.PL',
);
cmp_deeply(
$tzil->distmeta,
superhashof({
prereqs => {
configure => {
requires => {
'ExtUtils::MakeMaker' => '6.01',
},
},
build => { requires => { 'Builder::Bob' => '9.901' } },
runtime => {
requires => {
'Foo::Bar' => '1.20',
'perl' => ignore, # probably raised to 5.008 by [MakeMaker]
},
},
test => {
requires => {
'Test::Deet' => '7',
'perl' => '5.008',
},
},
},
dynamic_config => 0,
}),
'plugin metadata, including dumped configs',
) or diag 'got distmeta: ', explain $tzil->distmeta;
subtest 'run the generated Makefile.PL' => sub
{
my $wd = pushd path($tzil->tempdir)->child('build');
is(
exception { $makemaker->build },
undef,
'Makefile.PL can be run successfully',
);
};
diag 'got log messages: ', explain $tzil->log_messages
if not Test::Builder->new->is_passing;
done_testing;
|