Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 28345
Status: resolved
Priority: 0/
Queue: Test-Simple

People
Owner: Nobody in particular
Requestors: a.r.ferreira [...] gmail.com
Cc:
AdminCc:

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



Subject: BEGIN { use_ok } may happen without a plan
Date: Tue, 17 Jul 2007 08:19:45 -0300
To: bug-Test-Simple [...] rt.cpan.org
From: "Adriano Ferreira" <a.r.ferreira [...] gmail.com>
Show quoted text
---------- Forwarded message ---------- From: Michael G Schwern <schwern@gmail.com> Date: Jul 24, 2006 12:08 AM Subject: Re: Test::More, BEGIN use_ok, plan, what? To: Adriano Ferreira <a.r.ferreira@gmail.com> Cc: perl-qa@perl.org On 7/21/06, Adriano Ferreira <a.r.ferreira@gmail.com> wrote:
> If I run this script > > use Test::More; > > plan tests => 2; > > BEGIN { use_ok( 'My', 'foo' ); } > > ok(1); > is(foo, 1); > > I got the output, which says nothing about the use_ok. It is not > counted as a test, it does not ruin the plan, it does its job > (requiring and importing a &foo subroutine). > > $ perl use_ok_ok.t > 1..2 > ok 1 > ok 2 > > Is this expected?
No. You should have gotten an error about lacking a plan. Its a bug. The trouble seems to be is that use_ok() is for some reason inside an "eval". $^S is set and there's an "eval" sub on the call stack. I don't know why. So the croak() about not having a plan gets eaten in the eval. Doesn't make a difference if I change it to a die(). I don't know how to work around this. I'm pretty sure its not Test::More's fault. PS perl-qa@perl.org is not the bug tracker for Test::More. http://rt.cpan.org is where you report bugs. Posting a "hey, is this a bug" on the mailing list is ok, but if it doesn't wind up in the bug tracker I am more likely to just drop it on the floor and never get around to it.
Show quoted text
> > use Test::More; > > > > plan tests => 2; > > > > BEGIN { use_ok( 'My', 'foo' ); }
To be clear, the critical pieces are... 1) A failing use_ok() inside a BEGIN block 2) No plan already set #2 is because "plan tests => 2" actually happens after the BEGIN block. use_ok() calls Test::Builder->ok() which calls Test::Builder->_plan_check. _plan_check() is correctly dying but the die is being eaten. $^S is undef at the point of the die.
Subject: Re: [rt.cpan.org #28345] BEGIN { use_ok } may happen without a plan
Date: Wed, 29 Aug 2007 13:49:46 -0300
To: bug-Test-Simple [...] rt.cpan.org
From: "Adriano Ferreira" <a.r.ferreira [...] gmail.com>
This bug report was turned into perlbug #44115 because Schwern suspected this was not an issue with Test::More but with the perl interpreter itself. http://rt.perl.org/rt3//Public/Bug/Display.html?id=44115 I've found that a minimum case could be constructed like this sub use_ok { my $module = shift; local($@); # isolate eval eval "require $module"; die "You tried to run a test without a plan!"; } BEGIN { use_ok('Foo'); } where ' eval "require $mode" ' was not important. Read below. Yitzchak Scott-Thoennes answered to this report by pointing the relevance of tickets #20823 and #18810. In the first, http://rt.perl.org/rt3/Public/Bug/Display.html?id=20823 we discover that the problem is the bug/behavior of perl when doing a localization of $@ in a eval/BEGIN block followed by a die. $ perl -e ' BEGIN { local $@; die "now" }; print "ok" ' ok In the second, Abigail reported the same behavior in Test::More and Yitzchak provided a patch, that was never applied according to history of file "lib/Test/More.pm" (as seen here: http://public.activestate.com/cgi-bin/perlbrowse/l/lib/Test/More.pm@30711 ). This patch is repeated here. It is important because it works around the limitation of perl along a full horizon of versions ranging from 5.6, 5.8 and the soon-to-be 5.10 release. Regards, Adriano Ferreira On 7/23/07, Michael G Schwern via RT <bug-Test-Simple@rt.cpan.org> wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=28345 > >
> > > use Test::More; > > > > > > plan tests => 2; > > > > > > BEGIN { use_ok( 'My', 'foo' ); }
> > To be clear, the critical pieces are... > > 1) A failing use_ok() inside a BEGIN block > 2) No plan already set > > #2 is because "plan tests => 2" actually happens after the BEGIN block. > > use_ok() calls Test::Builder->ok() which calls > Test::Builder->_plan_check. _plan_check() is correctly dying but the > die is being eaten. $^S is undef at the point of the die. >

Message body is not shown because sender requested not to inline it.

Thanks, I've applied that patch and it'll be in the next release.