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
|
#!/usr/bin/perl -w
use strict;
use Test::More;
use vars '$loaded';
BEGIN { $loaded = eval { require PAR::Dist; 1 } };
BEGIN {
my $tests = 29;
if ($loaded) {
# skip these tests without YAML loader or without (A::Zip or zipo/unzip)
$PAR::Dist::DEBUG = 1;
my $tools = PAR::Dist::_check_tools();
$PAR::Dist::DEBUG = 0;
if (not defined $tools->{DumpFile}) {
plan skip_all => "Skip because no YAML loader/dumper could be found";
exit();
}
elsif (not defined $tools->{zip}) {
plan skip_all => "Skip because neither Archive::Zip nor zip/unzip could be found";
exit();
}
else {
plan tests => $tests;
ok(1);
}
}
else {
plan tests => $tests;
ok(0, "Could not load PAR::Dist: $@");
exit();
}
}
ok (eval { require PAR::Dist; 1 });
chdir('t') if -d 't';
my @dist = (
'data/dist1.par',
'data/dist2.par',
);
my @tmp = map {my $f = $_; $f =~ s/^data\///; $f} @dist;
require File::Copy;
for (0..$#dist) {
ok(-f $dist[$_]);
ok(File::Copy::copy($dist[$_], $tmp[$_]));
}
sub cleanup {
unlink($_) for @tmp;
}
$SIG{INT} = \&cleanup;
$SIG{TERM} = \&cleanup;
END { cleanup(); }
my %provides_expect = (
"Math::Symbolic::Custom::Transformation" => {
file => "lib/Math/Symbolic/Custom/Transformation.pm",
version => "2.01",
},
"Math::Symbolic::Custom::Transformation::Group" => {
file => "lib/Math/Symbolic/Custom/Transformation/Group.pm",
version => "1.25",
},
"Test::Kit" => {
file => "lib/Test/Kit.pm",
version => "0.02",
},
"Test::Kit::Features" => {
file => "lib/Test/Kit/Features.pm",
version => "0.02",
},
"Test::Kit::Result" => {
file => "lib/Test/Kit/Features.pm",
},
);
my %requires_expect = (
"Math::Symbolic" => '0.507',
"Math::Symbolic::Custom::Pattern" => '1.20',
"base" => '2.11',
"namespace::clean" => '0.08',
"Test::More" => '0',
);
my %build_requires_expect = (
"Test::More" => '0.1',
"Test::Differences" => undef,
);
my %recommends_expect = (
"Test::Pod" => '1.0',
"Test::Pod::Coverage" => '1.0',
);
PAR::Dist::merge_par(@tmp);
ok(1); # got to this point
my ($y_func) = PAR::Dist::_get_yaml_functions();
my $meta = PAR::Dist::get_meta($tmp[0]);
ok(defined($meta));
my $result = $y_func->{Load}->( $meta );
ok(defined $result);
$result = $result->[0] if ref($result) eq 'ARRAY';
my $provides = $result->{provides};
ok(ref($provides) eq 'HASH');
foreach my $module (keys %provides_expect) {
ok(ref($provides->{$module}) eq 'HASH');
my $modhash = $provides->{$module};
my $exphash = $provides_expect{$module};
ok($exphash->{file} eq $modhash->{file});
if (exists $exphash->{version}) {
ok($exphash->{version} eq $modhash->{version});
}
else {
ok(!exists($modhash->{version}));
}
}
is_deeply($result->{requires}, \%requires_expect, "requires merged as expected");
is_deeply($result->{build_requires}, \%build_requires_expect, "build_requires merged as expected");
is_deeply($result->{configure_requires}, undef, "configure_requires merged as expected");
is_deeply($result->{recommends}, \%recommends_expect, "recommends merged as expected");
__END__
|