Hello community,

here is the log from the commit of package perl-Module-Reader for 
openSUSE:Factory checked in at 2017-06-26 15:56:28
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Module-Reader (Old)
 and      /work/SRC/openSUSE:Factory/.perl-Module-Reader.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-Module-Reader"

Mon Jun 26 15:56:28 2017 rev:5 rq:506084 version:0.003003

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Module-Reader/perl-Module-Reader.changes    
2017-01-10 10:41:56.288409591 +0100
+++ 
/work/SRC/openSUSE:Factory/.perl-Module-Reader.new/perl-Module-Reader.changes   
    2017-06-26 15:56:31.055666476 +0200
@@ -1,0 +2,12 @@
+Thu Jun 22 05:53:38 UTC 2017 - [email protected]
+
+- updated to 0.003003
+   see /usr/share/doc/packages/perl-Module-Reader/Changes
+
+  0.003003 - 2017-06-21
+    - fix EACCES handling to match the current perl
+    - fix raw file handle access for unopened files
+    - call @INC hooks for ./, ../, and / paths if they weren't found directly
+    - add handling for a string reference prefix return from a hook
+
+-------------------------------------------------------------------

Old:
----
  Module-Reader-0.003002.tar.gz

New:
----
  Module-Reader-0.003003.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-Module-Reader.spec ++++++
--- /var/tmp/diff_new_pack.ly2fQ6/_old  2017-06-26 15:56:31.747568907 +0200
+++ /var/tmp/diff_new_pack.ly2fQ6/_new  2017-06-26 15:56:31.751568343 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package perl-Module-Reader
 #
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,14 +17,14 @@
 
 
 Name:           perl-Module-Reader
-Version:        0.003002
+Version:        0.003003
 Release:        0
 %define cpan_name Module-Reader
 Summary:        Find and read perl modules like perl does
 License:        Artistic-1.0 or GPL-1.0+
 Group:          Development/Libraries/Perl
 Url:            http://search.cpan.org/dist/Module-Reader/
-Source0:        
http://www.cpan.org/authors/id/H/HA/HAARG/%{cpan_name}-%{version}.tar.gz
+Source0:        
https://cpan.metacpan.org/authors/id/H/HA/HAARG/%{cpan_name}-%{version}.tar.gz
 Source1:        cpanspec.yml
 BuildArch:      noarch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ Module-Reader-0.003002.tar.gz -> Module-Reader-0.003003.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/Changes 
new/Module-Reader-0.003003/Changes
--- old/Module-Reader-0.003002/Changes  2016-12-14 09:13:32.000000000 +0100
+++ new/Module-Reader-0.003003/Changes  2017-06-21 18:21:27.000000000 +0200
@@ -1,5 +1,11 @@
 Revision history for Module-Reader
 
+0.003003 - 2017-06-21
+  - fix EACCES handling to match the current perl
+  - fix raw file handle access for unopened files
+  - call @INC hooks for ./, ../, and / paths if they weren't found directly
+  - add handling for a string reference prefix return from a hook
+
 0.003002 - 2016-12-14
   - releasing as stable
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/MANIFEST 
new/Module-Reader-0.003003/MANIFEST
--- old/Module-Reader-0.003002/MANIFEST 2016-12-14 09:13:41.000000000 +0100
+++ new/Module-Reader-0.003003/MANIFEST 2017-06-21 18:21:35.000000000 +0200
@@ -4,9 +4,10 @@
 Makefile.PL
 MANIFEST                       This list of files
 t/file-types.t
-t/lib/TestLib.pm
+t/lib/InlineModule.pm
 t/main.t
 t/memory.t
+t/test-data/lib/MyTestModule.pm
 META.yml                                 Module YAML meta-data (added by 
MakeMaker)
 META.json                                Module JSON meta-data (added by 
MakeMaker)
 README                                   README file (added by Distar)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/META.json 
new/Module-Reader-0.003003/META.json
--- old/Module-Reader-0.003002/META.json        2016-12-14 09:13:41.000000000 
+0100
+++ new/Module-Reader-0.003003/META.json        2017-06-21 18:21:35.000000000 
+0200
@@ -10,7 +10,7 @@
    ],
    "meta-spec" : {
       "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec";,
-      "version" : "2"
+      "version" : 2
    },
    "name" : "Module-Reader",
    "no_index" : {
@@ -53,6 +53,6 @@
          "web" : "https://github.com/haarg/Module-Reader";
       }
    },
-   "version" : "0.003002",
-   "x_serialization_backend" : "JSON::PP version 2.27300"
+   "version" : "0.003003",
+   "x_serialization_backend" : "JSON::PP version 2.94"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/META.yml 
new/Module-Reader-0.003003/META.yml
--- old/Module-Reader-0.003002/META.yml 2016-12-14 09:13:41.000000000 +0100
+++ new/Module-Reader-0.003003/META.yml 2017-06-21 18:21:35.000000000 +0200
@@ -24,5 +24,5 @@
   bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Module-Reader
   license: http://dev.perl.org/licenses/
   repository: git://github.com/haarg/Module-Reader
-version: '0.003002'
+version: '0.003003'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/README 
new/Module-Reader-0.003003/README
--- old/Module-Reader-0.003002/README   2016-12-14 09:13:41.000000000 +0100
+++ new/Module-Reader-0.003003/README   2017-06-21 18:21:35.000000000 +0200
@@ -33,7 +33,7 @@
   module_content ( $module_name, @search_directories )
     Returns the content of a given module.
 
-CLASS ATTRIBUTES
+ATTRIBUTES
     inc An array reference containing a list of directories or hooks to
         search for modules or files. This will be used in the same manner
         that require uses @INC. If not provided, @INC itself will be used.
@@ -52,6 +52,18 @@
         A boolean controlling if the files found will be opened immediately
         when found. Defaults to true.
 
+    abort_on_eacces
+        A boolean controlling if an error should be thrown or if the path
+        should be skipped when encountering "EACCES" (access denied) errors.
+        Defaults to true on perl 5.18 and above, matching the behavior of
+        require.
+
+    check_hooks_for_nonsearchable
+        For non-searchable paths (absolute paths and those starting with
+        "./" or "../") attempt to check the hook items (and not the
+        directories) in @INC if the file cannot be found directly. This
+        matches the behavior of perl. Defaults to true.
+
 METHODS
   module
     Returns a file object for the given module name. If the module can't be
@@ -79,7 +91,7 @@
 
   FILE METHODS
    filename
-    The filename that was seached for.
+    The filename that was searched for.
 
    module
     If a module was searched for, or a file of the matching form
@@ -172,7 +184,7 @@
         information for the files that it finds.
 
     Module::Locate
-        Innacurately searches @INC for matching files. Attempts to handle
+        Inaccurately searches @INC for matching files. Attempts to handle
         hooks, but handles most cases wrong.
 
     Module::Mapper
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/lib/Module/Reader.pm 
new/Module-Reader-0.003003/lib/Module/Reader.pm
--- old/Module-Reader-0.003002/lib/Module/Reader.pm     2016-12-14 
09:12:53.000000000 +0100
+++ new/Module-Reader-0.003003/lib/Module/Reader.pm     2017-06-21 
18:21:25.000000000 +0200
@@ -3,30 +3,34 @@
 use strict;
 use warnings;
 
-our $VERSION = '0.003002';
+our $VERSION = '0.003003';
 $VERSION = eval $VERSION;
 
 use Exporter (); BEGIN { *import = \&Exporter::import }
 our @EXPORT_OK = qw(module_content module_handle);
 our %EXPORT_TAGS = (all => [@EXPORT_OK]);
 
-use File::Spec;
+use File::Spec ();
 use Scalar::Util qw(reftype refaddr openhandle);
-use Carp;
+use Carp qw(croak);
 use Config ();
 use Errno qw(EACCES);
-use constant _PMC_ENABLED => !(
-  exists &Config::non_bincompat_options ? grep { $_ eq 'PERL_DISABLE_PMC' } 
Config::non_bincompat_options()
-  : $Config::Config{ccflags} =~ /(?:^|\s)-DPERL_DISABLE_PMC\b/
+use constant _OPEN_LAYERS     => "$]" >= 5.008_000 ? ':' : '';
+use constant _ABORT_ON_EACCES => "$]" >= 5.017_001;
+use constant _ALLOW_PREFIX    => "$]" >= 5.008009;
+use constant _VMS             => $^O eq 'VMS' && !!require VMS::Filespec;
+use constant _WIN32           => $^O eq 'MSWin32';
+use constant _PMC_ENABLED     => !(
+  exists &Config::non_bincompat_options
+    ? grep { $_ eq 'PERL_DISABLE_PMC' } Config::non_bincompat_options()
+    : $Config::Config{ccflags} =~ /(?:^|\s)-DPERL_DISABLE_PMC\b/
 );
-use constant _VMS => $^O eq 'VMS' && !!require VMS::Filespec;
-use constant _WIN32 => $^O eq 'MSWin32';
 use constant _FAKE_FILE_FORMAT => do {
-  (my $uvx = $Config::Config{uvxformat}||'') =~ tr/"\0//d;
+  my $uvx = $Config::Config{uvxformat} || '';
+  $uvx =~ tr/"\0//d;
   $uvx ||= 'lx';
   "/loader/0x%$uvx/%s"
 };
-use constant _OPEN_LAYERS => "$]" >= 5.008 ? ':' : '';
 
 sub _mod_to_file {
   my $module = shift;
@@ -70,6 +74,10 @@
     if !exists $options{pmc};
   $options{open} = 1
     if !exists $options{open};
+  $options{abort_on_eacces} = _ABORT_ON_EACCES
+    if !exists $options{abort_on_eacces};
+  $options{check_hooks_for_nonsearchable} = 1
+    if !exists $options{check_hooks_for_nonsearchable};
   bless \%options, $class;
 }
 
@@ -104,13 +112,6 @@
 sub _find {
   my ($self, $file, $all) = @_;
 
-  if (!_searchable($file)) {
-    my $open = $self->_open_file($file);
-    return $open
-      if $open;
-    croak "Can't locate $file";
-  }
-
   my @found;
   eval {
     if (my $found = $self->{found}) {
@@ -128,9 +129,30 @@
     die $@
       if $@;
   }
+
+  my $searchable = _searchable($file);
+  if (!$searchable) {
+    my $open = $self->_open_file($file);
+    if ($all) {
+      push @found, $open;
+    }
+    elsif ($open) {
+      return $open;
+    }
+    else {
+      croak "Can't locate $file";
+    }
+  }
+
   my $search = $self->{inc};
   for my $inc (@$search) {
     my $open;
+    if (!$searchable) {
+      last
+        if !$self->{check_hooks_for_nonsearchable};
+      next
+        if !length ref $inc;
+    }
     eval {
       if (!length ref $inc) {
         my $full = _VMS ? VMS::Filespec::unixpath($inc) : $inc;
@@ -165,21 +187,23 @@
     $full,
   ) {
     my $pmc = $full ne $try;
-    next
-      if -e $try ? (-d _ || -b _) : $! != EACCES;
-
-    if (!$self->{open} ? -e _ : open my $fh, '<'._OPEN_LAYERS, $try) {
-      return Module::Reader::File->new(
-        filename        => $file,
-        ($fh ? (raw_filehandle => $fh) : ()),
-        found_file      => $full,
-        disk_file       => $try,
-        is_pmc          => $pmc,
-        (defined $inc ? (inc_entry => $inc) : ()),
-      );
+    if (-e $try) {
+      next
+        if -d _ || -b _;
+      if (open my $fh, '<'._OPEN_LAYERS, $try) {
+        return Module::Reader::File->new(
+          filename        => $file,
+          ($self->{open} ? (raw_filehandle => $fh) : ()),
+          found_file      => $full,
+          disk_file       => $try,
+          is_pmc          => $pmc,
+          (defined $inc ? (inc_entry => $inc) : ()),
+        );
+      }
     }
+
     croak "Can't locate $file:   $full: $!"
-      unless $pmc;
+      if $self->{abort_on_eacces} && $! == EACCES && !$pmc;
   }
   return;
 }
@@ -205,10 +229,15 @@
   my $fake_file = sprintf _FAKE_FILE_FORMAT, refaddr($inc), $file;
 
   my $fh;
+  my $prefix;
   my $cb;
   my $cb_options;
 
-  if (reftype $cb[0] eq 'GLOB' && openhandle $cb[0]) {
+  if (_ALLOW_PREFIX && reftype $cb[0] eq 'SCALAR') {
+    $prefix = shift @cb;
+  }
+
+  if ((reftype $cb[0]||'') eq 'GLOB' && openhandle $cb[0]) {
     $fh = shift @cb;
   }
 
@@ -217,13 +246,14 @@
     # only one or zero callback options will be passed
     $cb_options = @cb > 1 ? [ $cb[1] ] : undef;
   }
-  elsif (!$fh) {
+  elsif (!defined $fh && !defined $prefix) {
     return;
   }
   return Module::Reader::File->new(
     filename => $file,
     found_file => $fake_file,
     inc_entry => $inc,
+    (defined $prefix ? (prefix => $prefix) : ()),
     (defined $fh ? (raw_filehandle => $fh) : ()),
     (defined $cb ? (read_callback => $cb) : ()),
     (defined $cb_options ? (read_callback_options => $cb_options) : ()),
@@ -232,12 +262,12 @@
 
 sub inc   { $_[0]->{inc} }
 sub found { $_[0]->{found} }
-sub pmc    { $_[0]->{pmc} }
+sub pmc   { $_[0]->{pmc} }
 sub open  { $_[0]->{open} }
 
 {
   package Module::Reader::File;
-  use constant _OPEN_STRING => "$]" >= 5.008 || (require IO::String, 0);
+  use constant _OPEN_STRING => "$]" >= 5.008 || !require IO::String;
   use Carp 'croak';
 
   sub new {
@@ -264,6 +294,7 @@
     $_[0]->{raw_filehandle} ||= !$_[0]->{disk_file} ? undef : do {
       open my $fh, '<'.Module::Reader::_OPEN_LAYERS, $_[0]->{disk_file}
         or croak "Can't locate $_[0]->{disk_file}";
+      $fh;
     };
   }
 
@@ -273,20 +304,22 @@
       if exists $self->{content};
     my $fh = $self->raw_filehandle;
     my $cb = $self->read_callback;
+    my $content = defined $self->{prefix} ? ${$self->{prefix}} : '';
     if ($fh && !$cb) {
       local $/;
-      return scalar <$fh>;
+      $content .= <$fh>;
     }
-    my @params = @{$self->read_callback_options||[]};
-    my $content = '';
-    while (1) {
-      local $_ = $fh ? <$fh> : '';
-      $_ = ''
-        if !defined;
-      # perlfunc/require says that the first parameter will be a reference the
-      # sub itself.  this is wrong.  0 will be passed.
-      last if !$cb->(0, @params);
-      $content .= $_;
+    if ($cb) {
+      my @params = @{$self->read_callback_options||[]};
+      while (1) {
+        local $_ = $fh ? <$fh> : '';
+        $_ = ''
+          if !defined;
+        # perlfunc/require says that the first parameter will be a reference 
the
+        # sub itself.  this is wrong.  0 will be passed.
+        last if !$cb->(0, @params);
+        $content .= $_;
+      }
     }
     return $self->{content} = $content;
   }
@@ -356,7 +389,7 @@
 
 Returns the content of a given module.
 
-=head1 CLASS ATTRIBUTES
+=head1 ATTRIBUTES
 
 =over 4
 
@@ -384,6 +417,19 @@
 A boolean controlling if the files found will be opened immediately when found.
 Defaults to true.
 
+=item abort_on_eacces
+
+A boolean controlling if an error should be thrown or if the path should be
+skipped when encountering C<EACCES> (access denied) errors.  Defaults to true
+on perl 5.18 and above, matching the behavior of L<require|perlfunc/require>.
+
+=item check_hooks_for_nonsearchable
+
+For non-searchable paths (absolute paths and those starting with C<./> or
+C<../>) attempt to check the hook items (and not the directories) in C<@INC> if
+the file cannot be found directly.  This matches the behavior of perl.  
Defaults
+to true.
+
 =back
 
 =head1 METHODS
@@ -421,7 +467,7 @@
 
 =head3 filename
 
-The filename that was seached for.
+The filename that was searched for.
 
 =head3 module
 
@@ -532,7 +578,7 @@
 
 =item L<Module::Locate>
 
-Innacurately searches C<@INC> for matching files.  Attempts to handle hooks, 
but
+Inaccurately searches C<@INC> for matching files.  Attempts to handle hooks, 
but
 handles most cases wrong.
 
 =item L<Module::Mapper>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/maint/Makefile.PL.include 
new/Module-Reader-0.003003/maint/Makefile.PL.include
--- old/Module-Reader-0.003002/maint/Makefile.PL.include        2013-11-24 
12:22:17.000000000 +0100
+++ new/Module-Reader-0.003003/maint/Makefile.PL.include        2017-05-06 
14:05:54.000000000 +0200
@@ -5,3 +5,5 @@
 use ExtUtils::MakeMaker 6.58;
 
 author 'haarg - Graham Knop (cpan:HAARG) <[email protected]>';
+
+manifest_include 't/test-data/lib' => '.pm';
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/t/file-types.t 
new/Module-Reader-0.003003/t/file-types.t
--- old/Module-Reader-0.003002/t/file-types.t   2016-11-30 13:56:06.000000000 
+0100
+++ new/Module-Reader-0.003003/t/file-types.t   2017-04-25 04:13:56.000000000 
+0200
@@ -76,7 +76,7 @@
   for my $type_2 (sort keys %types) {
     my $inc_2 = "$dir/$type_2";
 
-    my $reader = Module::Reader->new(inc => [$inc_1, $inc_2, $fallback], pmc 
=> 0);
+    my $reader = Module::Reader->new(inc => [$inc_1, $inc_2, $fallback], pmc 
=> 0, abort_on_eacces => 1);
     my $found = eval { $reader->module('TestModule') };
 
     my ($want)
@@ -112,15 +112,21 @@
                                        : 'error';
 
     for my $read_opts (
-      ['normal', {inc => [$inc, $fallback], pmc => 1}, 'TestModule.pm'],
+      ['normal', {
+        inc => [$inc, $fallback],
+        pmc => 1,
+        abort_on_eacces => 1,
+      }, 'TestModule.pm'],
       ['found', {
         found => { 'TestModule.pm' => "$inc/TestModule.pm" },
         inc => [$fallback],
         pmc => 1,
+        abort_on_eacces => 1,
       }, 'TestModule.pm'],
       ['relative', {
         inc => [$fallback],
         pmc => 1,
+        abort_on_eacces => 1,
       }, './TestModule.pm', $inc],
     ) {
       my ($name, $opts, $file, $chdir) = @$read_opts;
@@ -128,6 +134,7 @@
         if defined $chdir;
       my $reader = Module::Reader->new(%$opts);
       my $found = eval { $reader->file($file) };
+      my $error = $@;
       my $want = $want eq 'none' && $file =~ /^\./ ? 'error' : $want;
 
       my $got
@@ -136,7 +143,15 @@
         : $found->is_pmc        ? 'pmc'
                                 : 'pm';
 
-      is $got, $want, "$name search of $type with $pmc_type pmc found $want";
+      my $ok = is $got, $want, "$name search of $type with $pmc_type pmc found 
$want";
+      if ($got eq 'error') {
+        if ($ok) {
+          note "Got error: ".$error;
+        }
+        else {
+          diag "Got error: ".$error;
+        }
+      }
       chdir $cwd;
     }
   }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/t/lib/InlineModule.pm 
new/Module-Reader-0.003003/t/lib/InlineModule.pm
--- old/Module-Reader-0.003002/t/lib/InlineModule.pm    1970-01-01 
01:00:00.000000000 +0100
+++ new/Module-Reader-0.003003/t/lib/InlineModule.pm    2017-04-24 
19:21:09.000000000 +0200
@@ -0,0 +1,53 @@
+package InlineModule;
+use strict;
+use warnings;
+
+BEGIN {
+  *_HAS_PERLIO = "$]" >= 5.008_000 ? sub(){1} : sub(){0};
+}
+
+sub import {
+  my ($class, %modules) = @_;
+  unshift @INC, inc_hook(%modules)
+    if %modules;
+}
+
+sub inc_hook {
+  my (%modules) = @_;
+  my %files = map {
+    (my $file = "$_.pm") =~ s{::}{/}g;
+    $file => $modules{$_};
+  } keys %modules;
+
+  sub {
+    return
+      unless exists $files{$_[1]};
+    my $module = $files{$_[1]};
+    if (!defined $module) {
+      die "Can't locate $_[1] in \@INC (hidden) (\@INC contains: @INC).\n";
+    }
+    inc_module($module);
+  }
+}
+
+sub inc_module {
+  my $code = $_[0];
+  if (_HAS_PERLIO) {
+    open my $fh, '<', \$code
+      or die "error loading module: $!";
+    return $fh;
+  }
+  else {
+    my $pos = 0;
+    my $last = length $code;
+    return (sub {
+      return 0 if $pos == $last;
+      my $next = (1 + index $code, "\n", $pos) || $last;
+      $_ .= substr $code, $pos, $next - $pos;
+      $pos = $next;
+      return 1;
+    });
+  }
+}
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/t/lib/TestLib.pm 
new/Module-Reader-0.003003/t/lib/TestLib.pm
--- old/Module-Reader-0.003002/t/lib/TestLib.pm 2016-11-29 09:41:47.000000000 
+0100
+++ new/Module-Reader-0.003003/t/lib/TestLib.pm 1970-01-01 01:00:00.000000000 
+0100
@@ -1,5 +0,0 @@
-package TestLib;
-
-our $FILENAME = __FILE__;
-
-1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/t/main.t 
new/Module-Reader-0.003003/t/main.t
--- old/Module-Reader-0.003002/t/main.t 2016-11-30 14:18:09.000000000 +0100
+++ new/Module-Reader-0.003003/t/main.t 2017-05-06 14:02:50.000000000 +0200
@@ -3,14 +3,14 @@
 
 use Test::More 0.88;
 use Module::Reader qw(:all);
-use lib 't/lib';
+use lib 't/test-data/lib';
 
 my $mod_content = do {
-  open my $fh, '<'.Module::Reader::_OPEN_LAYERS, 't/lib/TestLib.pm';
+  open my $fh, '<'.Module::Reader::_OPEN_LAYERS, 
't/test-data/lib/MyTestModule.pm';
   local $/;
   <$fh>;
 };
 
-is module_content('TestLib'), $mod_content, 'correctly load module from disk';
+is module_content('MyTestModule'), $mod_content, 'correctly load module from 
disk';
 
 done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Module-Reader-0.003002/t/memory.t 
new/Module-Reader-0.003003/t/memory.t
--- old/Module-Reader-0.003002/t/memory.t       2016-11-30 14:39:00.000000000 
+0100
+++ new/Module-Reader-0.003003/t/memory.t       2017-04-24 19:25:20.000000000 
+0200
@@ -4,59 +4,42 @@
 
 use Test::More 0.88;
 use Module::Reader qw(:all);
+use lib 't/lib';
+use InlineModule;
+
 BEGIN {
   *_HAS_PERLIO = "$]" >= 5.008_000 ? sub(){1} : sub(){0};
 }
 
 my $mod_content = do {
-  open my $fh, '<', 't/lib/TestLib.pm';
+  open my $fh, (_HAS_PERLIO ? '<:' : '<'), 't/test-data/lib/MyTestModule.pm';
   local $/;
   <$fh>;
 };
 
-sub inc_module {
-  my $code = $_[0];
-  if (_HAS_PERLIO) {
-    open my $fh, '<', \$code
-      or die "error loading module: $!";
-    return $fh;
-  }
-  else {
-    my $pos = 0;
-    my $last = length $code;
-    return (sub {
-      return 0 if $pos == $last;
-      my $next = (1 + index $code, "\n", $pos) || $last;
-      $_ .= substr $code, $pos, $next - $pos;
-      $pos = $next;
-      return 1;
-    });
-  }
-}
-
 {
   local @INC = (
-    sub { return inc_module($mod_content) if $_[1] eq 'TestLib.pm' },
+    InlineModule::inc_hook('MyTestModule' => $mod_content),
     @INC,
   );
-  is module_content('TestLib'), $mod_content,
+  is module_content('MyTestModule'), $mod_content,
     'correctly load module from sub @INC hook';
-  require TestLib;
+  require MyTestModule;
   SKIP: {
     skip 'found option doesn\'t work with @INC hooks in perl < 5.8', 2
       if "$]" < 5.008;
     local @INC = @INC;
     my $content = '1;';
-    unshift @INC, sub { return unless $_[1] eq 'TestLib.pm'; 
inc_module($content) };
-    is module_content('TestLib'), '1;',
+    unshift @INC, InlineModule::inc_hook( MyTestModule => $content );
+    is module_content('MyTestModule'), '1;',
       'loads overridden module from sub @INC hook';
-    is module_content('TestLib', { found => \%INC } ), $mod_content,
+    is module_content('MyTestModule', { found => \%INC } ), $mod_content,
       'found => \%INC loads mod as it was required';
   }
   {
     local $TODO = "unable to accurately calculate fake filename on perl 5.6"
       if "$]" < 5.008;
-    is +Module::Reader->new->module('TestLib')->found_file, $TestLib::FILENAME,
+    is +Module::Reader->new->module('MyTestModule')->found_file, 
$MyTestModule::FILENAME,
       'calculated file matches loaded filename';
   }
 }
@@ -67,14 +50,14 @@
 @ChildHook::ISA = qw(ParentHook);
 
 {
-  my $base_hook = sub { return unless $_[1] eq 'TestLib.pm'; 
inc_module($mod_content) };
+  my $base_hook = InlineModule::inc_hook( MyTestModule => $mod_content );
   for my $fake_hook (
     ['hook returning an array ref' => sub { return [] }],
     ['hook returning a hash ref' => sub { return {} }],
   ) {
     my $name = $fake_hook->[0];
     my @inc = ($fake_hook->[1], $base_hook);
-    is module_content('TestLib', { inc => \@inc }), $mod_content,
+    is module_content('MyTestModule', { inc => \@inc }), $mod_content,
       "$name is ignored";
   }
 }
@@ -98,7 +81,7 @@
     ['array ref with hash ref'  => [{}]],
     ['array ref with code'      => [sub { return }]],
   ) {
-    my $class = 'TestLib'.++$uniq;
+    my $class = 'MyTestModule'.++$uniq;
     my $name = $hook->[0];
     my @inc = ($hook->[1], sub { return unless $_[1] eq "$class.pm"; 
inc_module($mod_content) });
     eval {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/Module-Reader-0.003002/t/test-data/lib/MyTestModule.pm 
new/Module-Reader-0.003003/t/test-data/lib/MyTestModule.pm
--- old/Module-Reader-0.003002/t/test-data/lib/MyTestModule.pm  1970-01-01 
01:00:00.000000000 +0100
+++ new/Module-Reader-0.003003/t/test-data/lib/MyTestModule.pm  2017-04-24 
19:15:43.000000000 +0200
@@ -0,0 +1,5 @@
+package MyTestModule;
+
+our $FILENAME = __FILE__;
+
+1;


Reply via email to