Skip Menu |

This queue is for tickets about the IO-Pager CPAN distribution.

Report information
The Basics
Id: 121450
Status: resolved
Priority: 0/
Queue: IO-Pager

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

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



Subject: Tests fail when no '.' in @INC ( Can't locate t/08-redirect.pl in @INC )

I observe you have existing attempts at fixing tests for this, but alas, it wasn't enough.

Unfortunately, 'require "t/foo.pl" '  *also* triggers @INC traversal.

The only way to subvert @INC lookup is to either

a: Use a fully qualified path

b: Use a path with a leading "./"

Both of these are special cased.

Compare the results of running the tests directly vs with "legacy compat mode" enabled.

perl -Mblib=blib t/08-redirect.t
Can't locate t/08-redirect.pl in @INC (@INC contains: /home/kent/.cpanm/work/1493468674.30124/IO-Pager-0.37/blib/arch /home/kent/.cpanm/work/1493468674.30124/IO-Pager-0.37/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 -e line 1.
Can't locate t/08-redirect.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/08-redirect.t line 20, <TMP> chunk 1.

 

PERL_USE_UNSAFE_INC=1 perl -Mblib=blib t/08-redirect.t
ok 1 - Redirection (IO::Pager::Page)
1..1


perl -Mblib=blib t/11-redirect-oo.t
Can't locate t/08-redirect.pl in @INC (@INC contains: /home/kent/.cpanm/work/1493468674.30124/IO-Pager-0.37/blib/arch /home/kent/.cpanm/work/1493468674.30124/IO-Pager-0.37/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/11-redirect-oo.pl line 4.
Can't locate t/08-redirect.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/11-redirect-oo.t line 26, <TMP> chunk 1.


 PERL_USE_UNSAFE_INC=1 perl -Mblib=blib t/11-redirect-oo.t
ok 1 - Redirection with OO
1..1

 The attached patch as proof of concept should fix t/08-redirect.t , but 11-redirect-oo.t still needs its own fix.

Please make sure to run

PERL_USE_UNSAFE_INC=0 make test

on Perl 5.25.11+ when done to defeat TAP::Harness auto-magically hiding failures ( it internally sets PERL_UNSAFE_INC=1 if its not set )

-- 
- CPAN kentnl@cpan.org
- Gentoo Perl Maintainer kentnl@gentoo.org ( perl@gentoo.org )
Subject: redirect.patch
--- t/08-redirect.t 2017-04-26 00:00:32.000000000 +0000 +++ t/08-redirect.t.new 2017-04-29 12:32:42.335795330 +0000 @@ -12,12 +12,12 @@ #Print the heredoc in 08-redirect.pl to temp file via redirection my $q = q[']; $q = q["] if $^O =~ /MSWin32/; -system qq($^X -Mblib -MIO::Pager::Page -e $q require q[t/08-redirect.pl]; print \$txt $q >$tempname); +system qq($^X -Mblib -MIO::Pager::Page -e $q require q[./t/08-redirect.pl]; print \$txt $q >$tempname); open(TMP, $tempname) or die "Could not open tmpfile: $!\n"; my $slurp = do{ undef $/; <TMP> }; -our $txt; require 't/08-redirect.pl'; +our $txt; require './t/08-redirect.pl'; ok($txt eq $slurp, 'Redirection (IO::Pager::Page)'); done_testing;
On Sat Apr 29 08:37:22 2017, KENTNL wrote: Show quoted text
> I observe you have existing attempts at fixing tests for this, but > alas, it > wasn't enough. > > Unfortunately, 'require "t/foo.pl" ' *also* triggers @INC traversal. > > The only way to subvert @INC lookup is to either > > a: Use a fully qualified path > > b: Use a path with a leading "./" > > Both of these are special cased. > > Compare the results of running the tests directly vs with "legacy > compat mode" > enabled. > > perl -Mblib=blib t/08-redirect.t > Can't locate t/08-redirect.pl in @INC (@INC contains: > /home/kent/.cpanm/work/1493468674.30124/IO-Pager-0.37/blib/arch > /home/kent/.cpanm/work/1493468674.30124/IO-Pager-0.37/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 > -e line 1. > Can't locate t/08-redirect.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/08-redirect.t line 20, <TMP> chunk 1. > > PERL_USE_UNSAFE_INC=1 perl -Mblib=blib t/08-redirect.t > ok 1 - Redirection (IO::Pager::Page) > 1..1 > > > perl -Mblib=blib t/11-redirect-oo.t > Can't locate t/08-redirect.pl in @INC (@INC contains: > /home/kent/.cpanm/work/1493468674.30124/IO-Pager-0.37/blib/arch > /home/kent/.cpanm/work/1493468674.30124/IO-Pager-0.37/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/11-redirect-oo.pl line 4. > Can't locate t/08-redirect.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/11-redirect-oo.t line 26, <TMP> chunk 1. > > > PERL_USE_UNSAFE_INC=1 perl -Mblib=blib t/11-redirect-oo.t > ok 1 - Redirection with OO > 1..1 > > The attached patch as proof of concept should fix t/08-redirect.t , > but > 11-redirect-oo.t still needs its own fix. > > Please make sure to run > > PERL_USE_UNSAFE_INC=0 make test > > on Perl 5.25.11+ when done to defeat TAP::Harness auto-magically > hiding > failures ( it internally sets PERL_UNSAFE_INC=1 if its not set ) > > -- > - CPAN kentnl@cpan.org > - Gentoo Perl Maintainer kentnl@gentoo.org ( perl@gentoo.org )
Patch for test 11 attached


-- 
- CPAN kentnl@cpan.org
- Gentoo Perl Maintainer kentnl@gentoo.org ( perl@gentoo.org )
Subject: 0001-Fix-tests-failing-without-.-in-INC.patch
From 3a4daf4f10cd880edf0ce9d56f34abe0635aec8f Mon Sep 17 00:00:00 2001 From: Kent Fredric <kentnl@gentoo.org> Date: Thu, 26 Oct 2017 11:27:10 +1300 Subject: Fix tests failing without '.' in @INC Bug: https://rt.cpan.org/Ticket/Display.html?id=121450 --- t/11-redirect-oo.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/11-redirect-oo.pl b/t/11-redirect-oo.pl index 385d6d4..9203500 100644 --- a/t/11-redirect-oo.pl +++ b/t/11-redirect-oo.pl @@ -1,7 +1,7 @@ use blib; use IO::Pager; -our $txt; require 't/08-redirect.pl'; +our $txt; require './t/08-redirect.pl'; my $FH = new IO::Pager; $FH->print($txt); -- 2.14.3