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

People
Owner: ebhanssen [...] allverden.no
Requestors: TODDR [...] cpan.org
Cc:
AdminCc:

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 https://rt.cpan.org/Ticket/Display.html?id=105125 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/Builder.pm b/lib/Test/Trap/Builder.pm index d3da0c57c..5c1dde69b 100644 --- a/lib/Test/Trap/Builder.pm +++ b/lib/Test/Trap/Builder.pm @@ -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, ebhanssen@cpan.org 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 travis-ci.org Todd
Subject: Re: [rt.cpan.org #127112] Regression in 0.3.3 corrupts $!
Date: Mon, 15 Oct 2018 16:44:30 +0200
To: bug-Test-Trap [...] rt.cpan.org
From: The Sidhekin <sidhekin [...] gmail.com>
Download (untitled) / with headers
text/plain 341b
On Mon, Oct 15, 2018 at 2:23 AM Todd Rinaldo via RT < bug-Test-Trap@rt.cpan.org> 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 travis-ci.org >
Thank you, but I use Bitbucket (https://bitbucket.org/ebhanssen/test-trap), not github, so travis-ci.org 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, ebhanssen@cpan.org Just this .sig then nothing more


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.