You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Module
Hash::Util aka ext/Hash-Util/lib/Hash/Util.pm
Test::More aka cpan/Test-Simple/lib/Test2/Formatter/TAP.pm (I have filed Test-More/test-more#907 for this part of the bug)
Description
ext/Hash-Util/t/Util.t contains the following code:
lock_keys(%ENV);
eval { () = $ENV{I_DONT_EXIST} };
like(
$@,
qr/^Attempt to access disallowed key 'I_DONT_EXIST' in a restricted hash/,
'locked %ENV'
);
unlock_keys(%ENV); # Test::Builder cannot print test failures otherwise
If this test fails then it will break Test::More (it says Test::Builder, but i think that is wrong these days) with a message like this:
Attempt to access disallowed key 'HARNESS_ACTIVE' in a restricted hash at lib/Test2/Formatter/TAP.pm line 121.
A context appears to have been destroyed without first calling release().
Based on $@ it does not look like an exception was thrown (this is not always
a reliable test)
This is a problem because the global error variables ($!, $@, and $?) will
not be restored. In addition some release callbacks will not work properly from
inside a DESTROY method.
Here are the context creation details, just in case a tool forgot to call
release():
File: ext/Hash-Util/t/Util.t
Line: 204
Tool: Test::More::like
It is debatable whether this is a failure in Test::More or Hash::Util. Arguably both. I noticed this while working on #20928 and i solved it by replacing the code with the following:
{
# Note we can't call like() while %ENV is locked, or we will get an explosion
# because of: Attempt to access unknown key 'HARNESS_ACTIVE' in a restricted hash
# at lib/Test2/Formatter/TAP.pm line 121.
# So we copy the error, and then do the like check on the copy.
lock_keys(%ENV);
eval { () = $ENV{I_DONT_EXIST} };
my $error = $@;
unlock_keys(%ENV);
like(
$error,
qr/^Attempt to access unknown key 'I_DONT_EXIST' in a restricted hash/,
'locked %ENV'
);
}
However this includes a change to the error message from locked hashes, so it can't be applied directly.
I will also file a bug with Test::More as this one is a bit debatable. Is expecting Test::More to deal with a locked %ENV reasonable? Should Test::More copy %ENV super early before any code can lock it? Should Hash::Util be changed as I did in my PR?
Steps to Reproduce
$ perl -MTest::More -MHash::Util=lock_hash -e'lock_hash(%ENV); is(1,2)'
Attempt to access disallowed key 'HARNESS_ACTIVE' in a restricted hash at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test2/Formatter/TAP.pm line 121.
A context appears to have been destroyed without first calling release().
Based on $@ it does not look like an exception was thrown (this is not always
a reliable test)
This is a problem because the global error variables ($!, $@, and $?) will
not be restored. In addition some release callbacks will not work properly from
inside a DESTROY method.
Here are the context creation details, just in case a tool forgot to call
release():
File: -e
Line: 1
Tool: Test::More::is
Here is a trace to the code that caused the context to be destroyed, this could
be an exit(), a goto, or simply the end of a scope:
Context destroyed at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test2/Formatter/TAP.pm line 121.
eval {...} called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test2/Formatter/TAP.pm line 121
Test::Builder::ok(Test::Builder=HASH(0x561e206dbac8), "", undef) called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test/Builder.pm line 982
Test::Builder::cmp_ok(Test::Builder=HASH(0x561e206dbac8), 1, "eq", 2, undef) called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test/Builder.pm line 820
Test::Builder::is_eq(Test::Builder=HASH(0x561e206dbac8), 1, 2) called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test/More.pm line 405
Test::More::is(1, 2) called at -e line 1
Cleaning up the CONTEXT stack...
A context appears to have been destroyed without first calling release().
Based on $@ it does not look like an exception was thrown (this is not always
a reliable test)
This is a problem because the global error variables ($!, $@, and $?) will
not be restored. In addition some release callbacks will not work properly from
inside a DESTROY method.
Here are the context creation details, just in case a tool forgot to call
release():
File: -e
Line: 1
Tool: Test::More::is
Here is a trace to the code that caused the context to be destroyed, this could
be an exit(), a goto, or simply the end of a scope:
Context destroyed at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test2/Formatter/TAP.pm line 121.
eval {...} called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test2/Formatter/TAP.pm line 121
Test::Builder::cmp_ok(Test::Builder=HASH(0x561e206dbac8), 1, "eq", 2, undef) called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test/Builder.pm line 820
Test::Builder::is_eq(Test::Builder=HASH(0x561e206dbac8), 1, 2) called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test/More.pm line 405
Test::More::is(1, 2) called at -e line 1
Cleaning up the CONTEXT stack...
A context appears to have been destroyed without first calling release().
Based on $@ it does not look like an exception was thrown (this is not always
a reliable test)
This is a problem because the global error variables ($!, $@, and $?) will
not be restored. In addition some release callbacks will not work properly from
inside a DESTROY method.
Here are the context creation details, just in case a tool forgot to call
release():
File: -e
Line: 1
Tool: Test::More::is
Here is a trace to the code that caused the context to be destroyed, this could
be an exit(), a goto, or simply the end of a scope:
Context destroyed at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test2/Formatter/TAP.pm line 121.
eval {...} called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test2/Formatter/TAP.pm line 121
Test::Builder::is_eq(Test::Builder=HASH(0x561e206dbac8), 1, 2) called at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test/More.pm line 405
Test::More::is(1, 2) called at -e line 1
Cleaning up the CONTEXT stack...
Attempt to access disallowed key 'HARNESS_ACTIVE' in a restricted hash at /home/yorton/perl5/perlbrew/perls/perl-5.34.1/lib/site_perl/5.34.1/Test2/Formatter/TAP.pm line 121.
END failed--call queue aborted.
Expected behavior
The test failing shouldn't completely break Test::More. :-)
Module
Hash::Util aka ext/Hash-Util/lib/Hash/Util.pm
Test::More aka cpan/Test-Simple/lib/Test2/Formatter/TAP.pm (I have filed Test-More/test-more#907 for this part of the bug)
Description
ext/Hash-Util/t/Util.t contains the following code:
If this test fails then it will break Test::More (it says Test::Builder, but i think that is wrong these days) with a message like this:
It is debatable whether this is a failure in Test::More or Hash::Util. Arguably both. I noticed this while working on #20928 and i solved it by replacing the code with the following:
However this includes a change to the error message from locked hashes, so it can't be applied directly.
I will also file a bug with Test::More as this one is a bit debatable. Is expecting Test::More to deal with a locked %ENV reasonable? Should Test::More copy %ENV super early before any code can lock it? Should Hash::Util be changed as I did in my PR?
Steps to Reproduce
Expected behavior
The test failing shouldn't completely break Test::More. :-)
Perl configuration
This isnt really relevant, but
The text was updated successfully, but these errors were encountered: