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.