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
|
#!perl -w
# Stolen from ChrisDolan on use.perl.org
# http://use.perl.org/comments.pl?sid=29264&cid=44309
use warnings;
use strict;
use File::Find;
use Test::More;
eval {
#require Test::MinimumVersion::Fast;
require Parse::CPAN::Meta;
Parse::CPAN::Meta->import();
require CPAN::Meta::Validator;
CPAN::Meta::Validator->VERSION(2.15);
};
if ($@) {
plan skip_all => "CPAN::Meta::Validator version 2.15 required for testing META files";
}
else {
plan tests => 4;
}
use lib '.';
our %module;
require 'Makefile.PL';
# Loaded from Makefile.PL
%module = get_module_info();
my $module = $module{NAME};
(my $file = $module) =~ s!::!/!g;
require "$file.pm";
my $version = sprintf '%0.2f', $module->VERSION;
for my $meta_file ('META.yml', 'META.json') {
my $meta = Parse::CPAN::Meta->load_file($meta_file);
my $cmv = CPAN::Meta::Validator->new( $meta );
if(! ok $cmv->is_valid, "$meta_file is valid" ) {
diag $_ for $cmv->errors;
};
# Also check that the declared version matches the version in META.*
is $meta->{version}, $version, "$meta_file version matches module version ($version)";
};
|