Skip Menu |

This queue is for tickets about the Modern-Perl CPAN distribution.

Report information
The Basics
Id: 131608
Status: resolved
Priority: 0/
Queue: Modern-Perl

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

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



Subject: incorrect test in t/base.t
base.t includes the following code: use Test::More 0.98; BEGIN { local $INC{'IO/File.pm'}; local $INC{'IO/Handle.pm'}; use_ok( 'Modern::Perl' ) or exit; ok exists $INC{'IO/File.pm'}, 'M::P should load IO::File'; ok exists $INC{'IO/Handle.pm'}, 'M::P should load IO::Handle'; Modern::Perl->import(); } This code appears to be trying to test that Modern::Perl loads IO::File and IO::Handle, but the exists check always passes, since local does not remove the keys from %INC, it even adds them if they don't exist. For example: # tested here with 5.28.1 $ perl -le '{ local $INC{"IO/Foo.pm"}; print exists $INC{"IO/Foo.pm"} }' 1 So the ok() always passes. This came up in blead[1] development due to a new patch[2] there. Previously only the special built-in undef (&PL_sv_undef) was treated as if a previous require has failed, so the undefs that local stored in your BEGIN block were treated by require as if the modules has been loaded, and loaded successfully. The recent change 4b004c4 made it so any undef value in %INC is treated by require as if the previous attempt to load the module had failed, not just for the special built-in undef. This allows code like: local %INC = %INC which copies those special undef keys to behave as expected with require. This means instead of the loads of IO::File and IO::Handle being treated as previously successful and require not attempting to load them, they're now treated as previously unsuccessful, and require throws an error. To ensure that the test does test what it appears to be trying to test, I suggest deleting those two keys, so that require will attempt to reload the modules, and the exists() check is useful. Tony [1] https://github.com/Perl/perl5/issues/17501 [2] https://github.com/Perl/perl5/commit/4b004c43ef26ce175181122a7dfc3acd7dacb170
Thanks for the report. Fixed in 1.20200201.