You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2004/07/31 08:20:56 UTC

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

theory@apache.org wrote:
> theory      2004/07/30 19:43:33

>   +  # Always allow redirection.
>   +  my $redir = have_lwp ? [qw(GET HEAD POST)] : 1;
>   +  Apache::TestRequest::user_agent(reset => 1,
>   +                                  requests_redirectable => $redir);

Using have_ macros for non-plan() usage should be avoided, since it 
populates the SKIP messages array and if later the test is skipped, for 
a different reason it'll misleadingly tell the user that LWP was also a 
requirement for that test (which quite possibly could be what we want).

We need to fix that in general (since this issue is recurrent) and have 
a better way to handle requirements check+skip and only requirements 
check. Ideas?


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

David Wheeler wrote:
> On Jul 31, 2004, at 5:04 PM, Stas Bekman wrote:
> 
>>> I guess losing the skip message by making need_ functions that
>>> replace the existing have_ functions is okay. It's most important
>>> that tests continue to pass...
>>
>>
>> They will.
> 
> 
> Then I say we go with need.

I kind of favor this as well - it's really no big deal that have functions
will all of a sudden stop printing a skip message, and in doing so it will
encourage users that care to upgrade to the new function.

--Geoff


Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by David Wheeler <da...@kineticode.com>.
On Jul 31, 2004, at 5:04 PM, Stas Bekman wrote:

>> I guess losing the skip message by making need_ functions that 
>> replace the existing have_ functions is okay. It's most important 
>> that tests continue to pass...
>
> They will.

Then I say we go with need.

Regards,

David

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by Stas Bekman <st...@stason.org>.
David Wheeler wrote:
> On Jul 31, 2004, at 9:46 AM, Stas Bekman wrote:
> 
>> to me, got and have are exactly the same thing. How are you going to 
>> remember which one to use when?
> 
> 
> Yes, I will. :-)
> 
>> Authors of the existing tests don't have to change anything, have_foo 
>> will work just the same, but won't add the skip reason anymore. This 
>> won't make affect the existing tests in any way, rather than not 
>> printing the reason for a tests being skipped.
> 
> 
> Isn't that rather significant?

Significant, yes, but not critical. Most users aren't going to bother to 
figure out why tests were skipped and install optional modules required 
for the tests.

>> But, yes, the transition could be made 100% perfect, by keeping have_ 
>> as it is, and adding a new interface which doesn't add the skip 
>> reason. But we need to find an unambiguous name for it. skip_foo will 
>> be good, but we have a general function have(), which can't be 
>> replaced with skip(). So may be want_foo() is a better choice. Or may 
>> be you have a better name...
> 
> 
> I thought I did. Hrm...

Sorry, I was asking others to suggest too :)

>> or may be add must_have_*, so have_* is for checking, and must_have_* 
>> is checking and requiring. may be it's too long to type, but I like it.
> 
> 
> That's similar to have in the same way got is. Are you going to remember 
> which is which?

Yes, because one suggests a requirement and the other tells you what you 
have. While essentially the two are the same, the context is different. 
It's almost like 'require Foo' vs. 'eval { require Foo }'.

> I guess losing the skip message by making need_ functions that replace 
> the existing have_ functions is okay. It's most important that tests 
> continue to pass...

They will.


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by David Wheeler <da...@kineticode.com>.
On Jul 31, 2004, at 9:46 AM, Stas Bekman wrote:

> to me, got and have are exactly the same thing. How are you going to 
> remember which one to use when?

Yes, I will. :-)

> Authors of the existing tests don't have to change anything, have_foo 
> will work just the same, but won't add the skip reason anymore. This 
> won't make affect the existing tests in any way, rather than not 
> printing the reason for a tests being skipped.

Isn't that rather significant?

> But, yes, the transition could be made 100% perfect, by keeping have_ 
> as it is, and adding a new interface which doesn't add the skip 
> reason. But we need to find an unambiguous name for it. skip_foo will 
> be good, but we have a general function have(), which can't be 
> replaced with skip(). So may be want_foo() is a better choice. Or may 
> be you have a better name...

I thought I did. Hrm...

> or may be add must_have_*, so have_* is for checking, and must_have_* 
> is checking and requiring. may be it's too long to type, but I like 
> it.

That's similar to have in the same way got is. Are you going to 
remember which is which?

I guess losing the skip message by making need_ functions that replace 
the existing have_ functions is okay. It's most important that tests 
continue to pass...

Regards,

David

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
[...]
> But, yes, the transition could be made 100% perfect, by keeping have_ as 
> it is, and adding a new interface which doesn't add the skip reason. But 
> we need to find an unambiguous name for it. skip_foo will be good, but 
> we have a general function have(), which can't be replaced with skip(). 
> So may be want_foo() is a better choice. Or may be you have a better 
> name...

Sorry, that last para is contradicting itself. So again, I suggest to 
keep have_lwp, and remove the skip functionality from it, e.g.:

   # Always allow redirection.
   my $redir = have_lwp ? [qw(GET HEAD POST)] : 1; # no skip
   Apache::TestRequest::user_agent(reset => 1,
                                     requests_redirectable => $redir);

but having a new function that will be have_foo+skip:

plan tests => 5, need_lwp, need_cgi, need_php;

or:

plan tests => 5, want ['cgi', 'lwp'];

so require_ won't work too, as we will need a standalone word too. I 
think need_ or want_, or must_ pretty intuitive in the plan context.

or may be add must_have_*, so have_* is for checking, and must_have_* is 
checking and requiring. may be it's too long to type, but I like it.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by Stas Bekman <st...@stason.org>.
David Wheeler wrote:
> On Jul 31, 2004, at 1:14 AM, Stas Bekman wrote:
> 
>> so, have_foo is intuitive to be used anywhere in the code, and plan 
>> now will look like:
>>
>> plan tests => 5, need_lwp, need_cgi, need_php;
> 
> 
> I like this, but isn't it putting the onus of change on module owners 
> and introducing the likelihood of unexpected test failures when module 
> owners don't realize that they need to change their C<use> lines from 
> have_* to need_*?
> 
> Perhaps we leave have_* with its current semantics, but then add "got_*" 
> for the new semantics to be used anywhere in the code:
> 
>   # Always allow redirection.
>   my $redir = got_lwp ? [qw(GET HEAD POST)] : 1;
>   Apache::TestRequest::user_agent(reset => 1,
>                                     requests_redirectable => $redir);

to me, got and have are exactly the same thing. How are you going to 
remember which one to use when?

Authors of the existing tests don't have to change anything, have_foo 
will work just the same, but won't add the skip reason anymore. This 
won't make affect the existing tests in any way, rather than not 
printing the reason for a tests being skipped.

But, yes, the transition could be made 100% perfect, by keeping have_ as 
it is, and adding a new interface which doesn't add the skip reason. But 
we need to find an unambiguous name for it. skip_foo will be good, but 
we have a general function have(), which can't be replaced with skip(). 
So may be want_foo() is a better choice. Or may be you have a better 
name...

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by David Wheeler <da...@kineticode.com>.
On Jul 31, 2004, at 1:14 AM, Stas Bekman wrote:

> so, have_foo is intuitive to be used anywhere in the code, and plan 
> now will look like:
>
> plan tests => 5, need_lwp, need_cgi, need_php;

I like this, but isn't it putting the onus of change on module owners 
and introducing the likelihood of unexpected test failures when module 
owners don't realize that they need to change their C<use> lines from 
have_* to need_*?

Perhaps we leave have_* with its current semantics, but then add 
"got_*" for the new semantics to be used anywhere in the code:

   # Always allow redirection.
   my $redir = got_lwp ? [qw(GET HEAD POST)] : 1;
   Apache::TestRequest::user_agent(reset => 1,
                                     requests_redirectable => $redir);

Regards,

David

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>>Using have_ macros for non-plan() usage should be avoided, since it
>>populates the SKIP messages array and if later the test is skipped, for
>>a different reason it'll misleadingly tell the user that LWP was also a
>>requirement for that test (which quite possibly could be what we want).
>>
>>We need to fix that in general (since this issue is recurrent) and have
>>a better way to handle requirements check+skip and only requirements
>>check. Ideas?
> 
> 
> have_foo('bar', 1);  # don't populate @SkipReason
> 
> or
> 
> check_foo('bar');    # same as have_foo but don't populate @SkipReason
> 
> or a combination of both (where check_foo() is a wrapper around
> have_foo($a,1) and we keep the interface undocumented).

I'm in favor of having two distinct base names in order to keep things 
intuitive -- it's hard to remember what the extra argument in 
have_foo('bar', 1) means: should 1 add skip messages, or should it not...

My suggestion for the names selection:

have_foo # don't populate @SkipReason
need_foo # populate @SkipReason

so, have_foo is intuitive to be used anywhere in the code, and plan now 
will look like:

plan tests => 5, need_lwp, need_cgi, need_php;

or call it require_foo, or want_foo, or desire_foo, etc...



-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestRequest.pm

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Using have_ macros for non-plan() usage should be avoided, since it
> populates the SKIP messages array and if later the test is skipped, for
> a different reason it'll misleadingly tell the user that LWP was also a
> requirement for that test (which quite possibly could be what we want).
> 
> We need to fix that in general (since this issue is recurrent) and have
> a better way to handle requirements check+skip and only requirements
> check. Ideas?

have_foo('bar', 1);  # don't populate @SkipReason

or

check_foo('bar');    # same as have_foo but don't populate @SkipReason

or a combination of both (where check_foo() is a wrapper around
have_foo($a,1) and we keep the interface undocumented).

?

--Geoff