Skip to content
Browse files

Fix bugs in conversion to YAML::Tiny

  • Loading branch information...
1 parent 0e21de3 commit e0939c409c54b97880a3b455c1a88135d5813700 @xdg xdg committed
Showing with 12 additions and 8 deletions.
  1. +1 −1 lib/Module/Build/Base.pm
  2. +11 −7 t/mymeta.t
View
2 lib/Module/Build/Base.pm
@@ -4473,7 +4473,7 @@ sub read_metafile {
$self->_mb_feature('YAML_support') or return;
my $string = $self->_slurp($metafile, $] < 5.8 ? "" : ":utf8");
- my $meta = $YAML::Tiny->read_string($string)
+ my $meta = YAML::Tiny->read_string($string)
or $self->log_warn( "Error parsing '$metafile': " . YAML::Tiny->errstr . "\n");
return $meta->[0] || {};
View
18 t/mymeta.t
@@ -3,10 +3,14 @@
use strict;
use lib 't/lib';
use MBTest;
-plan tests => 25;
+if ( eval "require YAML::Tiny; 1" ) {
+ plan tests => 25;
+}
+else {
+ plan skip_all => "No YAML::Tiny";
+}
blib_load('Module::Build');
-blib_load('Module::Build::YAML');
my $tmp = MBTest->tmpdir;
@@ -56,8 +60,8 @@ $dist->chdir_in;
"Re-ran Build.PL and regenerated MYMETA.yml based on META.yml"
);
- my $meta = Module::Build::YAML->read('META.yml')->[0];
- my $mymeta = Module::Build::YAML->read('MYMETA.yml')->[0];
+ my $meta = YAML::Tiny->read('META.yml')->[0];
+ my $mymeta = YAML::Tiny->read('MYMETA.yml')->[0];
is( delete $mymeta->{dynamic_config}, 0,
"MYMETA 'dynamic_config' is 0"
);
@@ -74,7 +78,7 @@ $dist->chdir_in;
"Ran Build.PL with dynamic config"
);
ok( -e "MYMETA.yml", "MYMETA.yml exists" );
- $mymeta = Module::Build::YAML->read('MYMETA.yml')->[0];
+ $mymeta = YAML::Tiny->read('MYMETA.yml')->[0];
isnt( $meta->{requires}{'File::Spec'},
$mymeta->{requires}{'File::Spec'},
"MYMETA requires differs from META"
@@ -86,14 +90,14 @@ $dist->chdir_in;
# manually change META and check that changes are preserved
$meta->{author} = ['John Gault'];
- ok( Module::Build::YAML->new($meta)->write('META.yml'),
+ ok( YAML::Tiny->new($meta)->write('META.yml'),
"Wrote manually modified META.yml" );
$output = stdout_of sub { $dist->run_build_pl };
like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
"Ran Build.PL"
);
- my $mymeta2 = Module::Build::YAML->read('MYMETA.yml')->[0];
+ my $mymeta2 = YAML::Tiny->read('MYMETA.yml')->[0];
is_deeply( $mymeta2->{author}, [ 'John Gault' ],
"MYMETA preserved META modifications"
);

0 comments on commit e0939c4

Please sign in to comment.
Something went wrong with that request. Please try again.