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
|
#!perl
use strict;
use warnings;
use Test::More 0.88;
use lib 't/lib';
use Test::DZil;
use YAML::Tiny;
sub build_meta {
my $tzil = shift;
$tzil->build;
YAML::Tiny->new->read($tzil->tempdir->file('build/META.yml'))->[0];
}
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/AutoPrereqs' },
{ },
);
# check found prereqs
my $meta = build_meta($tzil);
my %wanted = (
# DZPA::Main should not be extracted
'DZPA::Base::Moose1' => 0,
'DZPA::Base::Moose2' => 0,
'DZPA::Base::base1' => 0,
'DZPA::Base::base2' => 0,
'DZPA::Base::base3' => 0,
'DZPA::Base::parent1' => 0,
'DZPA::Base::parent2' => 0,
'DZPA::Base::parent3' => 0,
'DZPA::IgnoreAPI' => 0,
'DZPA::IndentedRequire' => '3.45',
'DZPA::IndentedUse' => '0.13',
'DZPA::MinVerComment' => '0.50',
'DZPA::ModRequire' => 0,
'DZPA::NotInDist' => 0,
'DZPA::Role' => 0,
'DZPA::ScriptUse' => 0,
'base' => 0,
'parent' => 0,
'perl' => 5.008,
'strict' => 0,
'warnings' => 0,
);
is_deeply(
$meta->{prereqs}{runtime}{requires},
\%wanted,
'all requires found, but no more',
);
# Try again with configure_finder:
$tzil = Builder->from_config(
{ dist_root => 'corpus/dist/AutoPrereqs' },
{
add_files => {
'source/dist.ini' => simple_ini(
qw(GatherDir ExecDir),
[ AutoPrereqs => { skip => '^DZPA::Skip',
configure_finder => ':IncModules' } ],
[ MetaYAML => { version => 2 } ],
),
'source/inc/DZPA.pm' => "use DZPA::NotInDist;\n use DZPA::Configure;\n",
},
},
);
# check found prereqs
$meta = build_meta($tzil);
is_deeply(
$meta->{prereqs}{runtime}{requires},
\%wanted,
'configure_finder did not change requires',
);
my %want_configure = (
'DZPA::Configure' => 0,
'DZPA::NotInDist' => 0,
);
is_deeply(
$meta->{prereqs}{configure}{requires},
\%want_configure,
'configure_requires is correct',
);
# Try again with a customized scanner list:
$tzil = Builder->from_config(
{ dist_root => 'corpus/dist/AutoPrereqs' },
{
add_files => {
'source/dist.ini' => simple_ini(
qw(GatherDir ExecDir),
[ AutoPrereqs => { scanner => 'Perl5', extra_scanner => 'Aliased' } ],
[ MetaYAML => { version => 2 } ],
),
'source/lib/DZPA/Aliased.pm' => "use aliased 'Long::Class::Name';\n",
},
},
);
# check found prereqs
$meta = build_meta($tzil);
# Moose-style prereqs should not be recognized this time:
delete $wanted{'DZPA::Base::Moose1'};
delete $wanted{'DZPA::Base::Moose2'};
delete $wanted{'DZPA::Role'};
$wanted{'DZPA::Skip::Blah'} = 0; # not skipping anymore
$wanted{'DZPA::Skip::Foo'} = 0;
$wanted{'aliased'} = 0;
$wanted{'Long::Class::Name'} = 0;
is_deeply(
$meta->{prereqs}{runtime}{requires},
\%wanted,
'custom scanner list',
);
done_testing;
|