here is the patch (against cvs) that allows you to:
'run-tests[=N[:mode]]' => ['run the tests',
{
N => 'repeat times',
mode => '(repeat|rotate|random)',
}],
the actual regex is more flexible and allows:
--run-tests[=[N][:][mode]]
-r=N:mode, -r=Nmode, -r=N, -r=mode, -r (-r == --run-tests)
should I adjust the usage? or make it more strict for users who don't look
at the source code :)
> - t/TEST -run-tests without =x will start/stop the server even it is
> already running (via t/TEST -start or -debug)
is it OK now?
> - doesn't work for all tests (when none are specified), i think
> Apache::TestHarness is where the x run-tests should be done to fix this.
fixed
> - something else to look into, a recent bug has been introduced, if
> t/TEST -run=2 starts the server, when $SIG{INT} is caught it should
> stop the server but does not at the moment.
I don't understand why would you want to do that. --run-tests is already a
non-standard execution, and when I debug it's quite nice to have the
server keep on running.
In any case, I think that this is not related to the change I'm
introducing. Was it different beforehand?
Now, Doug, try --run-tests=20random, I've seen about 8% failure rate.
Since you should be able to reproduce problems in the random mode, I
introduce yet another option --seed. When you run in the random mode, the
seed is printed. So:
- is it ok to add this option?
- -s is taken :) what option name can I use?
- I can do --run-tests=N:mode:seed but then it gets too cumbersome
_____________________________________________________________________
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/
--- Apache-Test/lib/Apache/TestHarness.pm.orig Sun Jun 24 18:04:34 2001
+++ Apache-Test/lib/Apache/TestHarness.pm Sun Jun 24 19:28:36 2001
@@ -3,6 +3,7 @@
use strict;
use warnings FATAL => 'all';
+use Apache::TestTrace;
use Test::Harness ();
use File::Spec::Functions qw(catfile);
use File::Find qw(finddepth);
@@ -57,6 +58,30 @@
push @tests, $t
}, '.');
}
+ }
+
+ my $times = $args->{times} || 1;
+ my $order = $args->{order} || 'rotate';
+
+ # reshuffle the test according to the requested mode
+ if ($order eq 'repeat') {
+ # a, a, b, b
+ @tests = map { ($_) x $times } @tests;
+ } elsif ($order eq 'rotate') {
+ # a, b, a, b
+ @tests = (@tests) x $times;
+ } elsif ($order eq 'random') {
+ # random
+ @tests = (@tests) x $times;
+ my $seed = time ^ ($$ + ($$ << 15));
+ warn "Using seed $seed\n";
+ # META: getting the seed from input?
+ srand($seed); # so we could reproduce the problem
+ my ($i,$j) = (0,0);
+ @tests[-$i,$j] = @tests[$j,-$i]
+ while $j = rand(@tests - $i), ++$i < @tests;
+ } else {
+ # nothing
}
Test::Harness::runtests(@tests);
--- Apache-Test/lib/Apache/TestRun.pm.orig Sun Jun 24 19:31:20 2001
+++ Apache-Test/lib/Apache/TestRun.pm Sun Jun 24 19:17:25 2001
@@ -12,7 +12,9 @@
use Getopt::Long qw(GetOptions);
use Config;
-my @std_run = qw(start-httpd run-tests stop-httpd);
+my @ctl_opts = qw(start-httpd stop-httpd);
+my @test_opts = qw(run-tests);
+my @std_run = (@ctl_opts, @test_opts);
my @others = qw(verbose configure clean help ping);
my @flag_opts = (@std_run, @others);
my @list_opts = qw(preamble postamble);
@@ -21,18 +23,22 @@
my @request_opts = qw(get head post);
my %usage = (
- 'start-httpd' => 'start the test server',
- 'run-tests' => 'run the tests',
- 'stop-httpd' => 'stop the test server',
- 'verbose' => 'verbose output',
- 'configure' => 'force regeneration of httpd.conf',
- 'clean' => 'remove all generated test files',
- 'help' => 'display this message',
- 'preamble' => 'config to add at the beginning of httpd.conf',
- 'postamble' => 'config to add at the end of httpd.conf',
- 'ping' => 'test if server is running or port in use',
- 'debug' => 'start server under debugger (e.g. gdb)',
- 'header' => "add headers to (".join('|', @request_opts).") request",
+ 'start-httpd' => 'start the test server',
+ 'run-tests[=N[:mode]]' => ['run the tests',
+ {
+ N => 'repeat times',
+ mode => '(repeat|rotate|random)',
+ }],
+ 'stop-httpd' => 'stop the test server',
+ 'verbose' => 'verbose output',
+ 'configure' => 'force regeneration of httpd.conf',
+ 'clean' => 'remove all generated test files',
+ 'help' => 'display this message',
+ 'preamble' => 'config to add at the beginning of httpd.conf',
+ 'postamble' => 'config to add at the end of httpd.conf',
+ 'ping' => 'test if server is running or port in use',
+ 'debug' => 'start server under debugger (e.g. gdb)',
+ 'header' => "add headers to (".join('|', @request_opts).") request",
(map { $_, "\U$_\E url" } @request_opts),
);
@@ -96,6 +102,7 @@
$self->{tests} = \@tests;
$self->{args} = \@args;
+
}
sub passenv {
@@ -116,12 +123,25 @@
my(%opts, %vopts, %conf_opts);
GetOptions(\%opts, @flag_opts, @exit_opts,
+ (map "$_:s", @test_opts),
(map "$_=s", @request_opts),
(map { ("$_=s", $vopts{$_} ||= []) } @list_opts),
(map { ("$_=s", $vopts{$_} ||= {}) } @hash_opts));
$opts{$_} = $vopts{$_} for keys %vopts;
+ # allow: -r=N:mode, -r=Nmode, -r=N, -r=mode, -r
+ if (exists $opts{'run-tests'}) {
+ $opts{'run-tests'} = 1 unless $opts{'run-tests'};
+ if ($opts{'run-tests'} =~
+ /^ (\d+)? :? (repeat|rotate|random)? $/x) {
+ $opts{'run-tests'} = int ($1 || 1);
+ $opts{'tests-order'} = $2;
+ } else {
+ $opts{'run-tests'} = 1;
+ }
+ }
+
#force regeneration of httpd.conf if commandline args want to modify it
$opts{configure} ||=
(grep { $opts{$_}->[0] } qw(preamble postamble)) ||
@@ -151,18 +171,19 @@
my $self = shift;
my($opts, $tests) = ($self->{opts}, $self->{tests});
- unless (grep { $opts->{$_} } @std_run, @request_opts) {
+ unless (grep { $opts->{$_} } @std_run, @test_opts, @request_opts) {
if (@$tests && $self->{server}->ping) {
#if certain tests are specified and server is running, dont restart
$opts->{'run-tests'} = 1;
}
else {
#default is server-server run-tests stop-server
- $opts->{$_} = 1 for @std_run;
+ $opts->{$_} = 1 for @std_run, @test_opts;
}
}
$opts->{'run-tests'} ||= @$tests;
+
}
my $caught_sig_int = 0;
@@ -259,6 +280,8 @@
my $test_opts = {
verbose => $self->{opts}->{verbose},
tests => $self->{tests},
+ times => $self->{opts}->{'run-tests'},
+ order => $self->{opts}->{'tests-order'},
};
#make sure we use an absolute path to perl
@@ -379,7 +402,14 @@
EOM
while (my($key, $val) = each %usage) {
- printf " -%-16s %s\n", $key, $val;
+ if (ref $val eq 'ARRAY') {
+ printf " -%-20s %s\n", $key, $val->[0];
+ my %sub_opts = %{ $val->[1] };
+ printf " %-14s %-6s: %s\n", '', $_, $sub_opts{$_}
+ for keys %sub_opts;
+ } else {
+ printf " -%-20s %s\n", $key, $val;
+ }
}
print "\n configuration options:\n";
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]