httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug MacEachern <>
Subject Re: [patch take2] add test skipping reasoning
Date Wed, 07 Nov 2001 19:21:15 GMT
On Thu, 8 Nov 2001, Stas Bekman wrote:
> that won't work. The condition argument must return a single value, or 
> it'll mess up the magic we have at the end of %args Test::plan expects.

right.  there's got to be a better solution to this than have to
check if the return value length == 1.
> Originally I've suggested to return a ref to a hash, since it wasn't 
> used yet. {$meets_condition => "failure reason"}.

that would still break expr if have_module(...);
> can you please explain why do you want to mix the two? What similarity 
> the two types have?

like in t/ssl/all.t:
plan tests => 1, [$vars->{ssl_module_name}, qw(LWP::Protocol::https)];

and t/modules/dav.t:
plan tests => 14, [qw(dav HTTP::DAV)];

don't want to have to write:
plan tests => 1, [have_module_c($vars->{ssl_module_name}),

plan tests => 14, [have_module_c('dav'), have_module_perl('HTTP::DAV')];
> I guess I don't understand you. What you have suggested earlier is to 
> add a special variable, so tests can set it if they have a reason to fail.
> First this requires changing tests to set the reason.

either way, as you've shown, requires a change to the test to set the
reason.  doesn't have to be a special variable, the point in the message
was simply that tests will need to be able to describe reasons why tests
are being skipped.

> 2. have a special class variable:
> $Test::FailureReason which can be set by any of have_foo functions on 
> failure and allows the test writer to set it as well.
>   This will allow us to keep tests simple and let have_foo subs to 
> report the reason, without taking away the flexibility of being able to 
> set this variable from within the test.

since the majority of tests will only skip tests based on have_foo not
being available, how about this.  an @Apache::Test::SkipReasons array,
where have_foo inside will push @SkipReasons, "..."; if foo is not
available.  then for the few special cases such as t/apache/getfile.t:

my $condition = sub { $perlpod };

Apache::Test::skip_reason("no .pod files in $vars->{perlpod}",
plan tests => @pods + keys(%other_files), $condition;

then skip_reason does this:

while (my($reason, $condition) = splice @_, 0, 2) {
    push @SkipReasons, $reason unless $condition->();

plan() in this case will see that $condition->() fails and the
reason(s) will already be present in @SkipReasons.

i just don't want to loose the current functionality of:

plan tests => $n, [qw(foo Bar::Baz)];


if (have_module('Foo::Bar')) {

View raw message