@@ -5,27 +5,49 @@ use Config;
55use CPAN::Distroprefs;
66use File::Spec;
77
8- my $yamlclass = $^V =~ / c$ / ? ' YAML::Safe' : ' YAML' ;
8+ my $yamlclass = $^V =~ / c$ /
9+ ? ($] >= 5.030 ? ' YAML::Safe' : ' YAML::XS' )
10+ : ' YAML' ;
911my %ext = (
1012 yml => $yamlclass ,
1113);
1214eval " require $ext {yml}; 1"
1315 or plan skip_all => " $ext {yml} required" ;
14- plan tests => 3 ;
16+ plan tests => 4 ;
1517
1618my $finder = CPAN::Distroprefs-> find(
1719 ' ./distroprefs' , \%ext ,
1820);
21+ my $LoadFile = sub {
22+ no strict ' refs' ;
23+ my $m = " ${yamlclass} ::LoadFile" ;
24+ if ($yamlclass eq ' YAML::Safe' ) {
25+ my $c = $yamlclass ;
26+ my $o = $c -> new-> nonstrict;
27+ $o -> SafeLoadFile(@_ );
28+ } elsif ($^V =~ / c$ / && $yamlclass eq ' YAML::XS' ) { # only the cperl variant
29+ local $YAML::XS::NonStrict = 1;
30+ $m -> LoadFile(@_ );
31+ } else {
32+ $m -> (@_ );
33+ }
34+ };
1935
2036my $last = ' 0' ;
21- my @errors ;
37+ my ( @errors , @ymlerrors ) ;
2238while (my $next = $finder -> next) {
2339 if ( $next -> file lt $last ) {
2440 push @errors , $next -> file . " lt $last \n " ;
2541 }
2642 $last = $next -> file;
43+ if ($last =~ / \. ya?ml/ ) {
44+ my $result ;
45+ eval { $result = $LoadFile -> (" distroprefs/$last " ) };
46+ push @ymlerrors , $next -> file . " $@ \n " if !$result or $@ ;
47+ }
2748}
2849is(scalar @errors , 0, " finder traversed alphabetically" ) or diag @errors ;
50+ is(scalar @ymlerrors , 0, " all yml parsed" ) or diag @ymlerrors ;
2951
3052sub find_ok {
3153 my ($arg , $expect , $label ) = @_ ;
@@ -62,11 +84,6 @@ sub find_ok {
6284 );
6385}
6486
65- my $LoadFile = sub {
66- no strict ' refs' ;
67- my $m = " ${yamlclass} ::LoadFile" ;
68- $m -> (@_ )
69- };
7087find_ok(
7188 {
7289 distribution => ' HDP/Perl-Version-1' ,
@@ -86,7 +103,7 @@ find_ok(
86103 distribution => ' INGY/YAML-0.66' ,
87104 },
88105 {
89- prefs => do ' distroprefs/INGY.YAML.dd' ,
106+ prefs => do ' ./ distroprefs/INGY.YAML.dd' ,
90107 prefs_file => File::Spec-> catfile(qw/ distroprefs INGY.YAML.dd/ ),
91108 },
92109 ' match .dd' ,
0 commit comments