@@ -5,27 +5,49 @@ use Config;
5
5
use CPAN::Distroprefs;
6
6
use File::Spec;
7
7
8
- my $yamlclass = $^V =~ / c$ / ? ' YAML::Safe' : ' YAML' ;
8
+ my $yamlclass = $^V =~ / c$ /
9
+ ? ($] >= 5.030 ? ' YAML::Safe' : ' YAML::XS' )
10
+ : ' YAML' ;
9
11
my %ext = (
10
12
yml => $yamlclass ,
11
13
);
12
14
eval " require $ext {yml}; 1"
13
15
or plan skip_all => " $ext {yml} required" ;
14
- plan tests => 3 ;
16
+ plan tests => 4 ;
15
17
16
18
my $finder = CPAN::Distroprefs-> find(
17
19
' ./distroprefs' , \%ext ,
18
20
);
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
+ };
19
35
20
36
my $last = ' 0' ;
21
- my @errors ;
37
+ my ( @errors , @ymlerrors ) ;
22
38
while (my $next = $finder -> next) {
23
39
if ( $next -> file lt $last ) {
24
40
push @errors , $next -> file . " lt $last \n " ;
25
41
}
26
42
$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
+ }
27
48
}
28
49
is(scalar @errors , 0, " finder traversed alphabetically" ) or diag @errors ;
50
+ is(scalar @ymlerrors , 0, " all yml parsed" ) or diag @ymlerrors ;
29
51
30
52
sub find_ok {
31
53
my ($arg , $expect , $label ) = @_ ;
@@ -62,11 +84,6 @@ sub find_ok {
62
84
);
63
85
}
64
86
65
- my $LoadFile = sub {
66
- no strict ' refs' ;
67
- my $m = " ${yamlclass} ::LoadFile" ;
68
- $m -> (@_ )
69
- };
70
87
find_ok(
71
88
{
72
89
distribution => ' HDP/Perl-Version-1' ,
@@ -86,7 +103,7 @@ find_ok(
86
103
distribution => ' INGY/YAML-0.66' ,
87
104
},
88
105
{
89
- prefs => do ' distroprefs/INGY.YAML.dd' ,
106
+ prefs => do ' ./ distroprefs/INGY.YAML.dd' ,
90
107
prefs_file => File::Spec-> catfile(qw/ distroprefs INGY.YAML.dd/ ),
91
108
},
92
109
' match .dd' ,
0 commit comments