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
|
use strict;
use warnings;
use Test::More 0.88;
use Test::DZil;
use Test::Fatal;
use Path::Tiny;
{
my $tzil = Builder->from_config(
{ dist_root => 'does-not-exist' },
{
add_files => {
path(qw(source dist.ini)) => simple_ini(
[ 'GatherFile' => {
filename => 'lib/DZT/Sample.pm',
}],
),
path(qw(source lib DZT Sample.pm)) => "package DZT::Sample;\n1",
},
},
);
$tzil->chrome->logger->set_debug(1);
is(
exception { $tzil->build },
undef,
'build proceeds normally',
);
my $build_dir = path($tzil->tempdir)->child('build');
ok(-e $build_dir->child(qw(lib DZT Sample.pm)), 'file was gathered correctly');
diag 'got log messages: ', explain $tzil->log_messages
if not Test::Builder->new->is_passing;
}
{
my $tzil = Builder->from_config(
{ dist_root => 'does-not-exist' },
{
add_files => {
path(qw(source dist.ini)) => simple_ini(
[ 'GatherFile' => {
filename => 'lib/DZT/Sample.pm',
}],
),
# no source/lib/DZT/Sample.pm
},
},
);
$tzil->chrome->logger->set_debug(1);
like(
exception { $tzil->build },
qr{lib/DZT/Sample.pm does not exist!},
'missing file is detected',
);
diag 'got log messages: ', explain $tzil->log_messages
if not Test::Builder->new->is_passing;
}
{
my $tzil = Builder->from_config(
{ dist_root => 'does-not-exist' },
{
add_files => {
path(qw(source dist.ini)) => simple_ini(
[ 'GatherFile' => {
filename => 'subdir/index.html',
root => 'corpus/extra',
}],
),
},
also_copy => { 'corpus/extra' => 'source/corpus/extra' },
},
);
$tzil->chrome->logger->set_debug(1);
is(
exception { $tzil->build },
undef,
'build proceeds normally',
);
my $build_dir = path($tzil->tempdir)->child('build');
ok(-e $build_dir->child(qw(subdir index.html)), 'file was gathered correctly from a different root');
diag 'got log messages: ', explain $tzil->log_messages
if not Test::Builder->new->is_passing;
}
{
my $tzil = Builder->from_config(
{ dist_root => 'does-not-exist' },
{
add_files => {
path(qw(source dist.ini)) => simple_ini(
[ 'GatherFile' => {
filename => 'lib/DZT/Sample.pm',
prefix => 'stuff',
}],
),
path(qw(source lib DZT Sample.pm)) => "package DZT::Sample;\n1",
},
},
);
$tzil->chrome->logger->set_debug(1);
is(
exception { $tzil->build },
undef,
'build proceeds normally',
);
my $build_dir = path($tzil->tempdir)->child('build');
ok(-e $build_dir->child(qw(stuff lib DZT Sample.pm)), 'file was gathered correctly into the prefix dir');
diag 'got log messages: ', explain $tzil->log_messages
if not Test::Builder->new->is_passing;
}
done_testing;
|