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 2003/09/16 20:59:05 UTC

t/SMOKE on win32

Trying to spread unrelated topics into different threads, otherwise it's a mess:

Steve Hay wrote:
 > I tried running "perl t/SMOKE" but I just get this:
 >
 > =====
 > C:\Temp\modperl-2.0>perl t/SMOKE
 > *** Using random number seed: 1012582729 (autogenerated)
 > ***
 > ------------------------------------------------------------
 > *** [001-00-00] trying all tests 10 times
 > !!! failed to start server
 > '.' is not recognized as an internal or external command,
 > operable program or batch file.
 > =====

Yup, it needs tweaking to run on win32.

Randy wrote:
 > Try changing this to "$^X /path/to/modperl-2.0/t/TEST".
 > However, when I tried running this it *seemed* to hang;
 > but I may have just been too impatient, or tired ...

What do you mean hanging? have you tried adding the -verbose flag? Did it 
start the server? Did it start running the first tests?


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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


Re: t/SMOKE on win32

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
> On Wed, 17 Sep 2003, Stas Bekman wrote:
> 
> 
>>Randy Kobes wrote:
>>[...]
>>
>>>>I tried "perl t/SMOKE -verbose=1" and it makes no difference.
>>
>>it's a problem inside t/SMOKE which invokes t/TEST internally.
>>
>>
>>>>It kicks off an Apach.exe which eats a bit of CPU for a short while and
>>>>then everything goes quiet.  Apache.exe stays sitting there, but doesn't
>>>>seem to do anything else.  I left it for nearly 2 hours and nothing
>>>>happened.
>>>
>>>
>>>The problem here I believe is the use of pipes to launch the
>>>tests. I'm working on, for Win32, the use of Win32::Process
>>>instead - it's almost working, in that I can get the server
>>>to start up and run, but there's a couple of things to iron
>>>out, which hopefully won't take long.
>>
>>No, no, no, is it possible to keep the win32-specific code
>>away, it makes the code totally unreadable and
>>unmaintainable :( Randy, how about using IPC::Run, which
>>seems to work fine everywhere. I don't mind t/SMOKE to
>>depend on optional modules, which we didn't want for
>>t/TEST.
> 
> 
> For me, on WinXP, IPC::Run fails a sufficient number of its
> tests to be worrisome. And it reportedly doesn't work at all
> on Win95, and probably not on Win98 either.

in that case we have no choice but to use Win32::Process ;) Thanks Randy!

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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


Re: t/SMOKE on win32

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Wed, 17 Sep 2003, Stas Bekman wrote:

> Randy Kobes wrote:
> [...]
> >>I tried "perl t/SMOKE -verbose=1" and it makes no difference.
>
> it's a problem inside t/SMOKE which invokes t/TEST internally.
>
> >>It kicks off an Apach.exe which eats a bit of CPU for a short while and
> >>then everything goes quiet.  Apache.exe stays sitting there, but doesn't
> >>seem to do anything else.  I left it for nearly 2 hours and nothing
> >>happened.
> >
> >
> > The problem here I believe is the use of pipes to launch the
> > tests. I'm working on, for Win32, the use of Win32::Process
> > instead - it's almost working, in that I can get the server
> > to start up and run, but there's a couple of things to iron
> > out, which hopefully won't take long.
>
> No, no, no, is it possible to keep the win32-specific code
> away, it makes the code totally unreadable and
> unmaintainable :( Randy, how about using IPC::Run, which
> seems to work fine everywhere. I don't mind t/SMOKE to
> depend on optional modules, which we didn't want for
> t/TEST.

For me, on WinXP, IPC::Run fails a sufficient number of its
tests to be worrisome. And it reportedly doesn't work at all
on Win95, and probably not on Win98 either.

-- 
best regards,
randy

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


Re: t/SMOKE on win32

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
[...]
>>I tried "perl t/SMOKE -verbose=1" and it makes no difference.

it's a problem inside t/SMOKE which invokes t/TEST internally.

>>It kicks off an Apach.exe which eats a bit of CPU for a short while and
>>then everything goes quiet.  Apache.exe stays sitting there, but doesn't
>>seem to do anything else.  I left it for nearly 2 hours and nothing
>>happened.
> 
> 
> The problem here I believe is the use of pipes to launch the
> tests. I'm working on, for Win32, the use of Win32::Process
> instead - it's almost working, in that I can get the server
> to start up and run, but there's a couple of things to iron
> out, which hopefully won't take long.

No, no, no, is it possible to keep the win32-specific code away, it makes the 
code totally unreadable and unmaintainable :( Randy, how about using IPC::Run, 
which seems to work fine everywhere. I don't mind t/SMOKE to depend on 
optional modules, which we didn't want for t/TEST.

p.s. sorry for being grumpy about win32, it's certainly not your fault.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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


Re: t/SMOKE on win32

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Wed, 17 Sep 2003, Steve Hay wrote:

> Stas Bekman wrote:
>
> > Trying to spread unrelated topics into different threads, otherwise
> > it's a mess:
>
> Guilty as charged m'lud :-)
>
> >
> >
> > Steve Hay wrote:
> > > I tried running "perl t/SMOKE" but I just get this:
> > >
> > > =====
> > > C:\Temp\modperl-2.0>perl t/SMOKE
> > > *** Using random number seed: 1012582729 (autogenerated)
> > > ***
> > > ------------------------------------------------------------
> > > *** [001-00-00] trying all tests 10 times
> > > !!! failed to start server
> > > '.' is not recognized as an internal or external command,
> > > operable program or batch file.
> > > =====
> >
> > Yup, it needs tweaking to run on win32.
> >
> > Randy wrote:
> > > Try changing this to "$^X /path/to/modperl-2.0/t/TEST".
> > > However, when I tried running this it *seemed* to hang;
> > > but I may have just been too impatient, or tired ...

A more portable solution to this (I think) is using
$FindBin::Bin (which has already been used earlier) - I'll
make up a patch for this.

> > What do you mean hanging? have you tried adding the -verbose flag? Did
> > it start the server? Did it start running the first tests?
>
> I tried "perl t/SMOKE -verbose=1" and it makes no difference.
>
> It kicks off an Apach.exe which eats a bit of CPU for a short while and
> then everything goes quiet.  Apache.exe stays sitting there, but doesn't
> seem to do anything else.  I left it for nearly 2 hours and nothing
> happened.

The problem here I believe is the use of pipes to launch the
tests. I'm working on, for Win32, the use of Win32::Process
instead - it's almost working, in that I can get the server
to start up and run, but there's a couple of things to iron
out, which hopefully won't take long.

-- 
best regards,
randy

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


Re: t/SMOKE on win32

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
>> Patches are welcome.
>>
>> BTW, my notebook has a slow HD and running 'make' in modperl-2.0, even 
>> without any compilations takes a minute and even longer.
> 
> 
> hey, no fair tossing out the 'patches welcome' mat just because you have 
> a slow workstation...
> 
> :)

smiley's noted, i wanted to stress that I see no point in making developer's 
life harder than it's already, be it a slow harddisk and what not, as long as 
it doesn't make other lives harder. So as long as we find a compromise that 
suits everybody we are cool. Hence the request for a patch, since it was you 
who were unhappy about the current state-of-rat.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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


Re: t/SMOKE on win32

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Patches are welcome.
> 
> BTW, my notebook has a slow HD and running 'make' in modperl-2.0, even 
> without any compilations takes a minute and even longer.

hey, no fair tossing out the 'patches welcome' mat just because you have a 
slow workstation...

:)

--Geoff


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


Re: t/SMOKE on win32

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
> 
> Stas Bekman wrote:
> 
>> Steve Hay wrote:
>>
>>> So presumably t/SMOKE uses Apache-Test/lib rather than blib/lib?
>>
>>
>>
>> All our tools try to use the live libs instead of blib, to make it 
>> easy to develop.
> 
> 
> which doesn't work at all for third party XS modules, which is why we 
> have those extra statements in modperl_inc.pl, and why we need to do 
> that extra.last.conf.in foo in order to have XS modules seen at all.

I wasn't talking about 3rd party modules, but mp2 and Apache-Test's internals. 
Please see below.

>> Imagine how error-prone would it be if one had to remember to run 
>> 'make' after a single change is done to a file in lib/ or 
>> Apache-Test/lib, not talking about the overhead.
> 
> 
> remembering to run 'make' between test runs is everyday life for most of 
> us :)  I even have an alias for it
> 
> alias test='make && perl -Mblib'
> 
> $ test t/01foo.t
> 
> personally, I'd rather see everything run out of blib - it just seems to 
> make the most sense overall, and it's closer to what users of the other 
> perl testing suites are used to.

-1 on removing it, as it'll turn the development cycle into a nightmare (at 
least for me). +1 on turning this feature on only for the MAINTAINER mode. 
Patches are welcome.

BTW, my notebook has a slow HD and running 'make' in modperl-2.0, even without 
any compilations takes a minute and even longer.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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


Re: t/SMOKE on win32

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Stas Bekman wrote:
> Steve Hay wrote:
> 
>> So presumably t/SMOKE uses Apache-Test/lib rather than blib/lib?
> 
> 
> All our tools try to use the live libs instead of blib, to make it easy 
> to develop.

which doesn't work at all for third party XS modules, which is why we have 
those extra statements in modperl_inc.pl, and why we need to do that 
extra.last.conf.in foo in order to have XS modules seen at all.

> Imagine how error-prone would it be if one had to remember 
> to run 'make' after a single change is done to a file in lib/ or 
> Apache-Test/lib, not talking about the overhead.

remembering to run 'make' between test runs is everyday life for most of us 
:)  I even have an alias for it

alias test='make && perl -Mblib'

$ test t/01foo.t

personally, I'd rather see everything run out of blib - it just seems to 
make the most sense overall, and it's closer to what users of the other perl 
testing suites are used to.

--Geoff


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


Re: t/SMOKE on win32

Posted by Stas Bekman <st...@stason.org>.
Steve Hay wrote:

> So presumably t/SMOKE uses Apache-Test/lib rather than blib/lib?

All our tools try to use the live libs instead of blib, to make it easy to 
develop. Imagine how error-prone would it be if one had to remember to run 
'make' after a single change is done to a file in lib/ or Apache-Test/lib, not 
talking about the overhead.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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


Re: t/SMOKE on win32

Posted by Steve Hay <st...@uk.radan.com>.
Randy Kobes wrote:

>On Tue, 30 Sep 2003, Steve Hay wrote:
>
>  
>
>>Randy Kobes wrote:
>>    
>>
>[ ... ]
>  
>
>>>Here's a first stab at a patch to get t/SMOKE running on
>>>Win32. I tried to localize the Win32 changes by putting
>>>them in their own sub. The full functionality is probably
>>>not all there - it still needs more testing - but it does
>>>seem workable in principle.
>>>
>>>      
>>>
>>It didn't make any difference to mine :-(
>>
>>I applied the patch OK to a freshly built 1.99_10, but running "perl
>>t/SMOKE" (from the top-level of the mp2 build tree) still outputs:
>>
>>=====
>>C:\Temp\mod_perl-1.99_10>perl t/SMOKE
>>*** Using random number seed: 999532463 (autogenerated)
>>***
>>------------------------------------------------------------
>>*** [001-00-00] trying all tests 10 times
>>!!! failed to start server
>> '.' is not recognized as an internal or external command,
>>operable program or batch file.
>>=====
>>    
>>
>
>Strange - there was an error like this from before by
>trying to run ./TEST (from about line 122 of TestSmoke.pm),
>but I thought that was fixed in the patch ... Can you tell
>where this might be coming from? Also (just in case ...:),
>did you do an 'nmake' after patching, so that the patched
>TestSmoke.pm from lib/ gets copied over into blib/?
>  
>
I've got it working now - I'd actually patched the 
blib/lib/Apache/TestSmoke.pm file itself (my patch program couldn't find 
a file to patch so it asked me, and that's what I gave it).  Following 
your comment above I've now copied the patched TestSmoke.pm into 
Apache-Test/lib/Apache as well, and now it's smoking!

So presumably t/SMOKE uses Apache-Test/lib rather than blib/lib?

- Steve


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


Re: t/SMOKE on win32

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Tue, 30 Sep 2003, Steve Hay wrote:

> Randy Kobes wrote:
[ ... ]
> >Here's a first stab at a patch to get t/SMOKE running on
> >Win32. I tried to localize the Win32 changes by putting
> >them in their own sub. The full functionality is probably
> >not all there - it still needs more testing - but it does
> >seem workable in principle.
> >
> It didn't make any difference to mine :-(
>
> I applied the patch OK to a freshly built 1.99_10, but running "perl
> t/SMOKE" (from the top-level of the mp2 build tree) still outputs:
>
> =====
> C:\Temp\mod_perl-1.99_10>perl t/SMOKE
> *** Using random number seed: 999532463 (autogenerated)
> ***
> ------------------------------------------------------------
> *** [001-00-00] trying all tests 10 times
> !!! failed to start server
>  '.' is not recognized as an internal or external command,
> operable program or batch file.
> =====

Strange - there was an error like this from before by
trying to run ./TEST (from about line 122 of TestSmoke.pm),
but I thought that was fixed in the patch ... Can you tell
where this might be coming from? Also (just in case ...:),
did you do an 'nmake' after patching, so that the patched
TestSmoke.pm from lib/ gets copied over into blib/?

-- 
best regards,
randy

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


Re: t/SMOKE on win32

Posted by Steve Hay <st...@uk.radan.com>.
Randy Kobes wrote:

>On Wed, 17 Sep 2003, Steve Hay wrote:
>
>  
>
>>Stas Bekman wrote:
>>    
>>
>>>Steve Hay wrote:
>>>      
>>>
>>>>I tried running "perl t/SMOKE" but I just get this:
>>>>
>>>>=====
>>>>C:\Temp\modperl-2.0>perl t/SMOKE
>>>>*** Using random number seed: 1012582729 (autogenerated)
>>>>***
>>>>------------------------------------------------------------
>>>>*** [001-00-00] trying all tests 10 times
>>>>!!! failed to start server
>>>>'.' is not recognized as an internal or external command,
>>>>operable program or batch file.
>>>>=====
>>>>        
>>>>
>>>Yup, it needs tweaking to run on win32.
>>>      
>>>
>
>Here's a first stab at a patch to get t/SMOKE running on
>Win32. I tried to localize the Win32 changes by putting
>them in their own sub. The full functionality is probably
>not all there - it still needs more testing - but it does
>seem workable in principle.
>
It didn't make any difference to mine :-(

I applied the patch OK to a freshly built 1.99_10, but running "perl 
t/SMOKE" (from the top-level of the mp2 build tree) still outputs:

=====
C:\Temp\mod_perl-1.99_10>perl t/SMOKE
*** Using random number seed: 999532463 (autogenerated)
***
------------------------------------------------------------
*** [001-00-00] trying all tests 10 times
!!! failed to start server
 '.' is not recognized as an internal or external command,
operable program or batch file.
=====

I also tried cd'ing into the t/ subdirectory and running "perl SMOKE", 
but that's just the same.

- Steve

>========================================================
>Index: lib/Apache/TestSmoke.pm
>===================================================================
>RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmoke.pm,v
>retrieving revision 1.23
>diff -u -r1.23 TestSmoke.pm
>--- lib/Apache/TestSmoke.pm	12 Sep 2003 02:47:41 -0000	1.23
>+++ lib/Apache/TestSmoke.pm	30 Sep 2003 05:42:39 -0000
>@@ -16,6 +16,12 @@
> use POSIX ();
> use Symbol ();
>
>+use constant WIN32 => Apache::TestConfig::WIN32;
>+if (WIN32) {
>+    require Win32;
>+    require Win32::Process;
>+}
>+
> #use constant DEBUG => 1;
>
> # how many times to run all tests at the first iteration
>@@ -111,7 +117,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};
>@@ -462,6 +468,13 @@
>
> sub run_test {
>     my($self, $iter, $count, $tests, $ra_ok) = @_;
>+    my $run_test = \&{"run_test_$^O"};
>+    $run_test = \&run_test_default unless defined &$run_test;
>+    $run_test->($self, $iter, $count, $tests, $ra_ok);
>+}
>+
>+sub run_test_default {
>+    my($self, $iter, $count, $tests, $ra_ok) = @_;
>     my $bad = '';
>     my $ra_nok = [];
>
>@@ -627,6 +640,129 @@
>         return $bad;
>     }
>
>+
>+}
>+
>+sub run_test_MSWin32 {
>+    my($self, $iter, $count, $tests, $ra_ok) = @_;
>+    my $bad = '';
>+    my $ra_nok = [];
>+    my $ProcessObj;
>+
>+    # start server
>+    {
>+        my $cmd = $self->{start_command};
>+        my $cflags = Win32::Process::NORMAL_PRIORITY_CLASS();
>+        my $shell = $ENV{ComSpec};
>+        Win32::Process::Create($ProcessObj,
>+                               $shell,
>+                               "$shell /c $cmd",
>+                               0,
>+                               $cflags,
>+                               '.')
>+              or die Win32::FormatMessage(Win32::GetLastError());
>+        $ProcessObj->Wait(Win32::Process::INFINITE());
>+    }
>+    my $t_logs  = $self->{test_config}->{vars}->{t_logs};
>+    my @log_files = map { catfile $t_logs, $_ } qw(error_log access_log);
>+    $self->logs_init(@log_files);
>+
>+    # run tests
>+    {
>+        my $command = $self->{run_command};
>+
>+        my $max_len = 1;
>+        for my $test (@$tests) {
>+            $max_len = length $test if length $test > $max_len;
>+        }
>+
>+        for my $test (@$tests) {
>+            my $ok = 0;
>+            my $log = '';
>+            (my $test_name = $test) =~ s/\.t$//;
>+            my $fill = "." x ($max_len - length $test_name);
>+            $self->{total_tests_run}++;
>+
>+            my @args = (split(' ', $command), $test);
>+            $ok = not system(@args);
>+            if ($ok) {
>+                push @$ra_ok, $test;
>+                if ($self->{verbose}) {
>+                    print STDERR "$test_name${fill}ok\n";
>+                }
>+                # need to run log_diff to reset the position of the fh
>+                my %log_diffs = map { $_ => $self->log_diff($_) } @log_files;
>+
>+            }
>+            else {
>+                push @$ra_nok, $test;
>+                $bad = $test;
>+
>+                if ($self->{verbose}) {
>+                    print STDERR "$test_name${fill}FAILED\n";
>+                    error sep("-");
>+
>+                    # give server some time to finish the
>+                    # logging. it's ok to wait long time since we have
>+                    # to deal with an error
>+                    sleep 5;
>+                    my %log_diffs = map { $_ => $self->log_diff($_) } @log_files;
>+
>+                    # client log
>+                    error "\t\t*** run log ***";
>+                    $log =~ s/^/    /mg;
>+                    print STDERR "$log\n";
>+
>+                    # server logs
>+                    for my $path (@log_files) {
>+                        next unless length $log_diffs{$path};
>+                        error "\t\t*** $path ***";
>+                        $log_diffs{$path} =~ s/^/    /mg;
>+                        print STDERR "$log_diffs{$path}\n";
>+                    }
>+                }
>+
>+                if ($self->{verbose}) {
>+                    error sep("-");
>+                }
>+
>+                unless ($self->{bug_mode}) {
>+                    # normal smoke stop the run, but in the bug_mode
>+                    # we want to complete all the tests
>+                    last;
>+                }
>+            }
>+        }
>+    }
>+    $self->logs_end();
>+
>+
>+    # stop server
>+    {
>+        my $pid;
>+        if ($ProcessObj) {
>+            $pid = $ProcessObj->GetProcessID();
>+            $ProcessObj->Kill(0);
>+        }
>+        if ($pid) {
>+            Win32::Process::KillProcess($pid, 0);
>+        }
>+    }
>+    $self->kill_proc();
>+
>+    if ($self->{bug_mode}) {
>+        warning sep("-");
>+        if (@$ra_nok == 0) {
>+            printf STDERR "All tests successful (%d)\n", scalar @$ra_ok;
>+        }
>+        else {
>+            error sprintf "error running %d tests out of %d\n",
>+                scalar(@$ra_nok), scalar @$ra_ok + @$ra_nok;
>+        }
>+    }
>+    else {
>+        return $bad;
>+    }
>
> }
>
>=============================================================
>  
>



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


Re: t/SMOKE on win32

Posted by Stas Bekman <st...@stason.org>.
Randy Kobes wrote:
> On Wed, 17 Sep 2003, Steve Hay wrote:
> 
> 
>>Stas Bekman wrote:
>>
>>>Steve Hay wrote:
>>>
>>>>I tried running "perl t/SMOKE" but I just get this:
>>>>
>>>>=====
>>>>C:\Temp\modperl-2.0>perl t/SMOKE
>>>>*** Using random number seed: 1012582729 (autogenerated)
>>>>***
>>>>------------------------------------------------------------
>>>>*** [001-00-00] trying all tests 10 times
>>>>!!! failed to start server
>>>>'.' is not recognized as an internal or external command,
>>>>operable program or batch file.
>>>>=====
>>>
>>>Yup, it needs tweaking to run on win32.
> 
> 
> Here's a first stab at a patch to get t/SMOKE running on
> Win32. I tried to localize the Win32 changes by putting
> them in their own sub. The full functionality is probably
> not all there - it still needs more testing - but it does
> seem workable in principle.

Replicating the smoking logic more than once is not so good, for obvious 
reasons. The logic should be written only once and any supporting 
functionality should be abstracted into functions called by that logic code. 
Since t/TEST works just fine on win32, there shouldn't be any special code in 
TestSmoke, besides the new functionality, which is just starting a new process 
and then reading from the process's STDOUT in the line mode. Any test names 
mungling don't belong here.

Notice that I've temprorary complicated the logic to do:

1) start the server,
2) run a single test, check the results, scan fs for core files, go to 2
3) stop the server

because Test::Harness doesn't support a post-single-test-run action. and I 
needed to scan for core files and get the relevant error messages for the test 
that failed, rather than trying to fish it out from error_log after the run is 
  completed. However it's going to change hopefully soon and SMOKE will go 
back to the simple mode of running t/TEST and parsing its output, as soon as 
Test::Harness::Straps support that new feature (post-single-test-run 
callback). So what we really want on win32 is be able to start a process, read 
from its output in the line mode and stop the server. Similar to IPC::Run's API.

Randy, do you think it's going to be hard to fix IPC::Run do the right thing 
on win32? If IPC::Run is fixed, we don't need to add win32 cruft to our code.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


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


Re: t/SMOKE on win32

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Wed, 17 Sep 2003, Steve Hay wrote:

> Stas Bekman wrote:
> >
> > Steve Hay wrote:
> > > I tried running "perl t/SMOKE" but I just get this:
> > >
> > > =====
> > > C:\Temp\modperl-2.0>perl t/SMOKE
> > > *** Using random number seed: 1012582729 (autogenerated)
> > > ***
> > > ------------------------------------------------------------
> > > *** [001-00-00] trying all tests 10 times
> > > !!! failed to start server
> > > '.' is not recognized as an internal or external command,
> > > operable program or batch file.
> > > =====
> >
> > Yup, it needs tweaking to run on win32.

Here's a first stab at a patch to get t/SMOKE running on
Win32. I tried to localize the Win32 changes by putting
them in their own sub. The full functionality is probably
not all there - it still needs more testing - but it does
seem workable in principle.
========================================================
Index: lib/Apache/TestSmoke.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestSmoke.pm,v
retrieving revision 1.23
diff -u -r1.23 TestSmoke.pm
--- lib/Apache/TestSmoke.pm	12 Sep 2003 02:47:41 -0000	1.23
+++ lib/Apache/TestSmoke.pm	30 Sep 2003 05:42:39 -0000
@@ -16,6 +16,12 @@
 use POSIX ();
 use Symbol ();

+use constant WIN32 => Apache::TestConfig::WIN32;
+if (WIN32) {
+    require Win32;
+    require Win32::Process;
+}
+
 #use constant DEBUG => 1;

 # how many times to run all tests at the first iteration
@@ -111,7 +117,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};
@@ -462,6 +468,13 @@

 sub run_test {
     my($self, $iter, $count, $tests, $ra_ok) = @_;
+    my $run_test = \&{"run_test_$^O"};
+    $run_test = \&run_test_default unless defined &$run_test;
+    $run_test->($self, $iter, $count, $tests, $ra_ok);
+}
+
+sub run_test_default {
+    my($self, $iter, $count, $tests, $ra_ok) = @_;
     my $bad = '';
     my $ra_nok = [];

@@ -627,6 +640,129 @@
         return $bad;
     }

+
+}
+
+sub run_test_MSWin32 {
+    my($self, $iter, $count, $tests, $ra_ok) = @_;
+    my $bad = '';
+    my $ra_nok = [];
+    my $ProcessObj;
+
+    # start server
+    {
+        my $cmd = $self->{start_command};
+        my $cflags = Win32::Process::NORMAL_PRIORITY_CLASS();
+        my $shell = $ENV{ComSpec};
+        Win32::Process::Create($ProcessObj,
+                               $shell,
+                               "$shell /c $cmd",
+                               0,
+                               $cflags,
+                               '.')
+              or die Win32::FormatMessage(Win32::GetLastError());
+        $ProcessObj->Wait(Win32::Process::INFINITE());
+    }
+    my $t_logs  = $self->{test_config}->{vars}->{t_logs};
+    my @log_files = map { catfile $t_logs, $_ } qw(error_log access_log);
+    $self->logs_init(@log_files);
+
+    # run tests
+    {
+        my $command = $self->{run_command};
+
+        my $max_len = 1;
+        for my $test (@$tests) {
+            $max_len = length $test if length $test > $max_len;
+        }
+
+        for my $test (@$tests) {
+            my $ok = 0;
+            my $log = '';
+            (my $test_name = $test) =~ s/\.t$//;
+            my $fill = "." x ($max_len - length $test_name);
+            $self->{total_tests_run}++;
+
+            my @args = (split(' ', $command), $test);
+            $ok = not system(@args);
+            if ($ok) {
+                push @$ra_ok, $test;
+                if ($self->{verbose}) {
+                    print STDERR "$test_name${fill}ok\n";
+                }
+                # need to run log_diff to reset the position of the fh
+                my %log_diffs = map { $_ => $self->log_diff($_) } @log_files;
+
+            }
+            else {
+                push @$ra_nok, $test;
+                $bad = $test;
+
+                if ($self->{verbose}) {
+                    print STDERR "$test_name${fill}FAILED\n";
+                    error sep("-");
+
+                    # give server some time to finish the
+                    # logging. it's ok to wait long time since we have
+                    # to deal with an error
+                    sleep 5;
+                    my %log_diffs = map { $_ => $self->log_diff($_) } @log_files;
+
+                    # client log
+                    error "\t\t*** run log ***";
+                    $log =~ s/^/    /mg;
+                    print STDERR "$log\n";
+
+                    # server logs
+                    for my $path (@log_files) {
+                        next unless length $log_diffs{$path};
+                        error "\t\t*** $path ***";
+                        $log_diffs{$path} =~ s/^/    /mg;
+                        print STDERR "$log_diffs{$path}\n";
+                    }
+                }
+
+                if ($self->{verbose}) {
+                    error sep("-");
+                }
+
+                unless ($self->{bug_mode}) {
+                    # normal smoke stop the run, but in the bug_mode
+                    # we want to complete all the tests
+                    last;
+                }
+            }
+        }
+    }
+    $self->logs_end();
+
+
+    # stop server
+    {
+        my $pid;
+        if ($ProcessObj) {
+            $pid = $ProcessObj->GetProcessID();
+            $ProcessObj->Kill(0);
+        }
+        if ($pid) {
+            Win32::Process::KillProcess($pid, 0);
+        }
+    }
+    $self->kill_proc();
+
+    if ($self->{bug_mode}) {
+        warning sep("-");
+        if (@$ra_nok == 0) {
+            printf STDERR "All tests successful (%d)\n", scalar @$ra_ok;
+        }
+        else {
+            error sprintf "error running %d tests out of %d\n",
+                scalar(@$ra_nok), scalar @$ra_ok + @$ra_nok;
+        }
+    }
+    else {
+        return $bad;
+    }

 }

=============================================================
-- 
best regards,
randy

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


Re: t/SMOKE on win32

Posted by Steve Hay <st...@uk.radan.com>.
Stas Bekman wrote:

> Trying to spread unrelated topics into different threads, otherwise 
> it's a mess: 

Guilty as charged m'lud :-)

>
>
> Steve Hay wrote:
> > I tried running "perl t/SMOKE" but I just get this:
> >
> > =====
> > C:\Temp\modperl-2.0>perl t/SMOKE
> > *** Using random number seed: 1012582729 (autogenerated)
> > ***
> > ------------------------------------------------------------
> > *** [001-00-00] trying all tests 10 times
> > !!! failed to start server
> > '.' is not recognized as an internal or external command,
> > operable program or batch file.
> > =====
>
> Yup, it needs tweaking to run on win32.
>
> Randy wrote:
> > Try changing this to "$^X /path/to/modperl-2.0/t/TEST".
> > However, when I tried running this it *seemed* to hang;
> > but I may have just been too impatient, or tired ...
>
> What do you mean hanging? have you tried adding the -verbose flag? Did 
> it start the server? Did it start running the first tests? 

I tried "perl t/SMOKE -verbose=1" and it makes no difference.

It kicks off an Apach.exe which eats a bit of CPU for a short while and 
then everything goes quiet.  Apache.exe stays sitting there, but doesn't 
seem to do anything else.  I left it for nearly 2 hours and nothing 
happened.  When I killed it, it dumped this into the report file:

#####
======= Special Tests Sequence Failure Finder Report =======
------------------------------------------------------------
First iteration used:
C:\perl\bin\perl.exe C:/Temp/modperl-2.0/t/TEST [snipped -- long list of 
tests]
------------------------------------------------------------

========================= Summary ==========================
Completion               : Not Completed (aborted by user)
Status                   : Unknown
Tests run                : 0
Iterations (random) made : 0
------------------------------------------------------------
--- Started at: Wed Sep 17 12:32:34 2003 ---
--- Ended   at: Wed Sep 17 14:15:22 2003 ---
------------------------------------------------------------
The smoke testing was run on the system with the following
parameters:

[snipped -- Apache and Perl config info]

-- this report was generated by t/SMOKE
#####

I tried just running a small subset of the tests, e.g. "perl t/SMOKE 
-verbose=1 t/compat", but that behaves the same.

What gives?

- Steve


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