httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: Apache-Test breakage
Date Wed, 17 Oct 2001 09:28:07 GMT
Doug MacEachern wrote:

> hi stas, two problems cause by the recentish argv changes you made:
>
> 1) see the thread with ken on the test list:
>
>
>>t/TEST -httpd /path/to/httpd -start
>>
>>starts the server, and then runs all the tests.
>>
>
> looks like recent breakage, args picked up by GetOptions in
> Apache::PerlRun::getopts are being force to come before other options.
> stas can you please fix this.
> in the meantime ken, this will work:
> t/TEST -start -httpd /path/to/httpd

this was a simple fix, I've misread the explanation of the permute option
for Getopts, the fix is:

 -Getopt::Long::Configure(qw(pass_through no_permute));
 +Getopt::Long::Configure(qw(pass_through permute));

permute is enabled by default, but I prefer to explictly specify it since
the environment variable POSIXLY_CORRECT can disable the default.

> 2) args meant for Apache::TestRequest are dropped on the floor, so this
no
> longer works:
>
> t/TEST -post /echo_post -content one=1
>
> nor does
>
> t/TEST -get /authany -username dougm -password dougm
>
> if you need to know which args Apache::TestRequest recognizes, this
> function returns a hash ref:
> Apache::TestRequest::wanted_args()

that's right, I've missed the fact that we have 4 different opts groups in
ARGV :( I've tested only 3 of them.

I've added a support for the TestRequest opts now.

The tests are still correctly looked up as late as possible, so that the
autogenerated tests will have a chance to get created before tested for
existence.

>>t/TEST -proxy t/foo/bar.t
>>
>>runs all of the tests, rather that just the single specified test.
>>also does not run the tests through the proxy.  :(
>
> this may or may not be releated to the patch, cvs.apache.org is very
> slow right now.

I see exactly the same behavior with my patch and without, so I guess it
was broken before.

Here is the patch that fixes the 2 problems you've raised:

? diff
? patch
? run
? run.prefork
? run.prefork.5.6.1
? run.threaded
? run.worker
? Apache-Test/t/TEST
? ModPerl-Registry/Makefile
? ModPerl-Registry/pm_to_blib
? ModPerl-Registry/t/TEST
Index: Apache-Test/README
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/README,v
retrieving revision 1.13
diff -u -r1.13 README
--- Apache-Test/README	2001/10/17 01:30:40	1.13
+++ Apache-Test/README	2001/10/17 09:18:31
@@ -7,6 +7,9 @@

 see t/TEST as an example test harness

+For an extensive documentation see
+modperl-2.0/docs/src/devel/writing_tests/writing_tests.pod.
+
 see t/*.t for example tests

 if the file t/conf/httpd.conf.in exists, it will be used instead of
@@ -45,16 +48,16 @@
 % t/TEST -configure

 run as user nobody:
-% t/TEST User nobody
+% t/TEST -User nobody

 run on a different port:
-% t/TEST Port 8799
+% t/TEST -Port 8799

 configure an httpd other than the default (that apxs figures out)
-% t/TEST httpd ~/ap/httpd-2.0/httpd
+% t/TEST -httpd ~/ap/httpd-2.0/httpd

 switch to another apxs
-% t/TEST apxs ~/ap/httpd-2.0-prefork/bin/apxs
+% t/TEST -apxs ~/ap/httpd-2.0-prefork/bin/apxs

 turn on tracing
 % t/TEST -preamble "PerlTrace all"
@@ -69,19 +72,19 @@
 % t/TEST -head

 GET url with authentication credentials
-% t/TEST -get /server-info username dougm password foo
+% t/TEST -get /server-info -username dougm -password foo

 POST url (read content from string)
-% t/TEST -post /TestApache::post content 'name=dougm&company=covalent'
+% t/TEST -post /TestApache::post -content 'name=dougm&company=covalent'

 POST url (read content from stdin)
-% t/TEST -post /TestApache::post content - < foo.txt
+% t/TEST -post /TestApache::post -content - < foo.txt

 POST url (generate a body of data 1024 bytes in length)
-% t/TEST -post /TestApache::post content x1024
+% t/TEST -post /TestApache::post -content x1024

 POST url (only print headers, e.g. useful to just check Content-length)
-% t/TEST -post -head /TestApache::post content x100000
+% t/TEST -post -head /TestApache::post -content x100000

 GET url (only print headers, e.g. useful to just check Content-length)
 % t/TEST -get -head /foo
Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.74
diff -u -r1.74 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm	2001/10/17 01:30:40	1.74
+++ Apache-Test/lib/Apache/TestConfig.pm	2001/10/17 09:18:31
@@ -68,8 +68,9 @@
     }

     while (my($key, $val) = splice @filter, 0, 2) {
-        if ($wanted_args->{$key}) {
-            $keep{$key} = $val;
+        if ($key =~ /^-?-?(.+)/ # optinal - or -- prefix
+            && exists $wanted_args->{$1}) {
+            $keep{$1} = $val;
         }
         else {
             push @pass, $key, $val;
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.59
diff -u -r1.59 TestRun.pm
--- Apache-Test/lib/Apache/TestRun.pm	2001/10/17 02:56:24	1.59
+++ Apache-Test/lib/Apache/TestRun.pm	2001/10/17 09:18:31
@@ -82,12 +82,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/::;
@@ -116,12 +116,9 @@
                 next;
             }
         }
-
-        push @args, $_;
     }

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

 sub passenv {
@@ -135,12 +132,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);

+    # permute      : optional values can come before the options
+    # pass_through : all unknown things are to be left in @ARGV
+    Getopt::Long::Configure(qw(pass_through 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),
@@ -150,16 +148,38 @@

     $opts{$_} = $vopts{$_} for keys %vopts;

-    #force regeneration of httpd.conf if commandline args want to modify it
+    # separate configuration options and test files/dirs
+    my $req_wanted_args = Apache::TestRequest::wanted_args();
+    my @argv = ();
+    my %req_args = ();
+    while (@ARGV) {
+        my $val = shift @ARGV;
+        if ($val =~ /^--?(.+)/) { # must have a leading - or --
+            my $key = lc $1;
+            # a known config option?
+            if (exists $Apache::TestConfig::Usage{$key}) {
+                $conf_opts{$key} = shift @ARGV;
+            } # a TestRequest config option?
+            elsif (exists $req_wanted_args->{$key}) {
+                $req_args{$key} = shift @ARGV;
+            }
+        }
+        else {
+            push @argv, $val;
+        }
+    }
+
+    $opts{req_args} = \%req_args;
+
+    # @ARGV now includes only test files/dirs if any at all
+    @ARGV = @argv;
+
+    # force regeneration of httpd.conf if commandline args want to modify it
     $self->{reconfigure} = $opts{configure} ||
       (grep { $opts{$_}->[0] } qw(preamble postamble)) ||
-        (grep { $Apache::TestConfig::Usage{$_} } @ARGV) ||
+        (grep { $Apache::TestConfig::Usage{$_} } keys %conf_opts ) ||
           $self->passenv() || (! -e 'conf/httpd.conf');

-    while (my($key, $val) = splice @ARGV, 0, 2) {
-       $conf_opts{lc $key} = $val;
-    }
-
     if (exists $opts{debug}) {
         $opts{debugger} = $opts{debug};
         $opts{debug} = 1;
@@ -494,6 +514,8 @@

     $self->default_run_opts;

+    $self->split_test_args;
+
     $self->start;

     $self->run_tests;
@@ -538,14 +560,7 @@
 sub run_request {
     my($test_config, $opts) = @_;

-    my @args = %{ $opts->{header} };
-    my $wanted_args = Apache::TestRequest::wanted_args();
-
-    while (my($key, $val) = each %{ $test_config->{vars} }) {
-        next unless $wanted_args->{$key};
-        push @args, $key, $val;
-        delete $test_config->{vars}->{$key}; #dont save these
-    }
+    my @args = (%{ $opts->{header} }, %{ $opts->{req_args} });

     my($request, $url) = ("", "");





_____________________________________________________________________
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://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Mime
View raw message