randyk 2003/10/09 21:05:56
Modified: perl-framework/Apache-Test/lib/Bundle ApacheTest.pm
perl-framework/Apache-Test/lib/Apache TestSmoke.pm
TestServer.pm
perl-framework/Apache-Test Changes
Log:
Reviewed by: stas
- use IPC::Run3 in Apache::TestSmoke to run t/TEST commands, so
t/SMOKE can be used on Win32
- change way server is started in Apache::TestServer on Win32 so as to inherit
the calling processes handles, so Apache::TestSmoke can dup STDOUT/STDERR
- add message about server shudown in Apache::TestServer on Win32, as
Apache::TestSmoke expects it
Revision Changes Path
1.4 +2 -0
httpd-test/perl-framework/Apache-Test/lib/Bundle/ApacheTest.pm
Index: ApacheTest.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Bundle/ApacheTest.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ApacheTest.pm 14 Jul 2003 15:08:40 -0000 1.3
+++ ApacheTest.pm 10 Oct 2003 04:05:56 -0000 1.4
@@ -38,6 +38,8 @@
LWP - For libwww-perl
+IPC::Run3 - Used in Apache::TestSmoke
+
=head1 DESCRIPTION
This bundle lists all the CPAN modules used by Apache-Test.
1.24 +9 -31
httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmoke.pm
Index: TestSmoke.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmoke.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- TestSmoke.pm 12 Sep 2003 02:47:41 -0000 1.23
+++ TestSmoke.pm 10 Oct 2003 04:05:56 -0000 1.24
@@ -111,7 +111,7 @@
@{ $self->{tests} } = $self->get_tests($test_opts);
- $self->{base_command} = "./TEST";
+ $self->{base_command} = "$^X $FindBin::Bin/TEST";
# options common to all
$self->{base_command} .= " -verbose" if $self->{verbose};
@@ -461,6 +461,7 @@
}
sub run_test {
+ require IPC::Run3;
my($self, $iter, $count, $tests, $ra_ok) = @_;
my $bad = '';
my $ra_nok = [];
@@ -473,16 +474,9 @@
# start server
{
my $command = $self->{start_command};
- open my $pipe, "$command 2>&1|" or die "cannot fork: $!";
- my $oldfh = select $pipe; $| = 1; select $oldfh;
- # XXX: check startup success?
- my $started_ok = 0;
my $log = '';
- while (my $t = <$pipe>) {
- $started_ok = 1 if $t =~ /started/;
- $log .= $t;
- }
- close $pipe;
+ IPC::Run3::run3($command, undef, \$log, \$log);
+ my $started_ok = ($log =~ /started/) ? 1 : 0;
unless ($started_ok) {
error "failed to start server\n $log";
exit 1;
@@ -507,19 +501,10 @@
my $fill = "." x ($max_len - length $test_name);
$self->{total_tests_run}++;
- open my $pipe, "$command $test 2>&1|" or die "cannot fork: $!";
- my $oldfh = select $pipe; $| = 1; select $oldfh;
-
- my $ok = 0;
+ my $test_command = "$command $test";
my $log = '';
- while (<$pipe>) {
- $log .= $_;
-
- $ok = 1 if /All tests successful/;
- }
- # it's normal for $command to exit with a failure status if tests
- # fail, so we don't die/report it
- close $pipe;
+ IPC::Run3::run3($test_command, undef, \$log, \$log);
+ my $ok = ($log =~ /All tests successful/) ? 1 : 0;
my @core_files_msg =
$self->Apache::TestRun::scan_core_incremental;
@@ -594,16 +579,9 @@
# stop server
{
my $command = $self->{stop_command};
- open my $pipe, "$command 2>&1|" or die "cannot fork: $!";
- my $oldfh = select $pipe; $| = 1; select $oldfh;
- # XXX: check stopup success?
- my $stopped_ok = 0;
my $log = '';
- while (my $t = <$pipe>) {
- $stopped_ok = 1 if $t =~ /shutdown/;
- $log .= $t;
- }
- close $pipe;
+ IPC::Run3::run3($command, undef, \$log, \$log);
+ my $stopped_ok = ($log =~ /shutdown/) ? 1 : 0;
unless ($stopped_ok) {
error "failed to stop server\n $log";
exit 1;
1.67 +6 -1
httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm
Index: TestServer.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -r1.66 -r1.67
--- TestServer.pm 1 Oct 2003 13:45:23 -0000 1.66
+++ TestServer.pm 10 Oct 2003 04:05:56 -0000 1.67
@@ -316,12 +316,14 @@
if (Apache::TestConfig::WIN32) {
if ($self->{config}->{win32obj}) {
$self->{config}->{win32obj}->Kill(0);
+ warning "server $self->{name} shutdown";
return 1;
}
else {
require Win32::Process;
my $pid = $self->pid;
Win32::Process::KillProcess($pid, 0);
+ warning "server $self->{name} shutdown";
return 1;
}
}
@@ -440,10 +442,13 @@
my $one_process = $self->version_of(\%one_process);
require Win32::Process;
my $obj;
+ # We need the "1" below to inherit the calling processes
+ # handles when running Apache::TestSmoke so as to properly
+ # dup STDOUT/STDERR
Win32::Process::Create($obj,
$httpd,
"$cmd $one_process",
- 0,
+ 1,
Win32::Process::NORMAL_PRIORITY_CLASS(),
'.') || die Win32::Process::ErrorReport();
$config->{win32obj} = $obj;
1.52 +3 -0 httpd-test/perl-framework/Apache-Test/Changes
Index: Changes
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Changes,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- Changes 7 Oct 2003 19:12:18 -0000 1.51
+++ Changes 10 Oct 2003 04:05:56 -0000 1.52
@@ -8,6 +8,9 @@
=item 1.05-dev
+use IPC::Run3 in Apache::TestSmoke to run t/TEST commands,
+so as t/SMOKE can be used on Win32 [Stas, Steve Hay, Randy Kobes]
+
place mod_perl-specific directives in <IfModule> containers
within httpd.conf, allowing the default server to start if
mod_perl isn't present. [Geoffrey Young]