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
|
#!perl
# Test the FileFinder::ByName and FileFinder::Filter plugins
use strict;
use warnings;
use Test::More 0.88; # done_testing
use Test::DZil qw(Builder simple_ini is_filelist);
use Dist::Zilla::File::InMemory;
my $tzil;
my @dist_files = map { Dist::Zilla::File::InMemory->new(
name => $_, content => '') } qw(
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
Template_strict.patch
bin/foo.pl
bin/.hidden/foo.pl
corpus/DZT/README
corpus/DZT/lib/DZT/Sample.pm
corpus/DZT/t/basic.t
corpus/README
corpus/archives/DZT-Sample-0.01.tar.gz
corpus/archives/DZT-Sample-0.02.tar.gz
corpus/archives/DZT-Sample-0.03.tar.gz
corpus/gitvercheck.git
lib/Dist/Zilla/Plugin/ArchiveRelease.pm
lib/Dist/Zilla/Plugin/FindFiles.pm
lib/Dist/Zilla/Plugin/GitVersionCheckCJM.pm
lib/Dist/Zilla/Plugin/Metadata.pm
lib/Dist/Zilla/Plugin/ModuleBuild/Custom.pm
lib/Dist/Zilla/Plugin/TemplateCJM.pm
lib/Dist/Zilla/Plugin/VersionFromModule.pm
lib/Dist/Zilla/Role/ModuleInfo.pm
t/00-compile.t
t/arcrel.t
t/gitvercheck.t
t/mb_custom.t
t/metadata.t
t/release-pod-coverage.t
t/release-pod-syntax.t
t/template.t
t/vermod.t
);
#---------------------------------------------------------------------
sub is_found {
my ($plugin, $want, $comment) = @_;
my $have = $tzil->plugin_named($plugin)->find_files;
#printf " %s\n", $_->name for @$have;
local $Test::Builder::Level = $Test::Builder::Level + 1;
is_filelist($have, $want, $comment || $plugin);
}
#---------------------------------------------------------------------
sub make_tzil {
$tzil = Builder->from_config(
{ dist_root => 'corpus/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(@_),
},
},
);
# Don't bother building anything, we just need a list of filenames:
@{ $tzil->files } = @dist_files;
}
#---------------------------------------------------------------------
make_tzil([ 'FileFinder::ByName' => {qw(dir corpus skip archives)}],
[ 'FileFinder::Filter' => {qw(finder FileFinder::ByName skip DZT)}]);
is_found('FileFinder::ByName' => [qw(
corpus/DZT/README
corpus/DZT/lib/DZT/Sample.pm
corpus/DZT/t/basic.t
corpus/README
corpus/gitvercheck.git
)], 'dir corpus skip archives');
is_found('FileFinder::Filter' => [qw(
corpus/README
corpus/gitvercheck.git
)], 'filter DZT');
#---------------------------------------------------------------------
make_tzil(
[ 'FileFinder::ByName' => InBin => {qw(dir bin)}],
[ 'FileFinder::ByName' => AllPerl => { file => [qw( *.pl *.pm)] }],
[ 'FileFinder::ByName' => Plugins => {qw( dir lib match \.pm$ skip /Role/)}],
[ 'FileFinder::ByName' => Synopsis => { file => '*.pl',
dir => [qw(bin lib)],
match => '\.pm$',
skip => '(?i)version' }],
[ 'FileFinder::Filter' => Everything =>
{ finder => [qw(InBin AllPerl Plugins Synopsis)] }],
[ 'FileFinder::Filter' => NoPluginM =>
{ finder => 'AllPerl', skip => 'Plugin/M' }],
);
is_found(InBin => [qw(
bin/foo.pl
bin/.hidden/foo.pl
)]);
is_found(AllPerl => [qw(
bin/foo.pl
bin/.hidden/foo.pl
corpus/DZT/lib/DZT/Sample.pm
lib/Dist/Zilla/Plugin/ArchiveRelease.pm
lib/Dist/Zilla/Plugin/FindFiles.pm
lib/Dist/Zilla/Plugin/GitVersionCheckCJM.pm
lib/Dist/Zilla/Plugin/Metadata.pm
lib/Dist/Zilla/Plugin/ModuleBuild/Custom.pm
lib/Dist/Zilla/Plugin/TemplateCJM.pm
lib/Dist/Zilla/Plugin/VersionFromModule.pm
lib/Dist/Zilla/Role/ModuleInfo.pm
)]);
is_found(Plugins => [qw(
lib/Dist/Zilla/Plugin/ArchiveRelease.pm
lib/Dist/Zilla/Plugin/FindFiles.pm
lib/Dist/Zilla/Plugin/GitVersionCheckCJM.pm
lib/Dist/Zilla/Plugin/Metadata.pm
lib/Dist/Zilla/Plugin/ModuleBuild/Custom.pm
lib/Dist/Zilla/Plugin/TemplateCJM.pm
lib/Dist/Zilla/Plugin/VersionFromModule.pm
)]);
is_found(Synopsis => [qw(
bin/foo.pl
bin/.hidden/foo.pl
lib/Dist/Zilla/Plugin/ArchiveRelease.pm
lib/Dist/Zilla/Plugin/FindFiles.pm
lib/Dist/Zilla/Plugin/Metadata.pm
lib/Dist/Zilla/Plugin/ModuleBuild/Custom.pm
lib/Dist/Zilla/Plugin/TemplateCJM.pm
lib/Dist/Zilla/Role/ModuleInfo.pm
)]);
is_found(Everything => [qw(
bin/foo.pl
bin/.hidden/foo.pl
corpus/DZT/lib/DZT/Sample.pm
lib/Dist/Zilla/Plugin/ArchiveRelease.pm
lib/Dist/Zilla/Plugin/FindFiles.pm
lib/Dist/Zilla/Plugin/GitVersionCheckCJM.pm
lib/Dist/Zilla/Plugin/Metadata.pm
lib/Dist/Zilla/Plugin/ModuleBuild/Custom.pm
lib/Dist/Zilla/Plugin/TemplateCJM.pm
lib/Dist/Zilla/Plugin/VersionFromModule.pm
lib/Dist/Zilla/Role/ModuleInfo.pm
)]);
is_found(NoPluginM => [qw(
bin/foo.pl
bin/.hidden/foo.pl
corpus/DZT/lib/DZT/Sample.pm
lib/Dist/Zilla/Plugin/ArchiveRelease.pm
lib/Dist/Zilla/Plugin/FindFiles.pm
lib/Dist/Zilla/Plugin/GitVersionCheckCJM.pm
lib/Dist/Zilla/Plugin/TemplateCJM.pm
lib/Dist/Zilla/Plugin/VersionFromModule.pm
lib/Dist/Zilla/Role/ModuleInfo.pm
)]);
#---------------------------------------------------------------------
make_tzil([ 'FileFinder::ByName' => 'Everything' ],
[ 'FileFinder::ByName' => 'EverythingButPerl' =>
{skip => [qw( \.t$ (?i)\.p[lm]$ )]} ]);
is_found(Everything => [ map { $_->name } @dist_files ]);
is_found(EverythingButPerl => [qw(
Changes
LICENSE
MANIFEST
META.json
META.yml
README
Template_strict.patch
corpus/DZT/README
corpus/README
corpus/archives/DZT-Sample-0.01.tar.gz
corpus/archives/DZT-Sample-0.02.tar.gz
corpus/archives/DZT-Sample-0.03.tar.gz
corpus/gitvercheck.git
)]);
done_testing;
|