Hello community,
here is the log from the commit of package perl-File-ShareDir for openSUSE:Factory checked in at 2018-06-18 13:50:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-File-ShareDir (Old)
and /work/SRC/openSUSE:Factory/.perl-File-ShareDir.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-File-ShareDir"
Mon Jun 18 13:50:19 2018 rev:12 rq:617441 version:1.108
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-File-ShareDir/perl-File-ShareDir.changes 2017-07-04 11:55:37.492753312 +0200
+++ /work/SRC/openSUSE:Factory/.perl-File-ShareDir.new/perl-File-ShareDir.changes 2018-06-18 13:50:22.517045500 +0200
@@ -1,0 +2,38 @@
+Sat Jun 16 05:26:17 UTC 2018 - coolo@suse.com
+
+- updated to 1.108
+ see /usr/share/doc/packages/perl-File-ShareDir/Changes
+
+ 1.108 2018-06-15
+ - Fix RT#125582: Undefined subroutine &File::ShareDir::croak
+ called reported by yseto and Andreas Koenig (via RT#125575)
+ - Improve tests a little (a higher test coverage would be great)
+ - Update README.md
+
+-------------------------------------------------------------------
+Mon Jun 11 05:26:11 UTC 2018 - coolo@suse.com
+
+- updated to 1.106
+ see /usr/share/doc/packages/perl-File-ShareDir/Changes
+
+ 1.106 2018-06-10
+ - Add support for overriding the resolved path for a given
+ Module or Dist (Thanks to Kent Fredric )
+ - Fix RT#84914: _dist_file_new lacks return check (Thanks to
+ Alex Peters ) -- fixes RT#40158, too.
+ - Fix RT#60431: common @INC traversal code
+ Phillip Moore requested for
+ easier overriding in controlled environments an extraction
+ of @INC traversal in one subroutine.
+ The provided patch has been applied with minor modifications,
+ thanks Phillip!
+ - Fix RT#63548: State explicit how developers can use
+ File::ShareDir even in development phase out-of-the-box
+ - Fix RT#18042: Windows style path errors (Thanks to Barbie
+ )
+ - Improve infrastructure of distribution (toolchain, perltidy,
+ perlcritic, Devel::Cover, ...)
+ - deploy with most recent File::ShareDir::Install (v0.12-6-g29a6ff7
+ aka 0.13)
+
+-------------------------------------------------------------------
Old:
----
File-ShareDir-1.104.tar.gz
New:
----
File-ShareDir-1.108.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-File-ShareDir.spec ++++++
--- /var/tmp/diff_new_pack.vQ0wLG/_old 2018-06-18 13:50:23.553007208 +0200
+++ /var/tmp/diff_new_pack.vQ0wLG/_new 2018-06-18 13:50:23.557007060 +0200
@@ -1,7 +1,7 @@
#
# spec file for package perl-File-ShareDir
#
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 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,11 +17,11 @@
Name: perl-File-ShareDir
-Version: 1.104
+Version: 1.108
Release: 0
%define cpan_name File-ShareDir
Summary: Locate per-dist and per-module shared files
-License: Artistic-1.0 or GPL-1.0+
+License: Artistic-1.0 OR GPL-1.0-or-later
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/File-ShareDir/
Source0: https://cpan.metacpan.org/authors/id/R/RE/REHSACK/%{cpan_name}-%{version}.tar.gz
@@ -33,6 +33,7 @@
BuildRequires: perl(Class::Inspector) >= 1.12
BuildRequires: perl(Test::More) >= 0.9
Requires: perl(Class::Inspector) >= 1.12
+Recommends: perl(Params::Util) >= 1.07
%{perl_requires}
%description
++++++ File-ShareDir-1.104.tar.gz -> File-ShareDir-1.108.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/Changes new/File-ShareDir-1.108/Changes
--- old/File-ShareDir-1.104/Changes 2017-06-29 15:38:00.000000000 +0200
+++ new/File-ShareDir-1.108/Changes 2018-06-15 15:29:55.000000000 +0200
@@ -1,5 +1,31 @@
Revision history for Perl extension File-ShareDir
+1.108 2018-06-15
+ - Fix RT#125582: Undefined subroutine &File::ShareDir::croak
+ called reported by yseto and Andreas Koenig (via RT#125575)
+ - Improve tests a little (a higher test coverage would be great)
+ - Update README.md
+
+1.106 2018-06-10
+ - Add support for overriding the resolved path for a given
+ Module or Dist (Thanks to Kent Fredric )
+ - Fix RT#84914: _dist_file_new lacks return check (Thanks to
+ Alex Peters ) -- fixes RT#40158, too.
+ - Fix RT#60431: common @INC traversal code
+ Phillip Moore requested for
+ easier overriding in controlled environments an extraction
+ of @INC traversal in one subroutine.
+ The provided patch has been applied with minor modifications,
+ thanks Phillip!
+ - Fix RT#63548: State explicit how developers can use
+ File::ShareDir even in development phase out-of-the-box
+ - Fix RT#18042: Windows style path errors (Thanks to Barbie
+ )
+ - Improve infrastructure of distribution (toolchain, perltidy,
+ perlcritic, Devel::Cover, ...)
+ - deploy with most recent File::ShareDir::Install (v0.12-6-g29a6ff7
+ aka 0.13)
+
1.104 2017-06-29
- Fix RT#120833: Fails tests when no "." in @INC reported by Kent
Fredric .
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/MANIFEST new/File-ShareDir-1.108/MANIFEST
--- old/File-ShareDir-1.104/MANIFEST 2017-06-29 15:40:45.000000000 +0200
+++ new/File-ShareDir-1.108/MANIFEST 2018-06-15 15:31:14.000000000 +0200
@@ -7,11 +7,15 @@
LICENSE
Makefile.PL
MANIFEST
+MANIFEST.SKIP
README.md
share/sample.txt
share/subdir/sample.txt
t/01_compile.t
t/02_main.t
-t/lib/ShareDir.pm
+t/03_extensions.t
+t/04_fail.t
+t/05_class.t
+t/lib/ShareDir/TestClass.pm
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/MANIFEST.SKIP new/File-ShareDir-1.108/MANIFEST.SKIP
--- old/File-ShareDir-1.104/MANIFEST.SKIP 1970-01-01 01:00:00.000000000 +0100
+++ new/File-ShareDir-1.108/MANIFEST.SKIP 2018-06-10 13:02:05.000000000 +0200
@@ -0,0 +1,35 @@
+\B\.svn\b
+\B\.git\b
+\.gitignore$
+\.[Bb][Aa][Kk]$
+\.orig$
+\.old$
+\.tdy$
+\.tmp$
+\..*swp
+^Makefile$
+^Build$
+^Build\.bat$
+\.Inline/.*
+_Inline/.*
+\.bak$
+\.tar$
+\.tgz$
+\.tar\.gz$
+^mess/
+^tmp/
+^testdata/
+^blib/
+^sandbox/
+^pm_to_blib$
+^cover_db/
+nytprof*/
+nytprof.out
+^_build/.*
+~$
+.*\.planner
+^\..*
+^File-ShareDir-.*
+\bxt
+^MYMETA\.json$
+^MYMETA\..*$
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/META.json new/File-ShareDir-1.108/META.json
--- old/File-ShareDir-1.104/META.json 2017-06-29 15:40:45.000000000 +0200
+++ new/File-ShareDir-1.108/META.json 2018-06-15 15:31:14.000000000 +0200
@@ -4,13 +4,13 @@
"Adam Kennedy "
],
"dynamic_config" : 1,
- "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010",
+ "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
- "version" : "2"
+ "version" : 2
},
"name" : "File-ShareDir",
"no_index" : {
@@ -39,15 +39,23 @@
"develop" : {
"requires" : {
"File::ShareDir::Install" : "0.08",
+ "Module::CPANTS::Analyse" : "0.96",
"Test::CPAN::Changes" : "0",
"Test::CheckManifest" : "0",
+ "Test::Kwalitee" : "0",
+ "Test::Perl::Critic" : "0",
+ "Test::PerlTidy" : "0",
"Test::Pod" : "0",
"Test::Pod::Coverage" : "0",
"Test::Pod::Spelling::CommonMistakes" : "0",
+ "Test::Spelling" : "0",
"inc::latest" : "0.500"
}
},
"runtime" : {
+ "recommends" : {
+ "Params::Util" : "1.07"
+ },
"requires" : {
"Carp" : "0",
"Class::Inspector" : "1.12",
@@ -73,6 +81,6 @@
"web" : "https://github.com/perl5-utils/File-ShareDir"
}
},
- "version" : "1.104",
- "x_serialization_backend" : "JSON::PP version 2.27400_02"
+ "version" : "1.108",
+ "x_serialization_backend" : "JSON::PP version 2.97001"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/META.yml new/File-ShareDir-1.108/META.yml
--- old/File-ShareDir-1.104/META.yml 2017-06-29 15:40:45.000000000 +0200
+++ new/File-ShareDir-1.108/META.yml 2018-06-15 15:31:14.000000000 +0200
@@ -10,7 +10,7 @@
ExtUtils::MakeMaker: '0'
File::ShareDir::Install: '0.03'
dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010'
+generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -20,6 +20,8 @@
directory:
- t
- inc
+recommends:
+ Params::Util: '1.07'
requires:
Carp: '0'
Class::Inspector: '1.12'
@@ -29,5 +31,5 @@
bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=File-ShareDir
homepage: https://metacpan.org/release/File-ShareDir
repository: https://github.com/perl5-utils/File-ShareDir
-version: '1.104'
+version: '1.108'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/Makefile.PL new/File-ShareDir-1.108/Makefile.PL
--- old/File-ShareDir-1.104/Makefile.PL 2017-04-06 16:41:31.000000000 +0200
+++ new/File-ShareDir-1.108/Makefile.PL 2018-06-10 14:15:21.000000000 +0200
@@ -67,9 +67,14 @@
requires => {
'Test::CPAN::Changes' => 0,
'Test::CheckManifest' => 0,
+ 'Module::CPANTS::Analyse' => '0.96',
+ 'Test::Kwalitee' => 0,
+ 'Test::Perl::Critic' => 0,
+ 'Test::PerlTidy' => 0,
'Test::Pod' => 0,
'Test::Pod::Coverage' => 0,
'Test::Pod::Spelling::CommonMistakes' => 0,
+ 'Test::Spelling' => 0,
%BUNDLE_CONFIGURE_DEPS,
},
},
@@ -80,7 +85,8 @@
build => {requires => {%BUILD_DEPS}},
test => {requires => {%TEST_DEPS}},
runtime => {
- requires => {%RUN_DEPS},
+ requires => {%RUN_DEPS},
+ recommends => {'Params::Util' => '1.07'},
},
},
},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/README.md new/File-ShareDir-1.108/README.md
--- old/File-ShareDir-1.104/README.md 2017-06-29 15:38:00.000000000 +0200
+++ new/File-ShareDir-1.108/README.md 2018-06-15 15:25:52.000000000 +0200
@@ -71,9 +71,13 @@
you can use `File::ShareDir` to find your files again after
the installation.
-For the installation half of the solution, see [Module::Install](https://metacpan.org/pod/Module::Install)
+For the installation half of the solution, see [File::ShareDir::Install](https://metacpan.org/pod/File::ShareDir::Install)
and its `install_share` directive.
+Using [File::ShareDir::Install](https://metacpan.org/pod/File::ShareDir::Install) together with [File::ShareDir](https://metacpan.org/pod/File::ShareDir)
+allows one to rely on the files in appropriate `dist_dir()`
+or `module_dir()` in development phase, too.
+
# FUNCTIONS
`File::ShareDir` provides four functions for locating files and
@@ -131,8 +135,8 @@
# Find a file in our distribution shared dir
my $dir = dist_file('My-Distribution', 'file/name.txt');
-The `dist_file` function takes two params of the distribution name
-and file name, locates the dist dir, and then finds the file within
+The `dist_file` function takes two parameters of the distribution name
+and file name, locates the dist directory, and then finds the file within
it, verifying that the file actually exists, and that it is readable.
The filename should be a relative path in the format of your local
@@ -147,9 +151,9 @@
# Find a file in our module shared dir
my $dir = module_file('My::Module', 'file/name.txt');
-The `module_file` function takes two params of the module name
-and file name. It locates the module dir, and then finds the file within
-it, verifying that the file actually exists, and that it is readable.
+The `module_file` function takes two parameters of the module name
+and file name. It locates the module directory, and then finds the file
+within it, verifying that the file actually exists, and that it is readable.
In order to find the directory, the module **must** be loaded when
calling this function.
@@ -166,9 +170,9 @@
# Find a file in our module shared dir, or in our parent class
my $dir = class_file('My::Module', 'file/name.txt');
-The `module_file` function takes two params of the module name
-and file name. It locates the module dir, and then finds the file within
-it, verifying that the file actually exists, and that it is readable.
+The `module_file` function takes two parameters of the module name
+and file name. It locates the module directory, and then finds the file
+within it, verifying that the file actually exists, and that it is readable.
In order to find the directory, the module **must** be loaded when
calling this function.
@@ -186,6 +190,49 @@
Returns the file path as a string, or dies if the file or the dist's
directory cannot be located, or the file is not readable.
+# EXTENDING
+
+## Overriding Directory Resolution
+
+`File::ShareDir` has two convenience hashes for people who have advanced usage
+requirements of `File::ShareDir` such as using uninstalled `share`
+directories during development.
+
+ #
+ # Dist-Name => /absolute/path/for/DistName/share/dir
+ #
+ %File::ShareDir::DIST_SHARE
+
+ #
+ # Module::Name => /absolute/path/for/Module/Name/share/dir
+ #
+ %File::ShareDir::MODULE_SHARE
+
+Setting these values any time before the corresponding calls
+
+ dist_dir('Dist-Name')
+ dist_file('Dist-Name','some/file');
+
+ module_dir('Module::Name');
+ module_file('Module::Name','some/file');
+
+Will override the base directory for resolving those calls.
+
+An example of where this would be useful is in a test for a module that
+depends on files installed into a share directory, to enable the tests
+to use the development copy without needing to install them first.
+
+ use File::ShareDir;
+ use Cwd qw( getcwd );
+ use File::Spec::Functions qw( rel2abs catdir );
+
+ $File::ShareDir::MODULE_SHARE{'Foo::Module'} = rel2abs(catfile(getcwd,'share'));
+
+ use Foo::Module;
+
+ # interal calls in Foo::Module to module_file('Foo::Module','bar') now resolves to
+ # the source trees share/ directory instead of something in @INC
+
# SUPPORT
Bugs should always be submitted via the CPAN bug tracker
@@ -196,7 +243,7 @@
# AUTHOR
-Adam Kennedy <adamk@cpan.org>
+Adam Kennedy
# SEE ALSO
@@ -206,7 +253,8 @@
# COPYRIGHT
-Copyright 2005 - 2011 Adam Kennedy.
+Copyright 2005 - 2011 Adam Kennedy,
+Copyright 2014 - 2018 Jens Rehsack.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/inc/inc_File-ShareDir-Install/File/ShareDir/Install.pm new/File-ShareDir-1.108/inc/inc_File-ShareDir-Install/File/ShareDir/Install.pm
--- old/File-ShareDir-1.104/inc/inc_File-ShareDir-Install/File/ShareDir/Install.pm 2017-04-06 16:45:40.000000000 +0200
+++ new/File-ShareDir-1.108/inc/inc_File-ShareDir-Install/File/ShareDir/Install.pm 2018-06-15 09:53:34.000000000 +0200
@@ -1,16 +1,15 @@
-package File::ShareDir::Install; # git description: v0.10-8-gf7e9d47
+package File::ShareDir::Install; # git description: v0.12-6-g29a6ff7
# ABSTRACT: Install shared files
-use 5.008;
use strict;
use warnings;
-use Carp;
+use Carp ();
use File::Spec;
use IO::Dir;
-our $VERSION = '0.11';
+our $VERSION = '0.13';
our @DIRS;
our %ALREADY;
@@ -30,11 +29,11 @@
my $type = @_ ? shift : 'dist';
unless ( defined $type and
( $type =~ /^(module|dist)$/ ) ) {
- confess "Illegal or invalid share dir type '$type'";
+ Carp::confess "Illegal or invalid share dir type '$type'";
}
if( $type eq 'dist' and @_ ) {
- confess "Too many parameters to install_share";
+ Carp::confess "Too many parameters to install_share";
}
my $def = _mk_def( $type );
@@ -51,11 +50,11 @@
my $type = @_ ? shift : 'dist';
unless ( defined $type and
( $type =~ /^(module|dist)$/ ) ) {
- confess "Illegal or invalid share dir type '$type'";
+ Carp::confess "Illegal or invalid share dir type '$type'";
}
if( $type eq 'dist' and @_ ) {
- confess "Too many parameters to delete_share";
+ Carp::confess "Too many parameters to delete_share";
}
my $def = _mk_def( "delete-$type" );
@@ -84,7 +83,7 @@
if( $def->{type} =~ /module$/ ) {
my $module = _CLASS( $class );
unless ( defined $module ) {
- confess "Missing or invalid module name '$_[0]'";
+ Carp::confess "Missing or invalid module name '$_[0]'";
}
$def->{module} = $module;
}
@@ -104,10 +103,10 @@
foreach my $d ( @$dir ) {
unless ( $del or (defined $d and -d $d) ) {
- confess "Illegal or missing directory '$d'";
+ Carp::confess "Illegal or missing directory '$d'";
}
if( not $del and $ALREADY{ $d }++ ) {
- confess "Directory '$d' is already being installed";
+ Carp::confess "Directory '$d' is already being installed";
}
push @DIRS, { %$def };
$DIRS[-1]{dir} = $d;
@@ -162,7 +161,8 @@
my $files = {};
_scan_share_dir( $files, $idir, $dir, $def );
- @cmds = $self->split_command( $pm_to_blib, %$files );
+ @cmds = $self->split_command( $pm_to_blib,
+ map { ($self->quote_literal($_) => $self->quote_literal($files->{$_})) } sort keys %$files );
}
my $r = join '', map { "\t\$(NOECHO) $_\n" } @cmds;
@@ -248,7 +248,7 @@
=head1 VERSION
-version 0.11
+version 0.13
=head1 SYNOPSIS
@@ -407,12 +407,22 @@
Philip Gwyn
-=head1 CONTRIBUTOR
+=head1 CONTRIBUTORS
-=for stopwords Karen Etheridge
+=for stopwords Karen Etheridge Shoichi Kaji
+
+=over 4
+
+=item *
Karen Etheridge
+=item *
+
+Shoichi Kaji
+
+=back
+
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2009 by Philip Gwyn.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/lib/File/ShareDir.pm new/File-ShareDir-1.108/lib/File/ShareDir.pm
--- old/File-ShareDir-1.104/lib/File/ShareDir.pm 2017-04-06 18:13:03.000000000 +0200
+++ new/File-ShareDir-1.108/lib/File/ShareDir.pm 2018-06-15 15:25:38.000000000 +0200
@@ -75,9 +75,13 @@
you can use CFile::ShareDir to find your files again after
the installation.
-For the installation half of the solution, see LModule::Install
+For the installation half of the solution, see LFile::ShareDir::Install
and its C directive.
+Using LFile::ShareDir::Install together with LFile::ShareDir
+allows one to rely on the files in appropriate C
+or C in development phase, too.
+
=head1 FUNCTIONS
CFile::ShareDir provides four functions for locating files and
@@ -109,34 +113,31 @@
use strict;
use warnings;
+use base ('Exporter');
+use constant IS_MACOS => !!($^O eq 'MacOS');
+use constant IS_WIN32 => !!($^O eq 'MSWin32');
+
use Carp ();
-use Config ();
use Exporter ();
use File::Spec ();
use Class::Inspector ();
-use vars qw{ $VERSION @ISA @EXPORT_OK %EXPORT_TAGS };
-BEGIN {
- $VERSION = '1.104';
- @ISA = qw{ Exporter };
- @EXPORT_OK = qw{
- dist_dir
- dist_file
- module_dir
- module_file
- class_dir
- class_file
- };
- %EXPORT_TAGS = (
- ALL => [ @EXPORT_OK ],
- );
-}
-
-use constant IS_MACOS => !! ($^O eq 'MacOS');
-
-
-
+our %DIST_SHARE;
+our %MODULE_SHARE;
+our @CARP_NOT;
+our @EXPORT_OK = qw{
+ dist_dir
+ dist_file
+ module_dir
+ module_file
+ class_dir
+ class_file
+};
+our %EXPORT_TAGS = (
+ ALL => [@EXPORT_OK],
+);
+our $VERSION = '1.108';
#####################################################################
# Interface Functions
@@ -157,64 +158,45 @@
=cut
-sub dist_dir {
- my $dist = _DIST(shift);
- my $dir;
-
- # Try the new version
- $dir = _dist_dir_new( $dist );
- return $dir if defined $dir;
-
- # Fall back to the legacy version
- $dir = _dist_dir_old( $dist );
- return $dir if defined $dir;
-
- # Ran out of options
- Carp::croak("Failed to find share dir for dist '$dist'");
-}
-
-sub _dist_dir_new {
- my $dist = shift;
-
- # Create the subpath
- my $path = File::Spec->catdir(
- 'auto', 'share', 'dist', $dist,
- );
-
- # Find the full dir withing @INC
- foreach my $inc ( @INC ) {
- next unless defined $inc and ! ref $inc;
- my $dir = File::Spec->catdir( $inc, $path );
- next unless -d $dir;
- unless ( -r $dir ) {
- Carp::croak("Found directory '$dir', but no read permissions");
- }
- return $dir;
- }
-
- return undef;
-}
-
-sub _dist_dir_old {
- my $dist = shift;
-
- # Create the subpath
- my $path = File::Spec->catdir(
- 'auto', split( /-/, $dist ),
- );
-
- # Find the full dir within @INC
- foreach my $inc ( @INC ) {
- next unless defined $inc and ! ref $inc;
- my $dir = File::Spec->catdir( $inc, $path );
- next unless -d $dir;
- unless ( -r $dir ) {
- Carp::croak("Found directory '$dir', but no read permissions");
- }
- return $dir;
- }
+sub dist_dir
+{
+ my $dist = _DIST(shift);
+ my $dir;
+
+ # Try the new version
+ $dir = _dist_dir_new($dist);
+ return $dir if defined $dir;
+
+ # Fall back to the legacy version
+ $dir = _dist_dir_old($dist);
+ return $dir if defined $dir;
+
+ # Ran out of options
+ Carp::croak("Failed to find share dir for dist '$dist'");
+}
+
+sub _dist_dir_new
+{
+ my $dist = shift;
+
+ return $DIST_SHARE{$dist} if exists $DIST_SHARE{$dist};
- return undef;
+ # Create the subpath
+ my $path = File::Spec->catdir('auto', 'share', 'dist', $dist,);
+
+ # Find the full dir withing @INC
+ return _search_inc_path($path);
+}
+
+sub _dist_dir_old
+{
+ my $dist = shift;
+
+ # Create the subpath
+ my $path = File::Spec->catdir('auto', split(/-/, $dist),);
+
+ # Find the full dir within @INC
+ return _search_inc_path($path);
}
=pod
@@ -236,56 +218,54 @@
=cut
-sub module_dir {
- my $module = _MODULE(shift);
- my $dir;
-
- # Try the new version
- $dir = _module_dir_new( $module );
- return $dir if defined $dir;
-
- # Fall back to the legacy version
- return _module_dir_old( $module );
-}
-
-sub _module_dir_new {
- my $module = shift;
-
- # Create the subpath
- my $path = File::Spec->catdir(
- 'auto', 'share', 'module',
- _module_subdir( $module ),
- );
-
- # Find the full dir withing @INC
- foreach my $inc ( @INC ) {
- next unless defined $inc and ! ref $inc;
- my $dir = File::Spec->catdir( $inc, $path );
- next unless -d $dir;
- unless ( -r $dir ) {
- Carp::croak("Found directory '$dir', but no read permissions");
- }
- return $dir;
- }
-
- return undef;
-}
-
-sub _module_dir_old {
- my $module = shift;
- my $short = Class::Inspector->filename($module);
- my $long = Class::Inspector->loaded_filename($module);
- $short =~ tr{/}{:} if IS_MACOS;
- substr( $short, -3, 3, '' );
- $long =~ m/^(.*)\Q$short\E\.pm\z/s or die("Failed to find base dir");
- my $dir = File::Spec->catdir( "$1", 'auto', $short );
- unless ( -d $dir ) {
- Carp::croak("Directory '$dir', does not exist");
- }
- unless ( -r $dir ) {
- Carp::croak("Directory '$dir', no read permissions");
- }
- return $dir;
+sub module_dir
+{
+ my $module = _MODULE(shift);
+
+ return $MODULE_SHARE{$module} if exists $MODULE_SHARE{$module};
+
+ my $dir;
+
+ # Try the new version
+ $dir = _module_dir_new($module);
+ return $dir if defined $dir;
+
+ # Fall back to the legacy version
+ return _module_dir_old($module);
+}
+
+sub _module_dir_new
+{
+ my $module = shift;
+
+ # Create the subpath
+ my $path = File::Spec->catdir('auto', 'share', 'module', _module_subdir($module),);
+
+ # Find the full dir withing @INC
+ return _search_inc_path($path);
+}
+
+sub _module_dir_old
+{
+ my $module = shift;
+ my $short = Class::Inspector->filename($module);
+ my $long = Class::Inspector->loaded_filename($module);
+ $short =~ tr{/}{:} if IS_MACOS;
+ $short =~ tr{\\} {/} if IS_WIN32;
+ $long =~ tr{\\} {/} if IS_WIN32;
+ substr($short, -3, 3, '');
+ $long =~ m/^(.*)\Q$short\E\.pm\z/s or Carp::croak("Failed to find base dir");
+ my $dir = File::Spec->catdir("$1", 'auto', $short);
+
+ unless (-d $dir)
+ {
+ Carp::croak("Directory '$dir', does not exist");
+ }
+ unless (-r $dir)
+ {
+ Carp::croak("Directory '$dir', no read permissions");
+ }
+ return $dir;
}
=pod
@@ -295,8 +275,8 @@
# Find a file in our distribution shared dir
my $dir = dist_file('My-Distribution', 'file/name.txt');
-The C function takes two params of the distribution name
-and file name, locates the dist dir, and then finds the file within
+The C function takes two parameters of the distribution name
+and file name, locates the dist directory, and then finds the file within
it, verifying that the file actually exists, and that it is readable.
The filename should be a relative path in the format of your local
@@ -308,60 +288,54 @@
=cut
-sub dist_file {
- my $dist = _DIST(shift);
- my $file = _FILE(shift);
-
- # Try the new version first
- my $path = _dist_file_new( $dist, $file );
- return $path if defined $path;
-
- # Hand off to the legacy version
- return _dist_file_old( $dist, $file );;
-}
-
-sub _dist_file_new {
- my $dist = shift;
- my $file = shift;
-
- # If it exists, what should the path be
- my $dir = _dist_dir_new( $dist );
- my $path = File::Spec->catfile( $dir, $file );
-
- # Does the file exist
- return undef unless -e $path;
- unless ( -f $path ) {
- Carp::croak("Found dist_file '$path', but not a file");
- }
- unless ( -r $path ) {
- Carp::croak("File '$path', no read permissions");
- }
-
- return $path;
-}
-
-sub _dist_file_old {
- my $dist = shift;
- my $file = shift;
-
- # Create the subpath
- my $path = File::Spec->catfile(
- 'auto', split( /-/, $dist ), $file,
- );
-
- # Find the full dir withing @INC
- foreach my $inc ( @INC ) {
- next unless defined $inc and ! ref $inc;
- my $full = File::Spec->catdir( $inc, $path );
- next unless -e $full;
- unless ( -r $full ) {
- Carp::croak("Directory '$full', no read permissions");
- }
- return $full;
- }
-
- # Couldn't find it
- Carp::croak("Failed to find shared file '$file' for dist '$dist'");
+sub dist_file
+{
+ my $dist = _DIST(shift);
+ my $file = _FILE(shift);
+
+ # Try the new version first
+ my $path = _dist_file_new($dist, $file);
+ return $path if defined $path;
+
+ # Hand off to the legacy version
+ return _dist_file_old($dist, $file);
+}
+
+sub _dist_file_new
+{
+ my $dist = shift;
+ my $file = shift;
+
+ # If it exists, what should the path be
+ my $dir = _dist_dir_new($dist);
+ return undef unless defined $dir;
+ my $path = File::Spec->catfile($dir, $file);
+
+ # Does the file exist
+ return undef unless -e $path;
+ unless (-f $path)
+ {
+ Carp::croak("Found dist_file '$path', but not a file");
+ }
+ unless (-r $path)
+ {
+ Carp::croak("File '$path', no read permissions");
+ }
+
+ return $path;
+}
+
+sub _dist_file_old
+{
+ my $dist = shift;
+ my $file = shift;
+
+ # Create the subpath
+ my $path = File::Spec->catfile('auto', split(/-/, $dist), $file,);
+
+ # Find the full dir withing @INC
+ return _search_inc_path($path)
+ || Carp::croak("Failed to find shared file '$file' for dist '$dist'");
}
=pod
@@ -371,9 +345,9 @@
# Find a file in our module shared dir
my $dir = module_file('My::Module', 'file/name.txt');
-The C function takes two params of the module name
-and file name. It locates the module dir, and then finds the file within
-it, verifying that the file actually exists, and that it is readable.
+The C function takes two parameters of the module name
+and file name. It locates the module directory, and then finds the file
+within it, verifying that the file actually exists, and that it is readable.
In order to find the directory, the module B<must> be loaded when
calling this function.
@@ -387,18 +361,21 @@
=cut
-sub module_file {
- my $module = _MODULE(shift);
- my $file = _FILE(shift);
- my $dir = module_dir($module);
- my $path = File::Spec->catfile($dir, $file);
- unless ( -e $path ) {
- Carp::croak("File '$file' does not exist in module dir");
- }
- unless ( -r $path ) {
- Carp::croak("File '$file' cannot be read, no read permissions");
- }
- $path;
+sub module_file
+{
+ my $module = _MODULE(shift);
+ my $file = _FILE(shift);
+ my $dir = module_dir($module);
+ my $path = File::Spec->catfile($dir, $file);
+ unless (-e $path)
+ {
+ Carp::croak("File '$file' does not exist in module dir");
+ }
+ unless (-r $path)
+ {
+ Carp::croak("File '$file' cannot be read, no read permissions");
+ }
+ return $path;
}
=pod
@@ -408,9 +385,9 @@
# Find a file in our module shared dir, or in our parent class
my $dir = class_file('My::Module', 'file/name.txt');
-The C function takes two params of the module name
-and file name. It locates the module dir, and then finds the file within
-it, verifying that the file actually exists, and that it is readable.
+The C function takes two parameters of the module name
+and file name. It locates the module directory, and then finds the file
+within it, verifying that the file actually exists, and that it is readable.
In order to find the directory, the module B<must> be loaded when
calling this function.
@@ -430,123 +407,191 @@
=cut
-sub class_file {
- my $module = _MODULE(shift);
- my $file = _FILE(shift);
-
- # Get the super path ( not including UNIVERSAL )
- # Rather than using Class::ISA, we'll use an inlined version
- # that implements the same basic algorithm.
- my @path = ();
- my @queue = ( $module );
- my %seen = ( $module => 1 );
- while ( my $cl = shift @queue ) {
- push @path, $cl;
- no strict 'refs';
- unshift @queue, grep { ! $seen{$_}++ }
- map { s/^::/main::/; s/\'/::/g; $_ }
- ( @{"${cl}::ISA"} );
- }
-
- # Search up the path
- foreach my $class ( @path ) {
- local $@;
- my $dir = eval {
- module_dir($class);
- };
- next if $@;
- my $path = File::Spec->catfile($dir, $file);
- unless ( -e $path ) {
- next;
- }
- unless ( -r $path ) {
- Carp::croak("File '$file' cannot be read, no read permissions");
- }
- return $path;
- }
- Carp::croak("File '$file' does not exist in class or parent shared files");
+sub class_file
+{
+ my $module = _MODULE(shift);
+ my $file = _FILE(shift);
+
+ # Get the super path ( not including UNIVERSAL )
+ # Rather than using Class::ISA, we'll use an inlined version
+ # that implements the same basic algorithm.
+ my @path = ();
+ my @queue = ($module);
+ my %seen = ($module => 1);
+ while (my $cl = shift @queue)
+ {
+ push @path, $cl;
+ no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict)
+ unshift @queue, grep { !$seen{$_}++ }
+ map { my $s = $_; $s =~ s/^::/main::/; $s =~ s/\'/::/g; $s } (@{"${cl}::ISA"});
+ }
+
+ # Search up the path
+ foreach my $class (@path)
+ {
+ my $dir = eval { module_dir($class); };
+ next if $@;
+ my $path = File::Spec->catfile($dir, $file);
+ -e $path or next;
+ -r $path or Carp::croak("File '$file' cannot be read, no read permissions");
+ return $path;
+ }
+ Carp::croak("File '$file' does not exist in class or parent shared files");
}
+#####################################################################
+# Support Functions
+sub _search_inc_path
+{
+ my $path = shift;
-#####################################################################
-# Support Functions
+ # Find the full dir within @INC
+ foreach my $inc (@INC)
+ {
+ defined $inc or next;
+ ref $inc and next;
-sub _module_subdir {
- my $module = shift;
- $module =~ s/::/-/g;
- return $module;
-}
-
-sub _dist_packfile {
- my $module = shift;
- my @dirs = grep { -e } ( $Config::Config{archlibexp}, $Config::Config{sitearchexp} );
- my $file = File::Spec->catfile(
- 'auto', split( /::/, $module), '.packlist',
- );
-
- foreach my $dir ( @dirs ) {
- my $path = File::Spec->catfile( $dir, $file );
- next unless -f $path;
-
- # Load the file
- my $packlist = ExtUtils::Packlist->new($path);
- unless ( $packlist ) {
- die "Failed to load .packlist file for $module";
- }
+ my $dir = File::Spec->catdir($inc, $path);
+ next unless -d $dir;
- die "CODE INCOMPLETE";
- }
+ -r $dir or Carp::croak("Found directory '$dir', but no read permissions");
+ return $dir;
+ }
- die "CODE INCOMPLETE";
+ return undef;
}
+sub _module_subdir
+{
+ my $module = shift;
+ $module =~ s/::/-/g;
+ return $module;
+}
+
+sub _dist_packfile ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
+{
+ my $module = shift;
+ use Config ();
+ ## no critic (Variables::ProhibitPackageVars)
+ my @dirs = grep { -e } ($Config::Config{archlibexp}, $Config::Config{sitearchexp});
+ my $file = File::Spec->catfile('auto', split(/::/, $module), '.packlist',);
+
+ foreach my $dir (@dirs)
+ {
+ my $path = File::Spec->catfile($dir, $file);
+ next unless -f $path;
+
+ # Load the file
+ my $packlist = ExtUtils::Packlist->new($path);
+ $packlist or Carp::croak("Failed to load .packlist file for $module");
+
+ Carp::croak("CODE INCOMPLETE");
+ }
+
+ Carp::croak("CODE INCOMPLETE");
+}
+
+## no critic (BuiltinFunctions::ProhibitStringyEval)
+if (eval "use Params::Util; 1;")
+{
+ Params::Util->import("_CLASS", "_STRING");
+}
+else
+{
+ ## no critic (ErrorHandling::RequireCheckingReturnValueOfEval)
+ eval <<'END_OF_BORROWED_CODE';
# Inlined from Params::Util pure perl version
-sub _CLASS {
- (defined $_[0] and ! ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $_[0] : undef;
+sub _CLASS ($)
+{
+ return (defined $_[0] and !ref $_[0] and $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s) ? $_[0] : undef;
}
+sub _STRING ($)
+{
+ (defined $_[0] and ! ref $_[0] and length($_[0])) ? $_[0] : undef;
+}
+END_OF_BORROWED_CODE
+}
# Maintainer note: The following private functions are used by
# File::ShareDir::PAR. (It has to or else it would have to copy&fork)
# So if you significantly change or even remove them, please
-# notify the File::ShareDir::PAR maintainer(s). Thank you!
+# notify the File::ShareDir::PAR maintainer(s). Thank you!
# Matches a valid distribution name
### This is a total guess at this point
-sub _DIST {
- if ( defined $_[0] and ! ref $_[0] and $_[0] =~ /^[a-z0-9+_-]+$/is ) {
- return shift;
- }
- Carp::croak("Not a valid distribution name");
+sub _DIST ## no critic (Subroutines::RequireArgUnpacking)
+{
+ defined _STRING($_[0]) and $_[0] =~ /^[a-z0-9+_-]+$/is and return $_[0];
+ Carp::croak("Not a valid distribution name");
}
# A valid and loaded module name
-sub _MODULE {
- my $module = _CLASS(shift) or Carp::croak("Not a valid module name");
- if ( Class::Inspector->loaded($module) ) {
- return $module;
- }
- Carp::croak("Module '$module' is not loaded");
+sub _MODULE
+{
+ my $module = _CLASS(shift) or Carp::croak("Not a valid module name");
+ Class::Inspector->loaded($module) and return $module;
+ Carp::croak("Module '$module' is not loaded");
}
# A valid file name
-sub _FILE {
- my $file = shift;
- unless ( defined $file and ! ref $file and length $file ) {
- Carp::croak("Did not pass a file name");
- }
- if ( File::Spec->file_name_is_absolute($file) ) {
- Carp::croak("Cannot use absolute file name '$file'");
- }
- $file;
+sub _FILE
+{
+ my $file = shift;
+ _STRING($file) or Carp::croak("Did not pass a file name");
+ File::Spec->file_name_is_absolute($file) and Carp::croak("Cannot use absolute file name '$file'");
+ return $file;
}
1;
=pod
+=head1 EXTENDING
+
+=head2 Overriding Directory Resolution
+
+CFile::ShareDir has two convenience hashes for people who have advanced usage
+requirements of CFile::ShareDir such as using uninstalled C<share>
+directories during development.
+
+ #
+ # Dist-Name => /absolute/path/for/DistName/share/dir
+ #
+ %File::ShareDir::DIST_SHARE
+
+ #
+ # Module::Name => /absolute/path/for/Module/Name/share/dir
+ #
+ %File::ShareDir::MODULE_SHARE
+
+Setting these values any time before the corresponding calls
+
+ dist_dir('Dist-Name')
+ dist_file('Dist-Name','some/file');
+
+ module_dir('Module::Name');
+ module_file('Module::Name','some/file');
+
+Will override the base directory for resolving those calls.
+
+An example of where this would be useful is in a test for a module that
+depends on files installed into a share directory, to enable the tests
+to use the development copy without needing to install them first.
+
+ use File::ShareDir;
+ use Cwd qw( getcwd );
+ use File::Spec::Functions qw( rel2abs catdir );
+
+ $File::ShareDir::MODULE_SHARE{'Foo::Module'} = rel2abs(catfile(getcwd,'share'));
+
+ use Foo::Module;
+
+ # interal calls in Foo::Module to module_file('Foo::Module','bar') now resolves to
+ # the source trees share/ directory instead of something in @INC
+
=head1 SUPPORT
Bugs should always be submitted via the CPAN bug tracker
@@ -567,7 +612,8 @@
=head1 COPYRIGHT
-Copyright 2005 - 2011 Adam Kennedy.
+Copyright 2005 - 2011 Adam Kennedy,
+Copyright 2014 - 2018 Jens Rehsack.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/t/01_compile.t new/File-ShareDir-1.108/t/01_compile.t
--- old/File-ShareDir-1.104/t/01_compile.t 2014-05-10 16:50:48.000000000 +0200
+++ new/File-ShareDir-1.108/t/01_compile.t 2018-06-09 18:50:48.000000000 +0200
@@ -3,13 +3,15 @@
# Compile-testing for File::ShareDir
use strict;
-BEGIN {
- $| = 1;
- $^W = 1;
+
+BEGIN
+{
+ $| = 1;
+ $^W = 1;
}
use Test::More tests => 2;
-ok( $] > 5.005, 'Perl version is 5.005 or newer' );
+ok($] > 5.005, 'Perl version is 5.005 or newer');
-use_ok( 'File::ShareDir' );
+use_ok('File::ShareDir');
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/t/02_main.t new/File-ShareDir-1.108/t/02_main.t
--- old/File-ShareDir-1.104/t/02_main.t 2017-04-06 18:13:03.000000000 +0200
+++ new/File-ShareDir-1.108/t/02_main.t 2018-06-15 10:42:05.000000000 +0200
@@ -3,21 +3,16 @@
# Compile-testing for File::ShareDir
use strict;
-BEGIN {
- $| = 1;
- $^W = 1;
+
+BEGIN
+{
+ $| = 1;
+ $^W = 1;
}
-use Test::More tests => 31;
+use Test::More;
use File::ShareDir;
-sub dies {
- my $code = shift;
- my $message = shift || 'Code dies as expected';
- my $rv = eval { &$code() };
- ok( $@, $message );
-}
-
# Print the contents of @INC
#diag("\@INC = qw{");
#foreach ( @INC ) {
@@ -25,111 +20,59 @@
#}
#diag(" }");
-
-
-
#####################################################################
# Loading and Importing
# Don't import by default
-ok( ! defined &dist_dir, 'dist_dir not imported by default' );
-ok( ! defined &module_dir, 'module_dir not imported by default' );
-ok( ! defined &dist_file, 'dist_file not imported by default' );
-ok( ! defined &module_file, 'module_file not imported by default' );
-ok( ! defined &class_file, 'class_file not imported by default' );
-use_ok( 'File::ShareDir', ':ALL' );
+ok(!defined &dist_dir, 'dist_dir not imported by default');
+ok(!defined &module_dir, 'module_dir not imported by default');
+ok(!defined &dist_file, 'dist_file not imported by default');
+ok(!defined &module_file, 'module_file not imported by default');
+ok(!defined &class_file, 'class_file not imported by default');
+use_ok('File::ShareDir', ':ALL');
# Import as needed
-ok( defined &dist_dir, 'dist_dir imported' );
-ok( defined &module_dir, 'module_dir imported' );
-ok( defined &dist_file, 'dist_file imported' );
-ok( defined &module_file, 'module_file imported' );
-ok( defined &class_file, 'class_file imported' );
+ok(defined &dist_dir, 'dist_dir imported');
+ok(defined &module_dir, 'module_dir imported');
+ok(defined &dist_file, 'dist_file imported');
+ok(defined &module_file, 'module_file imported');
+ok(defined &class_file, 'class_file imported');
# Allow all named functions
-use_ok(
- 'File::ShareDir',
- 'module_dir',
- 'module_file',
- 'dist_dir',
- 'dist_file',
- 'class_file',
-);
-
-
-
-
+use_ok('File::ShareDir', 'module_dir', 'module_file', 'dist_dir', 'dist_file', 'class_file',);
#####################################################################
# Support Methods
-is(
- File::ShareDir::_MODULE('File::ShareDir'), 'File::ShareDir',
- '_MODULE returns correct for known loaded module',
-);
-is(
- File::ShareDir::_DIST('File-ShareDir'), 'File-ShareDir',
- '_DIST returns correct for known good dist',
-);
-
-
-
-
+is(File::ShareDir::_MODULE('File::ShareDir'), 'File::ShareDir', '_MODULE returns correct for known loaded module',);
+is(File::ShareDir::_DIST('File-ShareDir'), 'File-ShareDir', '_DIST returns correct for known good dist',);
#####################################################################
# Module Tests
my $module_dir = module_dir('File::ShareDir');
-ok( $module_dir, 'Can find our own module dir' );
-ok( -d $module_dir, '... and is a dir' );
-ok( -r $module_dir, '... and have read permissions' );
-
-dies( sub { module_dir() }, 'No params to module_dir dies' );
-dies( sub { module_dir('') }, 'Null param to module_dir dies' );
-dies(
- sub { module_dir('File::ShareDir::Bad') },
- 'Getting module dir for known non-existanct module dies',
-);
+ok($module_dir, 'Can find our own module dir');
+ok(-d $module_dir, '... and is a dir');
+ok(-r $module_dir, '... and have read permissions');
my $module_file = module_file('File::ShareDir', 'test_file.txt');
-ok( -f $module_file, 'module_file ok' );
-
-
-
-
+ok(-f $module_file, 'module_file ok');
#####################################################################
# Distribution Tests
my $dist_dir = dist_dir('File-ShareDir');
-ok( $dist_dir, 'Can find our own dist dir' );
-ok( -d $dist_dir, '... and is a dir' );
-ok( -r $dist_dir, '... and have read permissions' );
+ok($dist_dir, 'Can find our own dist dir');
+ok(-d $dist_dir, '... and is a dir');
+ok(-r $dist_dir, '... and have read permissions');
my $dist_file = dist_file('File-ShareDir', 'sample.txt');
-ok( $dist_file, 'Can find our sample module file' );
-ok( -f $dist_file, '... and is a file' );
-ok( -r $dist_file, '... and have read permissions' );
+ok($dist_file, 'Can find our sample module file');
+ok(-f $dist_file, '... and is a file');
+ok(-r $dist_file, '... and have read permissions');
# Make sure the directory in dist_dir, matches the one from dist_file
# Bug found in Module::Install 0.54, fixed in 0.55
-is(
- File::Spec->catfile($dist_dir, 'sample.txt'), $dist_file,
- 'dist_dir and dist_file find the same directory',
-);
-
-
+is(File::Spec->catfile($dist_dir, 'sample.txt'), $dist_file, 'dist_dir and dist_file find the same directory',);
-
-
-#####################################################################
-# Class Tests
-
-{
- local @INC;
- push @INC, "." unless grep { $_ eq "." } @INC;
- use_ok( "t::lib::ShareDir" );
-}
-my $class_file = class_file('t::lib::ShareDir', 'test_file.txt');
-ok( -f $class_file, 'class_file ok' );
-is( $class_file, $module_file, 'class_file matches module_file for subclass' );
+done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/t/03_extensions.t new/File-ShareDir-1.108/t/03_extensions.t
--- old/File-ShareDir-1.104/t/03_extensions.t 1970-01-01 01:00:00.000000000 +0100
+++ new/File-ShareDir-1.108/t/03_extensions.t 2018-06-09 18:50:48.000000000 +0200
@@ -0,0 +1,30 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+# ABSTRACT: Test for overriding paths
+
+use File::ShareDir qw( dist_dir dist_file module_dir module_file );
+use Cwd qw( getcwd );
+
+my $FAKE_DIST = 'Fake-Sample-Dist';
+my $FAKE_MODULE = 'Fake::Sample::Module';
+
+{
+
+ package Fake::Sample::Module;
+ $INC{'Fake/Sample/Module.pm'} = 1;
+}
+
+$File::ShareDir::DIST_SHARE{$FAKE_DIST} = getcwd;
+$File::ShareDir::MODULE_SHARE{$FAKE_MODULE} = getcwd;
+
+is(dist_dir($FAKE_DIST), getcwd, "Fake distribution resolves to forced value");
+ok(-f dist_file($FAKE_DIST, 't/03_extensions.t'), "Fake distribution resolves to forced value with a file");
+
+is(module_dir($FAKE_MODULE), getcwd, "Fake module resolves to forced value");
+ok(-f module_file($FAKE_MODULE, 't/03_extensions.t'), "Fake module resolves to forced value with a file");
+
+done_testing;
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/t/04_fail.t new/File-ShareDir-1.108/t/04_fail.t
--- old/File-ShareDir-1.104/t/04_fail.t 1970-01-01 01:00:00.000000000 +0100
+++ new/File-ShareDir-1.108/t/04_fail.t 2018-06-15 10:42:28.000000000 +0200
@@ -0,0 +1,34 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+sub dies
+{
+ my $code = shift;
+ my $pattern = shift;
+ my $message = shift || 'Code dies as expected';
+ my $rv = eval { &$code() };
+ my $err = $@;
+ like($err, $pattern, $message);
+}
+
+use File::ShareDir ':ALL';
+
+dies(sub { module_dir() }, qr/Not a valid module name/, 'No params to module_dir dies');
+dies(sub { module_dir('') }, qr/Not a valid module name/, 'Null param to module_dir dies');
+dies(
+ sub { module_dir('File::ShareDir::Bad') },
+ qr/Module 'File::ShareDir::Bad' is not loaded/,
+ 'Getting module dir for known non-existant module dies',
+);
+# test from RT#125582
+dies(
+ sub { dist_file('File-ShareDir', 'file/name.txt'); },
+ qr,Failed to find shared file 'file/name.txt' for dist 'File-ShareDir',,
+ "Getting non-existant file dies"
+);
+
+done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/t/05_class.t new/File-ShareDir-1.108/t/05_class.t
--- old/File-ShareDir-1.104/t/05_class.t 1970-01-01 01:00:00.000000000 +0100
+++ new/File-ShareDir-1.108/t/05_class.t 2018-06-15 10:42:05.000000000 +0200
@@ -0,0 +1,24 @@
+#!perl
+
+use strict;
+use warnings;
+
+use Cwd ('abs_path');
+use File::Basename ('dirname');
+use File::Spec ();
+use Test::More;
+
+#####################################################################
+# Class Tests
+
+{
+ my @TEST_INC = @INC;
+ local @INC = (File::Spec->catdir(abs_path(dirname($0)), "lib"), @TEST_INC);
+ use_ok("ShareDir::TestClass");
+}
+my $class_file = File::ShareDir->can("class_file")->('ShareDir::TestClass', 'test_file.txt');
+ok(-f $class_file, 'class_file ok');
+my $module_file = File::ShareDir->can("module_file")->('File::ShareDir', 'test_file.txt');
+is($class_file, $module_file, 'class_file matches module_file for subclass');
+
+done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/t/lib/ShareDir/TestClass.pm new/File-ShareDir-1.108/t/lib/ShareDir/TestClass.pm
--- old/File-ShareDir-1.104/t/lib/ShareDir/TestClass.pm 1970-01-01 01:00:00.000000000 +0100
+++ new/File-ShareDir-1.108/t/lib/ShareDir/TestClass.pm 2018-06-15 10:42:05.000000000 +0200
@@ -0,0 +1,9 @@
+package ShareDir::TestClass;
+
+use strict;
+
+use parent ("File::ShareDir");
+
+our $VERSION = "1.02";
+
+1;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/File-ShareDir-1.104/t/lib/ShareDir.pm new/File-ShareDir-1.108/t/lib/ShareDir.pm
--- old/File-ShareDir-1.104/t/lib/ShareDir.pm 2014-05-10 16:50:48.000000000 +0200
+++ new/File-ShareDir-1.108/t/lib/ShareDir.pm 1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-package t::lib::ShareDir;
-
-use strict;
-
-use vars qw{$VERSION @ISA};
-BEGIN {
- $VERSION = '1.01';
- @ISA = 'File::ShareDir';
-}
-
-1;