Skip Menu |

This queue is for tickets about the Log-Agent CPAN distribution.

Report information
The Basics
Id: 121459
Status: resolved
Worked: 20 min
Priority: 0/
Queue: Log-Agent

People
Owner: mrogaski [...] cpan.org
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.002



Subject: Tests fail when no '.' in @INC (Can't locate t/code.pl in @INC )
Note: templated response follows

Perl 5.25.11 removes '.' from the default @INC, and this breaks `require 't/code.pl'` due to not being able to assume ./t/code.pl is in the @INC load path. ( And "require $foo" where $foo is neither an absolute path or a path starting with './' , perl interprets as an @INC search )

This is not a complete end-of-the-world problem, as Perl provides a temporary workaround variable (PERL_USE_UNSAFE_INC=1) affected users can set that restores '.' in @INC temporarily to "just work", and for end users convenience, CPAN.pm, cpanm, prove and TAP::Harness ( called in `make test` ) set this variable, creating an illusion during installation that this problem is not there

However, this should still be considered a serious issue, as many types of end users don't get the luxury afforded by the CPAN-and-friends hacks ( vendors, hand installers, people running `perl t/foo.t` ), and this workaround is scheduled to be removed in the future.

And due to aforementioned temporary conveniences and hacks, you should intentionally defeat said hacks when testing you've fixed this, by explicitly setting PERL_USE_UNSAFE_INC=0 in your environment prior to running Makefile.PL and tests, and ensuring to perform said tests on Perl 5.25.11 or newer

Two primary solutions are recommended for tests:

1. Re-organise test dependencies into a dedicated directory such as `t/lib` and load that path into @INC with `use lib 't/lib'`

2. Rewrite calls to `do` and `require` to have either absolute paths ( via `File::Spec rel2abs` ) or have explicit `./` prefixes, both of which disable @INC lookup

Both of these suggestions intentionally avoid the easier option of just reinserting `.` on purpose, as some proportion of runtime code also is subject to these cwd-implied bugs, and it is desirable to expose such cases as the errors they are, not silently suppress their failures

For more details, check http://blogs.perl.org/users/ryan_voots/2017/04/trials-and-troubles-with-changing-inc.html

---

Raw Error Observed:

perl -Mblib=blib t/caller.t
1..10
Can't locate t/code.pl in @INC (@INC contains: blib/arch blib/lib /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/site_perl/5.25.12/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/site_perl/5.25.12 /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/5.25.12/x86_64-linux /home/kent/perl5/perlbrew/perls/5.25.12-nossp-sip13-nopmc-nodot/lib/5.25.12) at t/caller.t line 17.

perl -Mblib=blib t/carp_fork.t
do "t/carp.pl" failed, '.' is no longer in @INC; did you mean do "./t/carp.pl"? at t/carp_fork.t line 32.
 

-- 
- CPAN kentnl@cpan.org
- Gentoo Perl Maintainer kentnl@gentoo.org ( perl@gentoo.org )
Subject: 0001-Fix-test-failures-due-to-.-removal-from-INC-under-Pe.patch
From f85b4f6c097338ff07c5736fbe77dd09d2bca289 Mon Sep 17 00:00:00 2001 From: Kent Fredric <kentnl@gentoo.org> Date: Thu, 26 Oct 2017 21:02:47 +1300 Subject: Fix test failures due to '.' removal from @INC under Perl 5.26 when PERL_USE_UNSAFE_INC=0 Bug: https://bugs.gentoo.org/617050 Bug: https://rt.cpan.org/Ticket/Display.html?id=121459 Bug: https://github.com/mrogaski/Log-Agent/pull/13 --- t/caller.t | 2 +- t/carp.pl | 4 ++-- t/carp_default.t | 2 +- t/carp_file.t | 2 +- t/carp_fork.t | 2 +- t/carp_silent.t | 2 +- t/default.t | 2 +- t/default_exp.t | 2 +- t/file.t | 2 +- t/fork.t | 2 +- t/priority.t | 2 +- t/tag_callback.t | 2 +- t/tag_string.t | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/t/caller.t b/t/caller.t index 6a14aa6..feb3c2c 100644 --- a/t/caller.t +++ b/t/caller.t @@ -14,7 +14,7 @@ print "1..10\n"; -require 't/code.pl'; +require './t/code.pl'; sub ok; use Log::Agent; diff --git a/t/carp.pl b/t/carp.pl index a4327e1..352f7d6 100644 --- a/t/carp.pl +++ b/t/carp.pl @@ -14,10 +14,10 @@ print "1..11\n"; -require 't/code.pl'; +require './t/code.pl'; sub ok; -my $FILE = "t/carp.pl"; +my $FILE = "./t/carp.pl"; package OTHER; use Log::Agent; diff --git a/t/carp_default.t b/t/carp_default.t index 293ddb7..819e438 100644 --- a/t/carp_default.t +++ b/t/carp_default.t @@ -20,4 +20,4 @@ select(ORIG_STDOUT); open(STDOUT, ">t/file.out") || die "can't redirect STDOUT: $!\n"; open(STDERR, ">t/file.err") || die "can't redirect STDOUT: $!\n"; -do 't/carp.pl'; +do './t/carp.pl'; diff --git a/t/carp_file.t b/t/carp_file.t index 9e5e9a3..8239d62 100644 --- a/t/carp_file.t +++ b/t/carp_file.t @@ -27,4 +27,4 @@ my $driver = Log::Agent::Driver::File->make( ); logconfig(-driver => $driver); -do 't/carp.pl'; +do './t/carp.pl'; diff --git a/t/carp_fork.t b/t/carp_fork.t index c81a86b..dcf8131 100644 --- a/t/carp_fork.t +++ b/t/carp_fork.t @@ -29,4 +29,4 @@ my $driver = Log::Agent::Driver::Fork->make( ); logconfig(-driver => $driver); -do 't/carp.pl'; +do './t/carp.pl'; diff --git a/t/carp_silent.t b/t/carp_silent.t index 6c7c8ca..c913308 100644 --- a/t/carp_silent.t +++ b/t/carp_silent.t @@ -14,7 +14,7 @@ print "1..2\n"; -require 't/code.pl'; +require './t/code.pl'; sub ok; use Log::Agent; diff --git a/t/default.t b/t/default.t index eadca93..73bab3a 100644 --- a/t/default.t +++ b/t/default.t @@ -14,7 +14,7 @@ print "1..4\n"; -require 't/code.pl'; +require './t/code.pl'; sub ok; use Log::Agent; diff --git a/t/default_exp.t b/t/default_exp.t index 5fc95b7..940e1eb 100644 --- a/t/default_exp.t +++ b/t/default_exp.t @@ -19,7 +19,7 @@ print "1..8\n"; -require 't/code.pl'; +require './t/code.pl'; sub ok; use Log::Agent; diff --git a/t/file.t b/t/file.t index 57caaba..e7487ee 100644 --- a/t/file.t +++ b/t/file.t @@ -15,7 +15,7 @@ use Test::More; use Log::Agent; require Log::Agent::Driver::File; -require 't/common.pl'; +require './t/common.pl'; BEGIN { plan tests => 38 } diff --git a/t/fork.t b/t/fork.t index a943a89..5726ba2 100644 --- a/t/fork.t +++ b/t/fork.t @@ -14,7 +14,7 @@ use strict; use Test; -require 't/common.pl'; +require './t/common.pl'; BEGIN { plan tests => 19 } diff --git a/t/priority.t b/t/priority.t index 3e5be89..3f6b2c4 100644 --- a/t/priority.t +++ b/t/priority.t @@ -14,7 +14,7 @@ print "1..5\n"; -require 't/code.pl'; +require './t/code.pl'; sub ok; use Log::Agent; diff --git a/t/tag_callback.t b/t/tag_callback.t index 64a1bd4..39b749d 100644 --- a/t/tag_callback.t +++ b/t/tag_callback.t @@ -12,7 +12,7 @@ # ########################################################################## -require 't/code.pl'; +require './t/code.pl'; sub ok; eval "require Callback"; diff --git a/t/tag_string.t b/t/tag_string.t index 843fc10..b4851c2 100644 --- a/t/tag_string.t +++ b/t/tag_string.t @@ -14,7 +14,7 @@ print "1..2\n"; -require 't/code.pl'; +require './t/code.pl'; sub ok; use Log::Agent; -- 2.14.3
I've integrated Kent's patch in 1.002. https://github.com/mrogaski/Log-Agent/pull/13 I've also added the project to TravisCI. https://travis-ci.org/mrogaski/Log-Agent Thank you, Mark
Marking this as resolved.