summaryrefslogtreecommitdiff
path: root/cpan/CPAN-Meta-YAML
diff options
context:
space:
mode:
authorDavid Golden <dagolden@cpan.org>2015-03-16 22:02:00 -0400
committerJames E Keenan <jkeenan@cpan.org>2015-06-01 19:53:57 -0400
commit23741be4b13f82d31898c3651473f1942bdc945f (patch)
tree735f771972a1c9821b54cd083e55ad42b3f1e8de /cpan/CPAN-Meta-YAML
parent4e3e12f89258dc3beac58ac290b46017f159cc68 (diff)
downloadperl-23741be4b13f82d31898c3651473f1942bdc945f.tar.gz
Apply changes for CPAN-Meta-YAML v0.014.
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.
Diffstat (limited to 'cpan/CPAN-Meta-YAML')
-rw-r--r--cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm58
-rw-r--r--cpan/CPAN-Meta-YAML/t/00-report-prereqs.dd66
-rw-r--r--cpan/CPAN-Meta-YAML/t/10_read.t9
-rw-r--r--cpan/CPAN-Meta-YAML/t/12_write.t9
-rw-r--r--cpan/CPAN-Meta-YAML/t/21_yamlpm_compat.t7
-rw-r--r--cpan/CPAN-Meta-YAML/t/30_yaml_spec_tml.t8
-rw-r--r--cpan/CPAN-Meta-YAML/t/86_fail.t30
-rw-r--r--cpan/CPAN-Meta-YAML/t/README.md8
-rw-r--r--cpan/CPAN-Meta-YAML/t/lib/TestBridge.pm5
-rw-r--r--cpan/CPAN-Meta-YAML/t/lib/TestUtils.pm7
-rw-r--r--cpan/CPAN-Meta-YAML/t/tml-local/load-error/document.tml6
-rw-r--r--cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/collection.tml9
-rw-r--r--cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/quoting.tml7
-rw-r--r--cpan/CPAN-Meta-YAML/t/tml-world/YAML-Tiny-META.tml4
14 files changed, 161 insertions, 72 deletions
diff --git a/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm b/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm
index 387a8c4bb8..604a6450fa 100644
--- a/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm
+++ b/cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm
@@ -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
index 0000000000..589a97a190
--- /dev/null
+++ b/cpan/CPAN-Meta-YAML/t/00-report-prereqs.dd
@@ -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
diff --git a/cpan/CPAN-Meta-YAML/t/10_read.t b/cpan/CPAN-Meta-YAML/t/10_read.t
index 27f83b6587..af02e79d38 100644
--- a/cpan/CPAN-Meta-YAML/t/10_read.t
+++ b/cpan/CPAN-Meta-YAML/t/10_read.t
@@ -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:
diff --git a/cpan/CPAN-Meta-YAML/t/12_write.t b/cpan/CPAN-Meta-YAML/t/12_write.t
index 8c7b4bec63..4c099e4d27 100644
--- a/cpan/CPAN-Meta-YAML/t/12_write.t
+++ b/cpan/CPAN-Meta-YAML/t/12_write.t
@@ -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),
diff --git a/cpan/CPAN-Meta-YAML/t/21_yamlpm_compat.t b/cpan/CPAN-Meta-YAML/t/21_yamlpm_compat.t
index e6a69d3df4..aa587114c3 100644
--- a/cpan/CPAN-Meta-YAML/t/21_yamlpm_compat.t
+++ b/cpan/CPAN-Meta-YAML/t/21_yamlpm_compat.t
@@ -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);
diff --git a/cpan/CPAN-Meta-YAML/t/30_yaml_spec_tml.t b/cpan/CPAN-Meta-YAML/t/30_yaml_spec_tml.t
index 1c56c38f96..1209a9690b 100644
--- a/cpan/CPAN-Meta-YAML/t/30_yaml_spec_tml.t
+++ b/cpan/CPAN-Meta-YAML/t/30_yaml_spec_tml.t
@@ -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
index 0000000000..b61a06b192
--- /dev/null
+++ b/cpan/CPAN-Meta-YAML/t/86_fail.t
@@ -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";
+}
diff --git a/cpan/CPAN-Meta-YAML/t/README.md b/cpan/CPAN-Meta-YAML/t/README.md
index 4eece3c359..e95ebfe81a 100644
--- a/cpan/CPAN-Meta-YAML/t/README.md
+++ b/cpan/CPAN-Meta-YAML/t/README.md
@@ -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
diff --git a/cpan/CPAN-Meta-YAML/t/lib/TestBridge.pm b/cpan/CPAN-Meta-YAML/t/lib/TestBridge.pm
index 56c3a38123..addec9a7f8 100644
--- a/cpan/CPAN-Meta-YAML/t/lib/TestBridge.pm
+++ b/cpan/CPAN-Meta-YAML/t/lib/TestBridge.pm
@@ -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
#
diff --git a/cpan/CPAN-Meta-YAML/t/lib/TestUtils.pm b/cpan/CPAN-Meta-YAML/t/lib/TestUtils.pm
index df4993329d..b41f35c077 100644
--- a/cpan/CPAN-Meta-YAML/t/lib/TestUtils.pm
+++ b/cpan/CPAN-Meta-YAML/t/lib/TestUtils.pm
@@ -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 {
diff --git a/cpan/CPAN-Meta-YAML/t/tml-local/load-error/document.tml b/cpan/CPAN-Meta-YAML/t/tml-local/load-error/document.tml
index 454c5d0f6e..9e881f4ea1 100644
--- a/cpan/CPAN-Meta-YAML/t/tml-local/load-error/document.tml
+++ b/cpan/CPAN-Meta-YAML/t/tml-local/load-error/document.tml
@@ -3,3 +3,9 @@
\--- foo
a: 1
--- error: E_CLASSIFY
+
+=== mapping with double key
+--- yaml
+foo: 1
+foo: 2
+--- error: E_DUPKEY
diff --git a/cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/collection.tml b/cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/collection.tml
index 5b45243308..8927ebdb1d 100644
--- a/cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/collection.tml
+++ b/cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/collection.tml
@@ -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' } } ]
diff --git a/cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/quoting.tml b/cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/quoting.tml
index e9fb60f620..18de3bb97c 100644
--- a/cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/quoting.tml
+++ b/cpan/CPAN-Meta-YAML/t/tml-local/yaml-roundtrip/quoting.tml
@@ -131,4 +131,9 @@ slash3: '\\foo\\\\'
[ "A\\B \\C" ]
-
+=== Single Dash
+--- yaml
+---
+foo: '-'
+--- perl
+[ { foo => '-' } ]
diff --git a/cpan/CPAN-Meta-YAML/t/tml-world/YAML-Tiny-META.tml b/cpan/CPAN-Meta-YAML/t/tml-world/YAML-Tiny-META.tml
index af84a39deb..b5b39ed019 100644
--- a/cpan/CPAN-Meta-YAML/t/tml-world/YAML-Tiny-META.tml
+++ b/cpan/CPAN-Meta-YAML/t/tml-world/YAML-Tiny-META.tml
@@ -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>'