Skip Menu |

This queue is for tickets about the JavaScript-SpiderMonkey CPAN distribution.

Report information
The Basics
Id: 121452
Status: resolved
Priority: 0/
Queue: JavaScript-SpiderMonkey

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

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



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

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 )
Subject: 0002-Fix-test-failures-without-.-in-INC.patch
From c89a871ead0a961f8a0125d875cbe28974e23f29 Mon Sep 17 00:00:00 2001 From: Kent Fredric <kentnl@gentoo.org> Date: Thu, 26 Oct 2017 18:50:34 +1300 Subject: Fix test failures without '.' in @INC Bug: https://bugs.gentoo.org/617006 Bug: https://rt.cpan.org/Ticket/Display.html?id=121452 --- t/00array.t | 2 +- t/01doc-href.t | 2 +- t/02nav-appv.t | 2 +- t/03doc-write.t | 2 +- t/04loop.t | 2 +- t/05form.t | 2 +- t/06form2.t | 2 +- t/07func.t | 2 +- t/08func2.t | 2 +- t/09meth.t | 2 +- t/10elobj.t | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/t/00array.t b/t/00array.t index 3bd85a6..ba36807 100755 --- a/t/00array.t +++ b/t/00array.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; $js->array_by_path("document.form"); diff --git a/t/01doc-href.t b/t/01doc-href.t index 7f79c95..c545ca7 100755 --- a/t/01doc-href.t +++ b/t/01doc-href.t @@ -6,7 +6,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; my $source = <<EOT; $init diff --git a/t/02nav-appv.t b/t/02nav-appv.t index d038f3e..2e0d7f6 100755 --- a/t/02nav-appv.t +++ b/t/02nav-appv.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; my $source = <<EOT; $init diff --git a/t/03doc-write.t b/t/03doc-write.t index 9b38e21..f757592 100755 --- a/t/03doc-write.t +++ b/t/03doc-write.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; my $source = <<EOT; $init diff --git a/t/04loop.t b/t/04loop.t index 3757c1d..768067a 100755 --- a/t/04loop.t +++ b/t/04loop.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; my $source = <<EOT; $init diff --git a/t/05form.t b/t/05form.t index 0dc763a..3212d05 100755 --- a/t/05form.t +++ b/t/05form.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; my $source = <<EOT; $init diff --git a/t/06form2.t b/t/06form2.t index 9aacb7a..fdf1bd2 100755 --- a/t/06form2.t +++ b/t/06form2.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; my $a = $js->array_by_path("document.array"); my $e = $js->array_set_element($a, 0, "gurkenhobel"); diff --git a/t/07func.t b/t/07func.t index c0f95cc..9b12633 100644 --- a/t/07func.t +++ b/t/07func.t @@ -6,7 +6,7 @@ print "1..1\n"; $init = ""; $buffer = ""; -require "t/init.pl"; +require "./t/init.pl"; my $source = <<EOT; $init diff --git a/t/08func2.t b/t/08func2.t index 6b49ef7..95c7749 100644 --- a/t/08func2.t +++ b/t/08func2.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; $args = ""; diff --git a/t/09meth.t b/t/09meth.t index 4b5da81..2b86a9c 100644 --- a/t/09meth.t +++ b/t/09meth.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; $args = ""; diff --git a/t/10elobj.t b/t/10elobj.t index d4eca5c..2c097b9 100644 --- a/t/10elobj.t +++ b/t/10elobj.t @@ -5,7 +5,7 @@ print "1..1\n"; $init = ""; -require "t/init.pl"; +require "./t/init.pl"; $submitted = "0"; -- 2.14.3
Thanks for the contribution. This is now fixed in version 0.23