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
|
use strict;
use warnings;
use Test::More 0.88;
use Test::Deep;
use utf8;
use Test::DZil;
use JSON::MaybeXS;
use YAML::Tiny;
{
# 2.0
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
'GatherDir',
[ MetaResources => HomePage => {homepage => 'http://bana.na/phone'}],
[ MetaResources => License => {license => 'http://b.sd/license' }],
[ Prereqs => { 'Foo::Bar' => '1.234' } ],
[ Prereqs => RuntimeRecommends => { 'Foo::Bar::Opt' => '1.234' } ],
[ Prereqs => BuildRequires => { 'Test::Foo' => '2.34' } ],
[ Prereqs => ConfigureRequires => { 'Build::Foo' => '0.12' } ],
'MetaJSON',
'MetaConfig',
),
},
},
);
$tzil->build;
my @files = map {; $_->name } @{ $tzil->files };
my %meta;
my $json = $tzil->slurp_file('build/META.json');
$meta{json} = JSON::MaybeXS->new(utf8 => 0)->decode($json);
$meta{json}{x_serialization_backend} = 'ignore';
$meta{original} = $tzil->distmeta;
$meta{original}{x_serialization_backend} = 'ignore';
cmp_deeply(
$meta{json},
{
%{ $meta{original} },
generated_by => $meta{original}{generated_by} . ', CPAN::Meta::Converter version ' . CPAN::Meta::Converter->VERSION,
},
"META.json data is identical to original distmeta",
);
for my $type (qw(json original)) {
my $meta = $meta{$type};
my %want = (
name => 'DZT-Sample',
abstract => 'Sample DZ Dist',
author => [ 'E. Xavier Ample <example@example.org>' ],
prereqs => {
runtime => {
requires => { 'Foo::Bar' => '1.234' },
recommends => { 'Foo::Bar::Opt' => '1.234' },
},
build => { requires => { 'Test::Foo' => '2.34' } },
configure => { requires => { 'Build::Foo' => '0.12' } },
},
license => [ 'perl_5' ],
resources => {
homepage => 'http://bana.na/phone',
license => [ 'http://b.sd/license' ],
},
version => '0.001',
);
cmp_deeply(
$meta,
superhashof(\%want),
"2.0 $type data",
);
}
}
{
# 1.4
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZT' },
{
add_files => {
'source/dist.ini' => simple_ini(
'GatherDir',
[ MetaResources => HomePage => {homepage => 'http://bana.na/phone'}],
[ MetaResources => License => {license => 'http://b.sd/license' }],
[ Prereqs => { 'Foo::Bar' => '1.234' } ],
[ Prereqs => RuntimeRecommends => { 'Foo::Bar::Opt' => '1.234' } ],
[ Prereqs => BuildRequires => { 'Test::Foo' => '2.34' } ],
[ Prereqs => ConfigureRequires => { 'Build::Foo' => '0.12' } ],
'MetaYAML',
'MetaConfig',
),
},
},
);
$tzil->build;
my @files = map {; $_->name } @{ $tzil->files };
my %meta;
my $yaml = $tzil->slurp_file('build/META.yml');
$meta{yaml} = YAML::Tiny->new->read_string($yaml)->[0];
$meta{yaml}{x_serialization_backend} = 'ignore';
#cmp_deeply($meta{json}, $meta{yaml}, "META.json data is identical to META.yml");
for my $type (qw(yaml)) {
my $meta = $meta{$type};
my %want = (
name => 'DZT-Sample',
abstract => 'Sample DZ Dist',
author => [ 'E. Xavier Ample <example@example.org>' ],
configure_requires => { 'Build::Foo' => '0.12' },
build_requires => { 'Test::Foo' => '2.34' },
requires => { 'Foo::Bar' => '1.234' },
recommends => { 'Foo::Bar::Opt' => '1.234' },
license => 'perl',
resources => {
homepage => 'http://bana.na/phone',
license => 'http://b.sd/license',
},
version => '0.001',
);
cmp_deeply(
$meta,
superhashof(\%want),
"1.4 $type data",
);
}
}
{ # non-ASCII
my $tzil = Builder->from_config(
{ dist_root => 'corpus/dist/DZ-NonAscii' },
);
$tzil->build;
my @files = map {; $_->name } @{ $tzil->files };
my %meta;
my $json = $tzil->slurp_file('build/META.json');
$meta{json} = JSON::MaybeXS->new(utf8 => 0)->decode($json);
$meta{json}{x_serialization_backend} = 'ignore';
my $yaml = $tzil->slurp_file('build/META.yml');
$meta{yaml} = YAML::Tiny->new->read_string($yaml)->[0];
$meta{yaml}{x_serialization_backend} = 'ignore';
for my $type (qw(json yaml)) {
cmp_deeply(
$meta{$type}{author},
[
'Olivier Mengué <dolmen@example.org>',
'김도형 <keedi@example.com>'
],
"authors ($type) are set as expected, decode properly",
);
}
}
done_testing;
|