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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
|
use strict;
use warnings;
use Test::More 0.88;
use lib 't/lib';
use Test::DZil;
sub test_this {
my ($plugins, $add_files, $assertion) = @_;
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
'GatherDir',
@$plugins,
[ Prereqs => { 'Foo::Bar' => '1.20' } ],
[ Prereqs => BuildRequires => { 'Builder::Bob' => '9.901' } ],
[ Prereqs => TestRequires => { 'Test::Deet' => '7' } ],
),
%$add_files,
},
},
);
$tzil->build;
$assertion->($tzil);
}
# ShareDir
test_this(
[ qw(MakeMaker) ],
{ },
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
unlike($makefile, qr/install_share dist => .share./, "not going to install share");
},
);
test_this(
[ qw(MakeMaker ShareDir) ],
{ },
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
unlike($makefile, qr/install_share dist => .share./, "not going to install share");
},
);
test_this(
[ qw(MakeMaker) ],
{ 'source/share/stupid-share.txt' => "This is a sharedir file.\n" },
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
unlike(
$makefile,
qr/install_share dist => .share./,
"files in ./share, but no ShareDir, so we will not install_share"
);
},
);
test_this(
[ qw(MakeMaker ShareDir) ],
{ 'source/share/stupid-share.txt' => "This is a sharedir file.\n" },
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
like(
$makefile,
qr/install_share dist => .share./,
"files in ./share, ShareDir, so we will install_share"
);
},
);
test_this(
[ qw(ModuleBuild ShareDir) ],
{ 'source/share/stupid-share.txt' => "This is a sharedir file.\n" },
sub {
my $tzil = shift;
my $modulebuild = $tzil->plugin_named('ModuleBuild');
is(
$modulebuild->__module_build_args->{share_dir}{dist},
'share',
"files in ./share, ShareDir, so we have a Build.PL share_dir"
);
},
);
# ModuleShareDirs
test_this(
[ qw(MakeMaker) ],
{ },
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
unlike($makefile, qr/install_share module => .DZT::Simple., .share./,
"not going to install module-based share"
);
},
);
test_this(
[ qw(MakeMaker ModuleShareDirs) ],
{ },
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
unlike($makefile, qr/install_share module => .DZT::Simple., .share./,
"not going to install module-based share"
);
},
);
test_this(
[ qw(MakeMaker ModuleShareDirs) ],
{ 'source/share/stupid-share.txt' => "This is a sharedir file.\n" },
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
unlike($makefile, qr/install_share module => .DZT::Simple., .share./,
"files in ./share, empty ModuleShareDirs, so we will not install_share"
);
},
);
test_this(
[
'MakeMaker',
['ModuleShareDirs' => { 'DZT::Simple' => 'share' } ],
],
{ 'source/share/stupid-share.txt' => "This is a sharedir file.\n" },
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
like($makefile, qr/install_share module => .DZT::Simple., .share./,
"files in ./share, ModuleShareDirs given, so we will install_share"
);
},
);
test_this(
[
'MakeMaker',
['ModuleShareDirs' => { 'DZT::Simple' => 'share', 'DZT::Other' => 'other' } ],
],
{
'source/share/stupid-share.txt' => "This is a sharedir file.\n",
'source/other/stupid-other.txt' => "This is another sharedir file.\n",
},
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
like($makefile, qr/install_share module => .DZT::Simple., .share./,
"files in ./share, ModuleShareDirs given, so we will install_share"
);
like($makefile, qr/install_share module => .DZT::Other., .other./,
"files in ./other, another ModuleShareDirs given, so we will install_share"
);
},
);
test_this(
[
'MakeMaker', 'ShareDir',
['ModuleShareDirs' => { 'DZT::Simple' => 'simple', 'DZT::Other' => 'other' } ],
],
{
'source/share/stupid-share.txt' => "This is a sharedir file.\n",
'source/other/stupid-other.txt' => "This is another sharedir file.\n",
'source/simple/stupid-other.txt' => "This is another simple sharedir file.\n",
},
sub {
my $tzil = shift;
my $makefile = $tzil->slurp_file('build/Makefile.PL');
like($makefile, qr/install_share dist => .share./,
"ShareDir and ModuleShareDirs: dist share"
);
like($makefile, qr/install_share module => .DZT::Simple., .simple./,
"ShareDir and ModuleShareDirs: first module share",
);
like($makefile, qr/install_share module => .DZT::Other., .other./,
"ShareDir and ModuleShareDirs: other module share"
);
},
);
test_this(
[
'ModuleBuild',
['ModuleShareDirs' => { 'DZT::Simple' => 'share' } ],
],
{ 'source/share/stupid-share.txt' => "This is a sharedir file.\n" },
sub {
my $tzil = shift;
my $modulebuild = $tzil->plugin_named('ModuleBuild');
is(
$modulebuild->__module_build_args->{share_dir}{module}{'DZT::Simple'},
'share',
"files in ./share, ModuleShareDirs given, so we have a Build.PL share_dir"
);
},
);
test_this(
[
'ModuleBuild', 'ShareDir',
['ModuleShareDirs' => { 'DZT::Simple' => 'simple', 'DZT::Other' => 'other' } ],
],
{
'source/share/stupid-share.txt' => "This is a sharedir file.\n",
'source/other/stupid-other.txt' => "This is another sharedir file.\n",
'source/simple/stupid-other.txt' => "This is another simple sharedir file.\n",
},
sub {
my $tzil = shift;
my $modulebuild = $tzil->plugin_named('ModuleBuild');
is_deeply(
$modulebuild->__module_build_args->{share_dir},
{
dist => 'share',
module => {
'DZT::Simple' => 'simple',
'DZT::Other' => 'other',
},
},
"ModuleBuild with ShareDir and ModuleShareDirs"
);
},
);
# ExecDir
test_this(
[ qw(MakeMaker) ],
{ },
sub {
my $tzil = shift;
my $makemaker = $tzil->plugin_named('MakeMaker');
is_deeply(
$makemaker->__write_makefile_args->{EXE_FILES},
[],
"not going to install execs",
);
},
);
test_this(
[ qw(MakeMaker) ],
{ 'source/bin/be-stiff' => "#!perl\nuse D::Evo;\nuse B::Stuff;\n" },
sub {
my $tzil = shift;
my $makemaker = $tzil->plugin_named('MakeMaker');
is_deeply(
$makemaker->__write_makefile_args->{EXE_FILES},
[],
"files in ./bin, but no ExecDir, not going to install execs",
);
},
);
test_this(
[ qw(MakeMaker ExecDir) ],
{ 'source/bin/be-stiff' => "#!perl\nuse D::Evo;\nuse B::Stuff;\n" },
sub {
my $tzil = shift;
my $makemaker = $tzil->plugin_named('MakeMaker');
is_deeply(
$makemaker->__write_makefile_args->{EXE_FILES},
[ 'bin/be-stiff' ],
"files in ./bin, ExecDir, going to install execs",
);
},
);
test_this(
[ qw(ModuleBuild ExecDir) ],
{ 'source/bin/be-stiff' => "#!perl\nuse D::Evo;\nuse B::Stuff;\n" },
sub {
my $tzil = shift;
my $modulebuild = $tzil->plugin_named('ModuleBuild');
is_deeply(
$modulebuild->__module_build_args->{script_files},
[ 'bin/be-stiff' ],
"files in ./bin, ExecDir, going to install execs in Build.PL",
);
},
);
done_testing;
|