Subject: | Tests fail when no '.' in @INC ( Can't locate t/mytestlib.pl in @INC ) |
Perl 5.25.11 removes '.' from the default @INC, and this breaks `require t/mytestlib.pl` due to not being able to assume ./t/mytestlib.pl is in the @INC load path.
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 INSTALLER 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
Official Documentation: https://metacpan.org/pod/release/XSAWYERX/perl-5.26.0/pod/perldelta.pod#Removal-of-the-current-directory-%28%22.%22%29-from-@INC
---
Raw Error Observed:
t/iq.t ........................ 1/114 Can't locate t/mytestlib.pl in @INC (@INC contains: t/lib /var/tmp/portage/dev-perl/Net-Jabber-2.0.0-r1/work/Net-Jabber-2.0/blib/lib /var/tmp/portage/dev-perl/Net-Jabber-2.0.0-r1/work/Net-Jabber-2.0/blib/arch /etc/perl /usr/local/lib64/perl5/5.26.0/x86_64-linux /usr/local/lib64/perl5/5.26.0 /usr/lib64/perl5/vendor_perl/5.26.0/x86_64-linux /usr/lib64/perl5/vendor_perl/5.26.0 /usr/local/lib64/perl5 /usr/lib64/perl5/vendor_perl/5.26.0-RC1 /usr/lib64/perl5/vendor_perl/5.25.12 /usr/lib64/perl5/vendor_perl/5.25.11 /usr/lib64/perl5/vendor_perl/5.22.3 /usr/lib64/perl5/vendor_perl /usr/lib64/perl5/5.26.0/x86_64-linux /usr/lib64/perl5/5.26.0) at t/iq.t line 6. # Looks like you planned 114 tests but only ran 1. # Looks like your test died just after 1. t/iq.t ........................ Dubious, test returned 255 (wstat 65280, 0xff00) Failed 113/114 subtests t/jid.t ....................... 1/15 Can't locate t/mytestlib.pl in @INC (@INC contains: t/lib /var/tmp/portage/dev-perl/Net-Jabber-2.0.0-r1/work/Net-Jabber-2.0/blib/lib /var/tmp/portage/dev-perl/Net-Jabber-2.0.0-r1/work/Net-Jabber-2.0/blib/arch /etc/perl /usr/local/lib64/perl5/5.26.0/x86_64-linux /usr/local/lib64/perl5/5.26.0 /usr/lib64/perl5/vendor_perl/5.26.0/x86_64-linux /usr/lib64/perl5/vendor_perl/5.26.0 /usr/local/lib64/perl5 /usr/lib64/perl5/vendor_perl/5.26.0-RC1 /usr/lib64/perl5/vendor_perl/5.25.12 /usr/lib64/perl5/vendor_perl/5.25.11 /usr/lib64/perl5/vendor_perl/5.22.3 /usr/lib64/perl5/vendor_perl /usr/lib64/perl5/5.26.0/x86_64-linux /usr/lib64/perl5/5.26.0) at t/jid.t line 6.--
- CPAN kentnl@cpan.org
- Gentoo Perl Maintainer kentnl@gentoo.org ( perl@gentoo.org )