You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2001/09/21 12:35:47 UTC

[patch] correcting the tests extracting from @ARGV

Please consider the following scenario:

% ./t/TEST -clean
% ./t/TEST api

In the current setup, -clean deletes all autogenerated test files. Now the
second command is supposed to run all tests in t/api, but alas, most of
them weren't created yet, when the directory t/api is scanned for
t/api/*.t. Hence most of the tests won't be run.

The following patch fixes that, but it enforces something that wasn't
enforced so far. The configuration options has to start with - or -- to be
accepted, just like ./t/TEST -help advertises. So we have to fix the docs
to use '-apxs foo' and not just 'apxs foo'.

I know it's probably hard to change habits, but the current setup is not
clean, since you may miss a lot of tests, when you think you've run them
all. Since we aim to have Apache::Test working for other projects, I think
it'd be great to fix it as early as possible. I'll fix the docs if
accepted (including httpd-test).

So the new setup parses @ARGV 3 times

 1. GetOptions (options)
 2. Configuration options
 3. test files/dirs

The stage 3 happens only after the server is ready to run, i.e. when all
the auto-generated tests are created already, so t/api/*.t will pick all
the tests.

There is one more flow that I've noticed -- if you run:
./t/TEST apxs foo/bar
after the configuration has been built already, the new values don't take
effect and simply ignored. I think they should cause refresh.

Here is the patch:

Index: Apache-Test/lib/Apache/TestRun.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.51
diff -u -r1.51 TestRun.pm
--- Apache-Test/lib/Apache/TestRun.pm	2001/09/06 05:02:51	1.51
+++ Apache-Test/lib/Apache/TestRun.pm	2001/09/21 10:27:19
@@ -75,12 +75,12 @@
 #so we dont slurp arguments that are not tests, example:
 # httpd $HOME/apache-2.0/bin/httpd

-sub split_args {
-    my($self, $argv) = @_;
+sub split_test_args {
+    my($self) = @_;

-    my(@tests, @args);
+    my(@tests);

-    for (@$argv) {
+    for (@ARGV) {
         my $arg = $_;
         #need the t/ for stat-ing, but dont want to include it in test output
         $arg =~ s:^t/::;
@@ -109,12 +109,9 @@
                 next;
             }
         }
-
-        push @args, $_;
     }

     $self->{tests} = \@tests;
-    $self->{args}  = \@args;
 }

 sub passenv {
@@ -128,12 +125,13 @@
 sub getopts {
     my($self, $argv) = @_;

-    $self->split_args($argv);
-
-    #dont count test files/dirs as @ARGV arguments
-    local *ARGV = $self->{args};
     my(%opts, %vopts, %conf_opts);

+    # no_permute  : an opt. value cannot come before the option
+    # pass_through: all unknown things are to be left in @ARGV
+    Getopt::Long::Configure(qw(pass_through no_permute));
+
+    # grab from @ARGV only the options that we expect
     GetOptions(\%opts, @flag_opts, @help_opts,
                (map "$_:s", @debug_opts, @request_opts, @ostring_opts),
                (map "$_=s", @string_opts),
@@ -149,9 +147,18 @@
         (grep { $Apache::TestConfig::Usage{$_} } @ARGV) ||
           $self->passenv() || (! -e 'conf/httpd.conf');

-    while (my($key, $val) = splice @ARGV, 0, 2) {
-       $conf_opts{lc $key} = $val;
+    # split configuration options and test files/dirs
+    my @argv = ();
+    while (@ARGV) {
+        my $val = shift @ARGV;
+        if ($val =~ s/^--?//) {
+            $conf_opts{lc $val} = shift @ARGV || '';
+        }
+        else {
+            push @argv, $val;
+        }
     }
+    @ARGV = @argv;

     if (exists $opts{debug}) {
         $opts{debugger} = $opts{debug};
@@ -469,6 +476,8 @@
     $self->try_exit_opts;

     $self->default_run_opts;
+
+    $self->split_test_args;

     $self->start;


_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] correcting the tests extracting from @ARGV

Posted by Doug MacEachern <do...@covalent.net>.
On Sat, 22 Sep 2001, Stas Bekman wrote:
 
> I've fixed this problem and committed the new functionality.

cool.
 
> Now, I think we should enforce a leading - and not allow plain words. 
> Consider a situation where there is a test dir called apxs, because we 
> decided to test apxs. In the current setup this would be impossible. 
> (just like in the previous, if this dir was autogenerated)

not too worried about that, but forcing - or -- is fine.
 
> There are more problems that I've notices. e.g.:
> If I build perl Makefile.PL with prefork mod_perl, but then run the test 
> with the threaded one
> ./t/TEST -apxs /home/stas/httpd/threaded/bin/apxs
> 
> the configuration changes partially, e.g. Apache::BuildConfig doesn't 
> change. So if you run 'perl build/config.pl' you get the prefork options 
> and not the new ones passed via apxs. This is how it was before I've 
> committed my latest change.

Apache::BuildConfig shouldn't change in this case.  prefork is still the
apxs you used to _compile_ modperl.  you only change apxs for the tests to
find a different httpd.
 
> I'm kinda unsure what the ./t/TEST configuration option are supposed to 
> do. What's the scope of the change and etc. It doesn't seem clean to me.

Apache::BuildConfig and t/TEST are two different things.  t/TEST only uses
Apache::BuildConfig as a hint to find apxs if not specified elsewhere.
 
> Another problem: If I try to override configuration options in 
> httpd-test/perl-framework they are ignored. Again, tested with the new 
> TestRun.pm and the old one -- I see the same behavior. Try:
> 
> % /home/stas/perl/ithread/bin/perl5.7.2 Makefile.PL apxs 
> /home/stas/httpd/prefork/bin/apxs
> % ./t/TEST
> % ./t/TEST apxs /home/stas/httpd/threaded/bin/apxs
> 
> it still invokes the prefork server, I cannot figure out why...

works fine for me, as it always has.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] correcting the tests extracting from @ARGV

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Fri, 21 Sep 2001, Stas Bekman wrote:
> 
> 
>>Please consider the following scenario:
>>
>>% ./t/TEST -clean
>>% ./t/TEST api
>>
>>In the current setup, -clean deletes all autogenerated test files. Now the
>>second command is supposed to run all tests in t/api, but alas, most of
>>them weren't created yet, when the directory t/api is scanned for
>>t/api/*.t. Hence most of the tests won't be run.
>>
>>The following patch fixes that, but it enforces something that wasn't
>>enforced so far. The configuration options has to start with - or -- to be
>>accepted, just like ./t/TEST -help advertises. So we have to fix the docs
>>to use '-apxs foo' and not just 'apxs foo'.
>>
>>I know it's probably hard to change habits, but the current setup is not
>>clean, since you may miss a lot of tests, when you think you've run them
>>all. Since we aim to have Apache::Test working for other projects, I think
>>it'd be great to fix it as early as possible. I'll fix the docs if
>>accepted (including httpd-test).
>>
> 
> that sounds fine.
>  
> 
>>So the new setup parses @ARGV 3 times
>>
>> 1. GetOptions (options)
>> 2. Configuration options
>> 3. test files/dirs
>>
>>The stage 3 happens only after the server is ready to run, i.e. when all
>>the auto-generated tests are created already, so t/api/*.t will pick all
>>the tests.
>>
>>There is one more flow that I've noticed -- if you run:
>>./t/TEST apxs foo/bar
>>after the configuration has been built already, the new values don't take
>>effect and simply ignored. I think they should cause refresh.
>>
> 
> yes it should, and does for me in current cvs.  could be your patch
> changed that behavior?  please make sure your patch does not break that
> feature.


I've fixed this problem and committed the new functionality.

Note that I still allow configuration options without leading - or --, 
but at the same time I allow now those with - or -- as we advertise in 
the output of ./t/TEST --help

Now, I think we should enforce a leading - and not allow plain words. 
Consider a situation where there is a test dir called apxs, because we 
decided to test apxs. In the current setup this would be impossible. 
(just like in the previous, if this dir was autogenerated)

There are more problems that I've notices. e.g.:
If I build perl Makefile.PL with prefork mod_perl, but then run the test 
with the threaded one
./t/TEST -apxs /home/stas/httpd/threaded/bin/apxs

the configuration changes partially, e.g. Apache::BuildConfig doesn't 
change. So if you run 'perl build/config.pl' you get the prefork options 
and not the new ones passed via apxs. This is how it was before I've 
committed my latest change.

I'm kinda unsure what the ./t/TEST configuration option are supposed to 
do. What's the scope of the change and etc. It doesn't seem clean to me.

Another problem: If I try to override configuration options in 
httpd-test/perl-framework they are ignored. Again, tested with the new 
TestRun.pm and the old one -- I see the same behavior. Try:

% /home/stas/perl/ithread/bin/perl5.7.2 Makefile.PL apxs 
/home/stas/httpd/prefork/bin/apxs
% ./t/TEST
% ./t/TEST apxs /home/stas/httpd/threaded/bin/apxs

it still invokes the prefork server, I cannot figure out why...

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] correcting the tests extracting from @ARGV

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Fri, 21 Sep 2001, Stas Bekman wrote:
> 
> 
>>Please consider the following scenario:
>>
>>% ./t/TEST -clean
>>% ./t/TEST api
>>
>>In the current setup, -clean deletes all autogenerated test files. Now the
>>second command is supposed to run all tests in t/api, but alas, most of
>>them weren't created yet, when the directory t/api is scanned for
>>t/api/*.t. Hence most of the tests won't be run.
>>
>>The following patch fixes that, but it enforces something that wasn't
>>enforced so far. The configuration options has to start with - or -- to be
>>accepted, just like ./t/TEST -help advertises. So we have to fix the docs
>>to use '-apxs foo' and not just 'apxs foo'.
>>
>>I know it's probably hard to change habits, but the current setup is not
>>clean, since you may miss a lot of tests, when you think you've run them
>>all. Since we aim to have Apache::Test working for other projects, I think
>>it'd be great to fix it as early as possible. I'll fix the docs if
>>accepted (including httpd-test).
>>
> 
> that sounds fine.


great!

 
>>So the new setup parses @ARGV 3 times
>>
>> 1. GetOptions (options)
>> 2. Configuration options
>> 3. test files/dirs
>>
>>The stage 3 happens only after the server is ready to run, i.e. when all
>>the auto-generated tests are created already, so t/api/*.t will pick all
>>the tests.
>>
>>There is one more flow that I've noticed -- if you run:
>>./t/TEST apxs foo/bar
>>after the configuration has been built already, the new values don't take
>>effect and simply ignored. I think they should cause refresh.
>>
> 
> yes it should, and does for me in current cvs.  could be your patch
> changed that behavior?  please make sure your patch does not break that
> feature.

My patch postpones the tests probing until the latest possible but 
doesn't change anything else. But I'll test again before I commit.

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [patch] correcting the tests extracting from @ARGV

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 21 Sep 2001, Stas Bekman wrote:

> 
> Please consider the following scenario:
> 
> % ./t/TEST -clean
> % ./t/TEST api
> 
> In the current setup, -clean deletes all autogenerated test files. Now the
> second command is supposed to run all tests in t/api, but alas, most of
> them weren't created yet, when the directory t/api is scanned for
> t/api/*.t. Hence most of the tests won't be run.
> 
> The following patch fixes that, but it enforces something that wasn't
> enforced so far. The configuration options has to start with - or -- to be
> accepted, just like ./t/TEST -help advertises. So we have to fix the docs
> to use '-apxs foo' and not just 'apxs foo'.
> 
> I know it's probably hard to change habits, but the current setup is not
> clean, since you may miss a lot of tests, when you think you've run them
> all. Since we aim to have Apache::Test working for other projects, I think
> it'd be great to fix it as early as possible. I'll fix the docs if
> accepted (including httpd-test).

that sounds fine.
 
> So the new setup parses @ARGV 3 times
> 
>  1. GetOptions (options)
>  2. Configuration options
>  3. test files/dirs
> 
> The stage 3 happens only after the server is ready to run, i.e. when all
> the auto-generated tests are created already, so t/api/*.t will pick all
> the tests.
> 
> There is one more flow that I've noticed -- if you run:
> ./t/TEST apxs foo/bar
> after the configuration has been built already, the new values don't take
> effect and simply ignored. I think they should cause refresh.

yes it should, and does for me in current cvs.  could be your patch
changed that behavior?  please make sure your patch does not break that
feature.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org