Subject: | Tests fail when no '.' in @INC ( Can't locate t/init.pl in @INC ) |
Perl 5.25.11 removes '.' from the default @INC, and this breaks `require "t/init.pl"` due to not being able to assume ./t/init.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 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:
t/00array.t ........ Can't locate t/init.pl in @INC (@INC contains: /var/tmp/portage/dev-perl/JavaScript-SpiderMonkey-0.210.0-r1/work/JavaScript-SpiderMonkey-0.21/blib/lib /var/tmp/portage/dev-perl/JavaScript-SpiderMonkey-0.210.0-r1/work/JavaScript-SpiderMonkey-0.21/blib/arch /etc/perl /usr/local/lib64/perl5/5.25.12/x86_64-linux /usr/local/lib64/perl5/5.25.12 /usr/lib64/perl5/vendor_perl/5.25.12/x86_64-linux /usr/lib64/perl5/vendor_perl/5.25.12 /usr/local/lib64/perl5 /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.25.12/x86_64-linux /usr/lib64/perl5/5.25.12) at t/00array.t line 8.
t/00array.t ........ Dubious, test returned 2 (wstat 512, 0x200)
Failed 1/1 subtests
( and 10 more like this from different tests )
t/00array.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/01doc-href.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/02nav-appv.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/03doc-write.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/04loop.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/05form.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/06form2.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/07func.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/08func2.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/09meth.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
t/10elobj.t (Wstat: 512 Tests: 0 Failed: 0)
Non-zero exit status: 2
Parse errors: Bad plan. You planned 1 tests but ran 0.
- CPAN kentnl@cpan.org
- Gentoo Perl Maintainer kentnl@gentoo.org ( perl@gentoo.org )