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:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to