[perl-ExtUtils-Depends] Use / to make ::load filename, not File::Spec - perldoc -f require



commit 913bff0bad8bc4a2a882420af0b7505b9c0841b1
Author: Ed J <mohawk2 users noreply github com>
Date:   Thu Jan 1 17:18:06 2015 +0000

    Use / to make ::load filename, not File::Spec - perldoc -f require

 lib/ExtUtils/Depends.pm |    3 ++-
 t/02_save_load.t        |   21 ++++++++++++++++++---
 2 files changed, 20 insertions(+), 4 deletions(-)
---
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm
index 8e2f916..74043e1 100644
--- a/lib/ExtUtils/Depends.pm
+++ b/lib/ExtUtils/Depends.pm
@@ -178,7 +178,8 @@ sub load {
        my $dep = shift;
        my @pieces = split /::/, $dep;
        my @suffix = qw/ Install Files /;
-       my $relpath = File::Spec->catfile (@pieces, @suffix) . '.pm';
+       # not File::Spec - see perldoc -f require
+       my $relpath = join('/', @pieces, @suffix) . '.pm';
        my $depinstallfiles = join "::", @pieces, @suffix;
        eval {
                require $relpath 
diff --git a/t/02_save_load.t b/t/02_save_load.t
index 83769fd..998817f 100644
--- a/t/02_save_load.t
+++ b/t/02_save_load.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 38;
+use Test::More tests => 40;
 
 use FindBin;
 use lib "$FindBin::Bin/lib";
@@ -44,7 +44,13 @@ $dep_info->install (@installed_files);
 
 use Data::Dumper;
 $Data::Dumper::Terse = 1;
-$dep_info->save_config (catfile $tmp_inc, qw(DepTest Install Files.pm));
+my $IFpm = catfile $tmp_inc, qw(DepTest Install Files.pm);
+$dep_info->save_config ($IFpm);
+
+# ensure '/' used for config filename in require, not File::Spec
+open my $iffh, '>>', $IFpm or die "write $IFpm: $!";
+print $iffh qq{\nwarn "LOADING\\n";\n1;\n};
+undef $iffh;
 
 # --------------------------------------------------------------------------- #
 
@@ -75,7 +81,16 @@ foreach my $file (@c_files, @xs_files) {
 
 # --------------------------------------------------------------------------- #
 
-my $info = ExtUtils::Depends::load ('DepTest');
+my $info;
+{
+my $warning = '';
+local $SIG{__WARN__} = sub { $warning .= join '', @_; };
+$info = ExtUtils::Depends::load ('DepTest');
+like $warning, qr/LOADING/, 'loaded once';
+$warning = '';
+require DepTest::Install::Files;
+unlike $warning, qr/LOADING/, 'not loaded twice';
+}
 
 my $install_part = qr|DepTest.Install|;
 like ($info->{inc}, $install_part, "loaded inc");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]