Oh, shame! It seems like I never attached the promised patch to this ticket. That has something to do with why I never had an answer from Michael or chromatic? ;-)
So I attach it now and forward this also to perl-qa as well. Another
possible idea is to leave ->has_plan as it is and add a new method
->has_any_plan documented as follows:
=item B<has_plan>
$plan = $Test->has_plan;
Find out whether a plan has been defined. $plan is either C<undef>
(no plan has been set), C<no_plan> (indeterminate # of tests),
or an integer (the number of expected tests).
Skip_all plans are handled as if no plan was set (but see
C<has_any_plan>).
=cut
[snip] [code of has_plan is unchanged]
=item B<has_any_plan>
$plan = $Test->has_any_plan;
Find out whether a plan has been defined. It works as C<has_plan>
but for C<skip_all> plans, it returns C<skip_all>.
=cut
sub has_any_plan {
my $self = shift;
return('skip_all') if $self->{Skip_All};
return $self->has_plan;
}
Comments? Ok, returning to Warnock state (this time it would not be my
sole fault as there is a patch now for real).
Adriano Ferreira
On 4/24/07, Bugs in Test-Simple via RT <[EMAIL PROTECTED]> wrote:
Greetings,
This message has been automatically generated in response to the
creation of a trouble ticket regarding:
"[PATCH] has_plan('any') to report a skip_all plan",
a summary of which appears below.
There is no need to reply to this message right now. Your ticket has been
assigned an ID of [rt.cpan.org #26615]. Your ticket is accessible
on the web at:
http://rt.cpan.org/Ticket/Display.html?id=26615
Please include the string:
[rt.cpan.org #26615]
in the subject line of all future correspondence about this issue. To do so,
you may reply to this message.
Thank you,
[EMAIL PROTECTED]
-------------------------------------------------------------------------
The attached patch is meant to solve the problem of determining if
any of these statements were executed under the current Test::Builder
instance
$builder->plan( tests => $n );
$builder->plan( 'no_plan' );
$builder->plan( skip_all => $reason );
The first two may be determined looking at the return of
$builder->has_plan;
But that is not the case for the skip_all plan. Actually you'll have to
look at the internal attribute $builder->{Skip_All} to determine this.
I started a thread at [email protected] about this and got responses from Ovid
and Adrian Howard that made me see that although skip_all looks
like a plan, it is special anyway.
http://www.nntp.perl.org/group/perl.qa/2007/04/msg8583.html
So my proposal is to leave " $builder->has_plan " as it is, but augment
its behavior if an explicit argument 'any' was given.
$builder->has_plan('any') => the expected number of tests, or
=> 'no_plan' or
=> 'skip_all'
I've touched the documentation as well. If this patch is not accepted,
at the least the phrase "Skip_all plans are handled as if no plan was set."
may be added to the has_plan description.
I've also inserted another test into t/skipall.t to check " has_plan('any') "
works.
Best regards,
Adriano Ferreira.
test-builder.diff
Description: Binary data
