Skip to content

Commit c6f1b8a

Browse files
committed
Pass tests even in absence of CPAN::Meta
1 parent 4ab1d4a commit c6f1b8a

File tree

9 files changed

+59
-18
lines changed

9 files changed

+59
-18
lines changed

lib/Module/Build/Base.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,7 +1900,7 @@ sub create_mymeta {
19001900
}
19011901

19021902
# Try loading META.json or META.yml
1903-
if ( $self->try_require("CPAN::Meta", "2.110420") ) {
1903+
if ( $self->try_require("CPAN::Meta", "2.142060") ) {
19041904
for my $file ( @metafiles ) {
19051905
next unless -f $file;
19061906
$meta_obj = eval { CPAN::Meta->load_file($file, { lazy_validation => 0 }) };
@@ -4546,7 +4546,7 @@ sub _write_meta_files {
45464546
sub _get_meta_object {
45474547
my $self = shift;
45484548
my %args = @_;
4549-
return unless $self->try_require("CPAN::Meta", "2.110420");
4549+
return unless $self->try_require("CPAN::Meta", "2.142060");
45504550

45514551
my $meta;
45524552
eval {

t/extend.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ print "Hello, World!\n";
178178
is $mb->bar, 'yow';
179179
}
180180

181-
{
181+
SKIP: {
182+
skip 'Need CPAN::Meta 2.142060 for Meta support', 4 if not eval { require CPAN::Meta; CPAN::Meta->VERSION(2.142060) };
182183
# Test the meta_add and meta_merge stuff
183184
ok my $mb = Module::Build->new(
184185
module_name => $dist->name,

t/metadata.t

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
use strict;
44
use lib 't/lib';
5-
use MBTest tests => 14;
5+
use MBTest;
6+
7+
if (eval { require CPAN::Meta; CPAN::Meta->VERSION(2.142060) }) {
8+
plan(tests => 14);
9+
}
10+
else {
11+
plan(skip_all => 'No or old CPAN::Meta');
12+
}
613

714
blib_load('Module::Build');
815
blib_load('Module::Build::ConfigData');

t/metadata2.t

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
use strict;
44
use lib 't/lib';
5-
use MBTest tests => 18;
5+
use MBTest;
6+
7+
if (eval { require CPAN::Meta; CPAN::Meta->VERSION(2.142060) }) {
8+
plan(tests => 18);
9+
}
10+
else {
11+
plan(skip_all => 'No or old CPAN::Meta');
12+
}
613

714
blib_load('Module::Build');
815
blib_load('Module::Build::ConfigData');

t/mymeta.t

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
use strict;
44
use lib 't/lib';
55
use MBTest;
6-
use CPAN::Meta 2.110420;
7-
use CPAN::Meta::YAML;
8-
use Parse::CPAN::Meta 1.4401;
9-
plan tests => 41;
6+
7+
if (eval { require CPAN::Meta; CPAN::Meta->VERSION(2.142060) }) {
8+
plan(tests => 41);
9+
require CPAN::Meta::YAML;
10+
require Parse::CPAN::Meta;
11+
}
12+
else {
13+
plan(skip_all => 'No or old CPAN::Meta');
14+
}
1015

1116
blib_load('Module::Build');
1217

t/properties/license.t

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ use lib 't/lib';
33
use MBTest;
44
use DistGen;
55

6-
plan 'no_plan';
6+
if (eval { require CPAN::Meta; CPAN::Meta->VERSION(2.142060) }) {
7+
plan('no_plan');
8+
require CPAN::Meta::YAML;
9+
require Parse::CPAN::Meta;
10+
}
11+
else {
12+
plan(skip_all => 'No or old CPAN::Meta');
13+
}
714

815
# Ensure any Module::Build modules are loaded from correct directory
916
blib_load('Module::Build');

t/runthrough.t

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,14 @@ ok grep {$_ eq 'save_out' } $mb->cleanup;
124124
# else it could get into the tarball
125125
ok ! -e File::Spec->catdir('Simple-0.01', 'blib');
126126

127-
# Make sure all of the above was done by the new version of Module::Build
128-
open(my $fh, '<', File::Spec->catfile($dist->dirname, 'META.yml'));
129-
my $contents = do {local $/; <$fh>};
130-
$contents =~ /Module::Build version ([0-9_.]+)/m;
131-
cmp_ok $1, '==', $mb->VERSION, "Check version used to create META.yml: $1 == " . $mb->VERSION;
127+
SKIP: {
128+
skip 'CPAN::Meta 2.142060+ not installed', 1 if not eval { require CPAN::Meta; CPAN::Meta->VERSION(2.142060) };
129+
# Make sure all of the above was done by the new version of Module::Build
130+
open(my $fh, '<', File::Spec->catfile($dist->dirname, 'META.yml'));
131+
my $contents = do {local $/; <$fh>};
132+
$contents =~ /Module::Build version ([0-9_.]+)/m;
133+
cmp_ok $1, '==', $mb->VERSION, "Check version used to create META.yml: $1 == " . $mb->VERSION;
134+
}
132135

133136
SKIP: {
134137
skip( "Archive::Tar 1.08+ not installed", 1 )

t/script_dist.t

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ my $result;
7373
stdout_stderr_of( sub { $result = $mb->dispatch('distmeta') } );
7474
ok $result;
7575

76-
my $yml = CPAN::Meta::YAML->read_string(slurp('META.yml'))->[0];
77-
is_deeply($yml->{provides}, \%meta_provides);
76+
if (eval { require CPAN::Meta; CPAN::Meta->VERSION(2.142060); }) {
77+
my $yml = CPAN::Meta::YAML->read_string(slurp('META.yml'))->[0];
78+
is_deeply($yml->{provides}, \%meta_provides);
79+
}
7880

7981
$dist->chdir_original if $dist->did_chdir;

t/test_reqs.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ use MBTest;
66
use CPAN::Meta 2.110420;
77
use CPAN::Meta::YAML;
88
use Parse::CPAN::Meta 1.4401;
9-
plan tests => 4;
9+
10+
if (eval { require CPAN::Meta; CPAN::Meta->VERSION(2.142060) }) {
11+
plan(tests => 4);
12+
require CPAN::Meta::YAML;
13+
require Parse::CPAN::Meta;
14+
}
15+
else {
16+
plan(skip_all => 'No or old CPAN::Meta');
17+
}
18+
1019

1120
blib_load('Module::Build');
1221

0 commit comments

Comments
 (0)