diff options
author | Carlos <carlos@multi> | 2012-12-29 02:09:08 +0800 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-01-03 21:33:06 -0600 |
commit | 386514ec675d3879c28b3f1164974b049c552a5e (patch) | |
tree | e0cb6dfab06f1898973a3c7791cfad72739ecd2c /t/bug-rt-78272.t | |
parent | bcc7f413d40988759ea3ee73f9beb52b299cf1bb (diff) | |
download | package-stash-386514ec675d3879c28b3f1164974b049c552a5e.tar.gz package-stash-386514ec675d3879c28b3f1164974b049c552a5e.zip |
Moves test to Test::Fatal instead of Test::Exception
Diffstat (limited to 't/bug-rt-78272.t')
-rw-r--r-- | t/bug-rt-78272.t | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/t/bug-rt-78272.t b/t/bug-rt-78272.t index 670782b..c2bfff4 100644 --- a/t/bug-rt-78272.t +++ b/t/bug-rt-78272.t @@ -1,33 +1,39 @@ use strict; use warnings; use Test::More tests => 1; -use Test::Exception; +use Test::Fatal; subtest 'Bug RT-78272: Arbitrary code execution from $ENV' => sub { # https://rt.cpan.org/Public/Bug/Display.html?id=78272 my $e = $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP; exit 1"; - throws_ok { - require Package::Stash; - } - qr/^Could not load Package::Stash::$e/, - 'Arbitrary code in $ENV throws exception'; - throws_ok { - delete $INC{'Package/Stash.pm'}; - require Package::Stash; - } - qr/^Could not load Package::Stash::$e/, - 'Sanity check: forcing package reload throws the exception again'; + like( + exception { require Package::Stash }, + qr/^Could not load Package::Stash::$e/, + 'Arbitrary code in $ENV throws exception' + ); - lives_ok { - $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP"; - delete $INC{'Package/Stash.pm'}; - require Package::Stash; - new_ok( - 'Package::Stash' => ['Foo'], - 'Loaded and able to create instances' - ); - } - 'Valid $ENV value loads correctly'; + like( + exception { + delete $INC{'Package/Stash.pm'}; + require Package::Stash; + }, + qr/^Could not load Package::Stash::$e/, + 'Sanity check: forcing package reload throws the exception again' + ); + + is( + exception { + $ENV{PACKAGE_STASH_IMPLEMENTATION} = "PP"; + delete $INC{'Package/Stash.pm'}; + require Package::Stash; + new_ok( + 'Package::Stash' => ['Foo'], + 'Loaded and able to create instances' + ); + }, + undef, + 'Valid $ENV value loads correctly' + ); }; |