This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Apply changes for CPAN-Meta-YAML v0.014.
authorDavid Golden <dagolden@cpan.org>
Tue, 17 Mar 2015 02:02:00 +0000 (22:02 -0400)
committerJames E Keenan <jkeenan@cpan.org>
Mon, 1 Jun 2015 23:53:57 +0000 (19:53 -0400)
Held to be applied to blead before perl-5.23.1.

One test failure was corrected: t/Porting/exec-bit.t.
set +x on this executable, as it is in the cpan distribution

Additional patch by Karen Etheridge.

15 files changed:
MANIFEST
cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm
cpan/CPAN-Meta-YAML/t/00-report-prereqs.dd [new file with mode: 0644]
cpan/CPAN-Meta-YAML/t/10_read.t
cpan/CPAN-Meta-YAML/t/12_write.t
cpan/CPAN-Meta-YAML/t/21_yamlpm_compat.t
cpan/CPAN-Meta-YAML/t/30_yaml_spec_tml.t
cpan/CPAN-Meta-YAML/t/86_fail.t [new file with mode: 0644]
cpan/CPAN-Meta-YAML/t/README.md
cpan/CPAN-Meta-YAML/t/lib/TestBridge.pm
cpan/CPAN-Meta-YAML/t/lib/TestUtils.pm
cpan/CPAN-Meta-YAML/t/tml-local/load-error/document.tml
cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/collection.tml
cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/quoting.tml
cpan/CPAN-Meta-YAML/t/tml-world/YAML-Tiny-META.tml

index 1a81320..2586c3a 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -326,6 +326,7 @@ cpan/CPAN-Meta/t/repository.t
 cpan/CPAN-Meta/t/save-load.t
 cpan/CPAN-Meta/t/validator.t
 cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm              CPAN-Meta-YAML files
+cpan/CPAN-Meta-YAML/t/00-report-prereqs.dd
 cpan/CPAN-Meta-YAML/t/01_api.t
 cpan/CPAN-Meta-YAML/t/01_compile.t             CPAN-Meta-YAML files
 cpan/CPAN-Meta-YAML/t/10_read.t
@@ -337,6 +338,7 @@ cpan/CPAN-Meta-YAML/t/21_yamlpm_compat.t
 cpan/CPAN-Meta-YAML/t/30_yaml_spec_tml.t
 cpan/CPAN-Meta-YAML/t/31_local_tml.t
 cpan/CPAN-Meta-YAML/t/32_world_tml.t
+cpan/CPAN-Meta-YAML/t/86_fail.t
 cpan/CPAN-Meta-YAML/t/data/ascii.yml
 cpan/CPAN-Meta-YAML/t/data/latin1.yml
 cpan/CPAN-Meta-YAML/t/data/multibyte.yml               CPAN-Meta-YAML files
index 387a8c4..604a645 100644 (file)
@@ -1,17 +1,12 @@
 use 5.008001; # sane UTF-8 support
 use strict;
 use warnings;
-package CPAN::Meta::YAML;
-$CPAN::Meta::YAML::VERSION = '0.012';
-BEGIN {
-  $CPAN::Meta::YAML::AUTHORITY = 'cpan:ADAMK';
-}
-# git description: v1.60-1-g1c16a0a
-; # original $VERSION removed by Doppelgaenger
+package CPAN::Meta::YAML; # git description: v1.65-6-gfa117d1
 # XXX-INGY is 5.8.1 too old/broken for utf8?
 # XXX-XDG Lancaster consensus was that it was sufficient until
 # proven otherwise
-
+$CPAN::Meta::YAML::VERSION = '0.014';
+; # original $VERSION removed by Doppelgaenger
 
 #####################################################################
 # The CPAN::Meta::YAML API.
@@ -153,7 +148,7 @@ my %QUOTE = map { $_ => 1 } qw{
 my $re_capture_double_quoted = qr/\"([^\\"]*(?:\\.[^\\"]*)*)\"/;
 my $re_capture_single_quoted = qr/\'([^\']*(?:\'\'[^\']*)*)\'/;
 # unquoted re gets trailing space that needs to be stripped
-my $re_capture_unquoted_key  = qr/([^:]+(?::+\S[^:]*)*)(?=\s*\:(?:\s+|$))/;
+my $re_capture_unquoted_key  = qr/([^:]+(?::+\S(?:[^:]*|.*?(?=:)))*)(?=\s*\:(?:\s+|$))/;
 my $re_trailing_comment      = qr/(?:\s+\#.*)?/;
 my $re_key_value_separator   = qr/\s*:(?:\s+(?:\#.*)?|$)/;
 
@@ -300,10 +295,11 @@ Did you decode with lax ":utf8" instead of strict ":encoding(UTF-8)"?
             }
         }
     };
-    if ( ref $@ eq 'SCALAR' ) {
-        $self->_error(${$@});
-    } elsif ( $@ ) {
-        $self->_error($@);
+    my $err = $@;
+    if ( ref $err eq 'SCALAR' ) {
+        $self->_error(${$err});
+    } elsif ( $err ) {
+        $self->_error($err);
     }
 
     return $self;
@@ -515,6 +511,10 @@ sub _load_hash {
             die \"CPAN::Meta::YAML failed to classify line '$lines->[0]'";
         }
 
+        if ( exists $hash->{$key} ) {
+            die \"CPAN::Meta::YAML found a duplicate key '$key' in line '$lines->[0]'";
+        }
+
         # Do we have a value?
         if ( length $lines->[0] ) {
             # Yes
@@ -828,12 +828,10 @@ sub _can_flock {
 #####################################################################
 # Use Scalar::Util if possible, otherwise emulate it
 
+use Scalar::Util ();
 BEGIN {
     local $@;
-    if ( eval { require Scalar::Util }
-      && $Scalar::Util::VERSION
-      && eval($Scalar::Util::VERSION) >= 1.18
-    ) {
+    if ( eval { Scalar::Util->VERSION(1.18); } ) {
         *refaddr = *Scalar::Util::refaddr;
     }
     else {
@@ -855,8 +853,7 @@ END_PERL
     }
 }
 
-
-
+delete $CPAN::Meta::YAML::{refaddr};
 
 1;
 
@@ -881,7 +878,7 @@ CPAN::Meta::YAML - Read and write a subset of YAML for CPAN Meta files
 
 =head1 VERSION
 
-version 0.012
+version 0.014
 
 =head1 SYNOPSIS
 
@@ -917,31 +914,12 @@ C<write> methods do B<not> support UTF-8 and should not be used.
 This module is currently derived from L<YAML::Tiny> by Adam Kennedy.  If
 there are bugs in how it parses a particular META.yml file, please file
 a bug report in the YAML::Tiny bugtracker:
-L<https://rt.cpan.org/Public/Dist/Display.html?Name=YAML-Tiny>
+L<https://github.com/Perl-Toolchain-Gang/YAML-Tiny/issues>
 
 =head1 SEE ALSO
 
 L<YAML::Tiny>, L<YAML>, L<YAML::XS>
 
-=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
-
-=head1 SUPPORT
-
-=head2 Bugs / Feature Requests
-
-Please report any bugs or feature requests through the issue tracker
-at L<https://github.com/dagolden/CPAN-Meta-YAML/issues>.
-You will be notified automatically of any progress on your issue.
-
-=head2 Source Code
-
-This is open source software.  The code repository is available for
-public review and contribution under the terms of the license.
-
-L<https://github.com/dagolden/CPAN-Meta-YAML>
-
-  git clone https://github.com/dagolden/CPAN-Meta-YAML.git
-
 =head1 AUTHORS
 
 =over 4
diff --git a/cpan/CPAN-Meta-YAML/t/00-report-prereqs.dd b/cpan/CPAN-Meta-YAML/t/00-report-prereqs.dd
new file mode 100644 (file)
index 0000000..589a97a
--- /dev/null
@@ -0,0 +1,66 @@
+do { my $x = {
+       'configure' => {
+                        'requires' => {
+                                        'ExtUtils::MakeMaker' => '6.17',
+                                        'perl' => '5.008001'
+                                      }
+                      },
+       'develop' => {
+                      'requires' => {
+                                      'Dist::Zilla' => '5',
+                                      'Dist::Zilla::Plugin::AppendExternalData' => '0',
+                                      'Dist::Zilla::Plugin::Doppelgaenger' => '0.007',
+                                      'Dist::Zilla::Plugin::Encoding' => '0',
+                                      'Dist::Zilla::Plugin::Git::NextVersion' => '0',
+                                      'Dist::Zilla::Plugin::MakeMaker::Highlander' => '0.003',
+                                      'Dist::Zilla::Plugin::MetaResources' => '0',
+                                      'Dist::Zilla::Plugin::PkgVersion' => '0',
+                                      'Dist::Zilla::Plugin::PodWeaver' => '0',
+                                      'Dist::Zilla::Plugin::PruneFiles' => '0',
+                                      'Dist::Zilla::Plugin::RemovePrereqs' => '0',
+                                      'Dist::Zilla::PluginBundle::DAGOLDEN' => '0.072',
+                                      'File::Spec' => '0',
+                                      'File::Temp' => '0',
+                                      'IO::Handle' => '0',
+                                      'IPC::Open3' => '0',
+                                      'Test::CPAN::Meta' => '0',
+                                      'Test::More' => '0',
+                                      'Test::Pod' => '1.41',
+                                      'Test::Version' => '1'
+                                    }
+                    },
+       'runtime' => {
+                      'requires' => {
+                                      'B' => '0',
+                                      'Carp' => '0',
+                                      'Exporter' => '0',
+                                      'Fcntl' => '0',
+                                      'Scalar::Util' => '0',
+                                      'perl' => '5.008001',
+                                      'strict' => '0',
+                                      'warnings' => '0'
+                                    }
+                    },
+       'test' => {
+                   'recommends' => {
+                                     'CPAN::Meta' => '2.120900'
+                                   },
+                   'requires' => {
+                                   'ExtUtils::MakeMaker' => '0',
+                                   'File::Basename' => '0',
+                                   'File::Find' => '0',
+                                   'File::Spec' => '0',
+                                   'File::Spec::Functions' => '0',
+                                   'File::Temp' => '0.18',
+                                   'IO::Dir' => '0',
+                                   'JSON::PP' => '0',
+                                   'Test::More' => '0.99',
+                                   'lib' => '0',
+                                   'perl' => '5.008001',
+                                   'utf8' => '0',
+                                   'vars' => '0'
+                                 }
+                 }
+     };
+  $x;
+ }
\ No newline at end of file
index 27f83b6..af02e79 100644 (file)
@@ -101,12 +101,5 @@ subtest "bad read arguments" => sub {
 };
 
 done_testing;
-#
-# This file is part of CPAN-Meta-YAML
-#
-# This software is copyright (c) 2010 by Adam Kennedy.
-#
-# This is free software; you can redistribute it and/or modify it under
-# the same terms as the Perl 5 programming language system itself.
-#
+# COPYRIGHT
 # vim: ts=4 sts=4 sw=4 et:
index 8c7b4be..4c099e4 100644 (file)
@@ -8,7 +8,8 @@ use TestUtils;
 
 use CPAN::Meta::YAML;
 use File::Basename qw/basename/;
-use File::Temp qw/tempfile/;
+use File::Spec::Functions 'catfile';
+use File::Temp 0.18;
 
 #--------------------------------------------------------------------------#
 # Error conditions
@@ -44,9 +45,9 @@ for my $c ( @cases ) {
         @warnings = ();
 
         # get a tempfile name to write to
-        my ($fh, $tempfile) = tempfile("YAML-Tiny-test-XXXXXXXX", TMPDIR => 1 );
-        my $short_tempfile = basename($tempfile);
-        close $fh; # avoid locks on windows
+        my $tempdir = File::Temp->newdir("YTXXXXXX", TMPDIR => 1 );
+        my $short_tempfile = 'output';
+        my $tempfile = catfile($tempdir, $short_tempfile);
 
         # CPAN::Meta::YAML->write
         ok( CPAN::Meta::YAML->new($c)->write($tempfile),
index e6a69d3..aa58711 100644 (file)
@@ -3,7 +3,8 @@ use warnings;
 use lib 't/lib/';
 use Test::More 0.99;
 use TestBridge;
-use File::Temp qw(tempfile);
+use File::Spec::Functions 'catfile';
+use File::Temp 0.18;
 
 #--------------------------------------------------------------------------#
 # This file test that the YAML.pm compatible Dump/Load/DumpFile/LoadFile
@@ -31,8 +32,8 @@ use CPAN::Meta::YAML;
     my $arrayref = [ 1 .. 5 ];
     my $hashref = { alpha => 'beta', gamma => 'delta' };
 
-    my ($fh, $filename) = tempfile;
-    close $fh; # or LOCK_SH will hang
+    my $tempdir = File::Temp->newdir("YTXXXXXX", TMPDIR => 1 );
+    my $filename = catfile($tempdir, 'compat');
 
     my $rv = CPAN::Meta::YAML::DumpFile(
         $filename, $scalar, $arrayref, $hashref);
index 1c56c38..1209a96 100644 (file)
@@ -1,20 +1,22 @@
 # Run the appropriate tests from https://github.com/ingydotnet/yaml-spec-tml
 use strict;
 use warnings;
-use lib 't/lib/';
+use lib 't/lib';
 use Test::More 0.99;
 use TestBridge;
 use TestUtils;
 
 my $JSON = json_class()
-    or Test::More::plan skip_all => "no JSON or JSON::PP";
+    or Test::More::plan skip_all => 'no JSON backends available!?';
+
+diag 'using JSON backend: ' . $JSON;
 
 # Each spec test will need a different bridge and arguments:
 my @spec_tests = (
     ['t/tml-spec/basic-data.tml', 'test_yaml_json', $JSON],
     # This test is currently failing massively. We use LAST to only run what is
     # covered so far.
-    ['t/tml-spec/unicode.tml', 'test_code_point'],
+    ['t/tml-spec/unicode.tml', 'test_code_point'],  # uses JSON::PP
 );
 
 for my $test (@spec_tests) {
diff --git a/cpan/CPAN-Meta-YAML/t/86_fail.t b/cpan/CPAN-Meta-YAML/t/86_fail.t
new file mode 100644 (file)
index 0000000..b61a06b
--- /dev/null
@@ -0,0 +1,30 @@
+=pod
+
+This is an example of a serious design flaw in CPAN::Meta::YAML.
+
+It is generally a bad idea to fake out a parsing process. In this case,
+CPAN::Meta::YAML strips off all lines that look like comments.
+
+It should be easy to find dozens of bugs by looking at the assumptions the code
+makes and then finding a counter case like this.
+
+That's why I'm working on Tiny::YAML and YAML::Pegex, which are driven by a
+grammar.
+
+=cut
+
+use Test::More tests => 1;
+use CPAN::Meta::YAML;
+
+TODO: {
+local $TODO = "Failing tests for things CPAN::Meta::YAML does wrong";
+
+my $yaml = <<'...';
+- |
+  # Perl sub:
+  sub foo {}
+...
+is Load($yaml)->[0],
+    "# Perl sub:\nsub foo{}\n",
+    "Comments in literal scalars";
+}
index 4eece3c..e95ebfe 100644 (file)
@@ -1,6 +1,6 @@
-# Guide to CPAN::Meta::YAML testing
+# Guide to YAML::Tiny testing
 
-CPAN::Meta::YAML tests use several components:
+YAML::Tiny tests use several components:
 
 * .t files
 * Test libraries in t/lib
@@ -120,10 +120,10 @@ functions used to process test blocks.
 TestML data files are organized into three directories:
 
 * t/tml-spec — these test files are provided by the YAML spec maintainers and
-should not be modified except to skip testing features that CPAN::Meta::YAML does not
+should not be modified except to skip testing features that YAML::Tiny does not
 support
 
-* t/tml-local — these test files are CPAN::Meta::YAML's own unit tests; generally new
+* t/tml-local — these test files are YAML::Tiny's own unit tests; generally new
 test cases for coverage or correctness should be added here; these are
 broken into subdirectories, described later
 
index 56c3a38..addec9a 100644 (file)
@@ -38,6 +38,7 @@ my %ERROR = (
     E_FEATURE  => qr{\QCPAN::Meta::YAML does not support a feature},
     E_PLAIN    => qr{\QCPAN::Meta::YAML found illegal characters in plain scalar},
     E_CLASSIFY => qr{\QCPAN::Meta::YAML failed to classify the line},
+    E_DUPKEY   => qr{\QCPAN::Meta::YAML found a duplicate key},
 );
 
 # use XXX -with => 'YAML::XS';
@@ -194,7 +195,7 @@ sub test_perl_to_yaml {
 #--------------------------------------------------------------------------#
 # test_dump_error
 #
-# two blocks: perl, error 
+# two blocks: perl, error
 #
 # Tests that perl references result in an error when dumped
 #
@@ -225,7 +226,7 @@ sub test_dump_error {
 #--------------------------------------------------------------------------#
 # test_load_error
 #
-# two blocks: yaml, error 
+# two blocks: yaml, error
 #
 # Tests that a YAML string results in an error when loaded
 #
index df49933..b41f35c 100644 (file)
@@ -26,12 +26,9 @@ sub find_tml_files {
     return @files;
 }
 
-# Prefer JSON to JSON::PP; skip if we don't have at least one
 sub json_class {
-    for (qw/JSON JSON::PP/) {
-        return $_ if eval "require $_; 1";
-    }
-    return;
+    return eval { require JSON::MaybeXS; JSON::MaybeXS->VERSION('1.001000'); $JSON::MaybeXS::JSON_Class }
+        || do { require JSON::PP; 'JSON::PP' };
 }
 
 sub test_data_directory {
index 454c5d0..9e881f4 100644 (file)
@@ -3,3 +3,9 @@
 \--- foo
 a: 1
 --- error: E_CLASSIFY
+
+=== mapping with double key
+--- yaml
+foo: 1
+foo: 2
+--- error: E_DUPKEY
index 5b45243..8927ebd 100644 (file)
@@ -126,3 +126,12 @@ FOO:
     bar: baz 
 --- perl
 [ { 'FOO' => [ { bar => 'baz' } ] } ]
+
+# RT 92916 (a Test::Database ticket)
+=== colon at end of key
+--- yaml
+\---
+dbi:SQLite::
+  foo: bar
+--- perl
+[ { 'dbi:SQLite:' => { 'foo' => 'bar' } } ]
index e9fb60f..18de3bb 100644 (file)
@@ -131,4 +131,9 @@ slash3: '\\foo\\\\'
 [ "A\\B \\C" ]
 
 
-
+=== Single Dash
+--- yaml
+---
+foo: '-'
+--- perl
+[ { foo => '-' } ]
index af84a39..b5b39ed 100644 (file)
@@ -1,5 +1,5 @@
-=== CPAN::Meta::YAML
-# Testing CPAN::Meta::YAML's own META.yml file -- at least as of some time ago
+=== YAML::Tiny
+# Testing YAML::Tiny's own META.yml file -- at least as of some time ago
 --- yaml
 abstract: Read/Write YAML files with as little code as possible
 author: 'Adam Kennedy <cpan@ali.as>'