Skip Menu |

This queue is for tickets about the Test-Trap CPAN distribution.

Report information
The Basics
Id: 127112
Status: resolved
Priority: 0/
Queue: Test-Trap

Owner: ebhanssen [...]
Requestors: TODDR [...]

Bug Information
Severity: Important
Broken in: v0.3.3
Fixed in: v0.3.4

Subject: Regression in 0.3.3 corrupts $!
Download (untitled) / with headers
text/plain 611b
Hi, I see in the discussion for you were trying to localize $!. From what we can tell, this change caused exactly the opposite behavior. A simplified test to show this problem is: $>perl -E 'use Test::More tests => 1; use Test::Trap; local $! = 42; trap { die bless [], "Foo" }; $trap->die_isa_ok("Foo"); print int($!) . " (should be 42)<--\n";' 1..1 ok 1 - An object of class 'Foo' isa 'Foo' 0 <-- (should be 42) In essence the localization in 0.3.3 seems to have actually corrupted $!. I will submit a suggested patch to work around this in a second.
Download (untitled) / with headers
text/plain 247b
This fixes the issue. We determined that your approach would have worked with any other localization. something seems to be special about $!. We're reporting that to perl RT for comment. regardless, I think this patch should be applied for 0.3.4
Subject: trap.patch.txt
Download trap.patch.txt
text/plain 559b
diff --git a/lib/Test/Trap/ b/lib/Test/Trap/ index d3da0c57c..5c1dde69b 100644 --- a/lib/Test/Trap/ +++ b/lib/Test/Trap/ @@ -165,7 +165,10 @@ BEGIN { # Test callback registration and test method generation: my $ok; local $trap->Prop->{test_accessor} = "$accessor->{name}($index)"; local $Test::Builder::Level = $Test::Builder::Level+1; - local($!, $^E) = ($!, $^E); + + my @copy = ($!, $^E); + local ($!, $^E) = @copy; + $ok = $test->{code}->(@targs) or $trap->TestFailure; $ok; };
Download (untitled) / with headers
text/plain 753b
Thank you! This was annoying. For one thing, because I was aware of this wrinkle of $! and should have seen it coming; for another because I wasn't even trying to localize $!: It was $^E I wanted to localize, and the only reason I had to localize $! as well, is that these are entangled somehow on Linux, where $^E is not even meaningful ... I've applied your patch (thanks!), and I've cut a release and uploaded it to CPAN. I'll hold off on closing the ticket until I see some (hopefully white) smoke from the new release. (I haven't changed much besides your patch and a test; just an author test and some metadata; but I know my Murphy ...) Eirik -- Eirik Berg Hanssen, Just this .sig then nothing more
Download (untitled) / with headers
text/plain 137b
Thanks for the fix. If you want to give me your github repo, I can provide you with a patch to test your commits with Todd
Subject: Re: [ #127112] Regression in 0.3.3 corrupts $!
Date: Mon, 15 Oct 2018 16:44:30 +0200
To: bug-Test-Trap [...]
From: The Sidhekin <sidhekin [...]>
Download (untitled) / with headers
text/plain 341b
On Mon, Oct 15, 2018 at 2:23 AM Todd Rinaldo via RT <> wrote: Show quoted text
> If you want to give me your github repo, I can provide you with a patch to > test your commits with >
Thank you, but I use Bitbucket (, not github, so won't work, AFAIK. Eirik
Download (untitled) / with headers
text/plain 212b
209 reports all PASS. Linux, Windows, Solaris, Darwin, various BSDs represented. Resolving. Thanks again! Eirik -- Eirik Berg Hanssen, Just this .sig then nothing more

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to