Re: [mp2] ModPerl-Registry redirect test

2003-11-30 Thread Stas Bekman
Randy Kobes wrote:
In one of the redirect tests of ModPerl-Registry, catfile
is used to construct the location of a script, which for
non-unix doesn't use '/' as the directory separator. This
===
Index: ModPerl-Registry/t/redirect.t
===
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/redirect.t,v
retrieving revision 1.6
diff -u -r1.6 redirect.t
--- ModPerl-Registry/t/redirect.t   23 Nov 2003 21:01:50 -  1.6
+++ ModPerl-Registry/t/redirect.t   29 Nov 2003 14:28:38 -
@@ -16,7 +16,7 @@
 my $redirect_path = "/registry/basic.pl";
 my $url = "$base_url?$redirect_path";
 my $vars = Apache::Test::config()->{vars};
-my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
+my $script_file = $vars->{serverroot} . '/cgi-bin/basic.pl';
 ok t_cmp(
 "ok $script_file",

fixes it.
Another option might be to

use File::Spec::Unix;
my $script = File::Spec::Unix->catfile($var1, $var2);
Ah, what do you get as a response? a path like /tmp/foo.pl on win32? In which 
case the problem would be coming from:

$_[0]->{FILENAME} = $_[1]->filename;

in RegistryCooker.pm, which sets $0, eventually printed by cgi-bin/basic.pl. 
Does $r->filename return a unix path on winFU?

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: RE : RE : bug : make test fails

2003-11-30 Thread Stas Bekman
Barbara Post wrote:
OK, sorry for the offense, you're right.
It wasn't an offense at all, sorry if I sounded like it was...

The answer of the perl command line is an empty string.

$ perl -Mlib=Apache-Test/lib -MApache::TestRequest -le 'print
Apache::TestRequest::has_lwp'
Thanks Barbara. I just wanted to double check that it didn't think that it had 
LWP installed when it didn't. For some reason I can't reproduce the problem.

I will install LWP on Monday then.
Before you do that, can you please try applying this patch and see if it's 
still broken. I think it should work now fine without LWP:

Index: Apache-Test/lib/Apache/TestServer.pm
===
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestServer.pm,v
retrieving revision 1.73
diff -u -r1.73 TestServer.pm
--- Apache-Test/lib/Apache/TestServer.pm	24 Nov 2003 08:28:34 -	1.73
+++ Apache-Test/lib/Apache/TestServer.pm	30 Nov 2003 20:57:57 -
@@ -584,10 +584,9 @@

 my $server_up = sub {
 local $SIG{__WARN__} = sub {}; #avoid "cannot connect ..." warnings
-if (my $r = Apache::TestRequest::GET('/index.html')) {
-return $r->code;
-}
-0;
+# avoid fatal errors
+my $r = eval { Apache::TestRequest::GET('/index.html') };
+return !$@ && defined $r ? $r->code : 0;
 };
 if ($server_up->()) {



__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [mp2] ModPerl-Registry redirect test

2003-11-30 Thread Randy Kobes
On Sun, 30 Nov 2003, Stas Bekman wrote:

> Randy Kobes wrote:
> > In one of the redirect tests of ModPerl-Registry, catfile
> > is used to construct the location of a script, which for
> > non-unix doesn't use '/' as the directory separator. This
> > ===
> > Index: ModPerl-Registry/t/redirect.t
> > ===
> > RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/redirect.t,v
> > retrieving revision 1.6
> > diff -u -r1.6 redirect.t
> > --- ModPerl-Registry/t/redirect.t   23 Nov 2003 21:01:50 -  1.6
> > +++ ModPerl-Registry/t/redirect.t   29 Nov 2003 14:28:38 -
> > @@ -16,7 +16,7 @@
> >  my $redirect_path = "/registry/basic.pl";
> >  my $url = "$base_url?$redirect_path";
> >  my $vars = Apache::Test::config()->{vars};
> > -my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
> > +my $script_file = $vars->{serverroot} . '/cgi-bin/basic.pl';
> >
> >  ok t_cmp(
> >  "ok $script_file",
> > 
> > fixes it.
> >
> > Another option might be to
> >
> > use File::Spec::Unix;
> > my $script = File::Spec::Unix->catfile($var1, $var2);
>
> Ah, what do you get as a response? a path like /tmp/foo.pl on win32? In which
> case the problem would be coming from:
>
>  $_[0]->{FILENAME} = $_[1]->filename;
>
> in RegistryCooker.pm, which sets $0, eventually printed by cgi-bin/basic.pl.
> Does $r->filename return a unix path on winFU?

I guess one could look at it from both ends ... I was
thinking here that the problem was in the way that
$script_file was constructed with catfile, which on
Win32 came out as SERVER_ROOT\cgi-bin\basic.pl. So the
patch above changes this to SERVER_ROOT/cgi-bin/basic.pl,
which agrees with the response.

-- 
best regards,
randy


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



Re: [mp2] ModPerl-Registry redirect test

2003-11-30 Thread Randy Kobes
On Sun, 30 Nov 2003, Randy Kobes wrote:

> On Sun, 30 Nov 2003, Stas Bekman wrote:
[ .. ]
> > Ah, what do you get as a response? a path like
> > /tmp/foo.pl on win32? In which case the problem would be
> > coming from:
> >
> >  $_[0]->{FILENAME} = $_[1]->filename;
> >
> > in RegistryCooker.pm, which sets $0, eventually printed by cgi-bin/basic.pl.
> > Does $r->filename return a unix path on winFU?
>
> I guess one could look at it from both ends ... I was
> thinking here that the problem was in the way that
> $script_file was constructed with catfile, which on
> Win32 came out as SERVER_ROOT\cgi-bin\basic.pl. So the
> patch above changes this to SERVER_ROOT/cgi-bin/basic.pl,
> which agrees with the response.

Further to this, I think most people on Win32 (and probably
all non-Unices) are used to using '/' as a directory
separator when inside a web environment (eg, in constructing
urls). So I would think that SERVER_ROOT/cgi-bin/basic.pl
is the correct cross-platform value ...

However (I hate bringing this up :(, on Win32 there's
problems with sometimes the dos short path name being
used and then compared with the long path name
(eg, MODPER~1.0 vs modperl-2.0). This in principle
is what needs to be done to get t/basic.t and t/redirect.t
to pass under ModPerl-Registry:

Index: t/basic.t
===
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/basic.t,v
retrieving revision 1.15
diff -u -r1.15 basic.t
--- t/basic.t   23 Nov 2003 21:01:50 -  1.15
+++ t/basic.t   1 Dec 2003 04:23:37 -
@@ -6,7 +6,7 @@
 use Apache::TestRequest qw(GET GET_BODY HEAD);
 use Apache::TestConfig ();

-use File::Spec::Functions qw(catfile);
+use File::Spec::Unix;

 my %modules = (
 registry=> 'ModPerl::Registry',
@@ -19,7 +19,9 @@
 plan tests => @aliases * 4 + 3;

 my $vars = Apache::Test::config()->{vars};
-my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
+my $script_file = File::Spec::Unix->catfile($vars->{serverroot}, 'cgi-bin', 
'basic.pl');
+$script_file = Win32::GetLongPathName($script_file)
+if Apache::TestConfig::WIN32;

 # very basic compilation/response test
 for my $alias (@aliases) {
Index: t/redirect.t
===
RCS file: /home/cvs/modperl-2.0/ModPerl-Registry/t/redirect.t,v
retrieving revision 1.6
diff -u -r1.6 redirect.t
--- t/redirect.t23 Nov 2003 21:01:50 -  1.6
+++ t/redirect.t1 Dec 2003 04:23:37 -
@@ -5,7 +5,7 @@
 use Apache::TestUtil;
 use Apache::TestRequest qw(GET_BODY HEAD);

-use File::Spec::Functions qw(catfile);
+use File::Spec::Unix;

 plan tests => 4, have_lwp;

@@ -16,7 +16,9 @@
 my $redirect_path = "/registry/basic.pl";
 my $url = "$base_url?$redirect_path";
 my $vars = Apache::Test::config()->{vars};
-my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
+my $script_file = File::Spec::Unix->catfile($vars->{serverroot}, 'cgi-bin', 
'basic.pl');
+$script_file = Win32::GetLongPathName($script_file)
+if Apache::TestConfig::WIN32;

 ok t_cmp(
 "ok $script_file",
==

but it's not pretty ...

-- 
best regards,
randy

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



Re: [mp2] ModPerl-Registry redirect test

2003-11-30 Thread Stas Bekman
Randy Kobes wrote:

Ah, what do you get as a response? a path like
/tmp/foo.pl on win32? In which case the problem would be
coming from:
$_[0]->{FILENAME} = $_[1]->filename;

in RegistryCooker.pm, which sets $0, eventually printed by cgi-bin/basic.pl.
Does $r->filename return a unix path on winFU?
So does it do that? I suppose that it does...

I guess one could look at it from both ends ... I was
thinking here that the problem was in the way that
$script_file was constructed with catfile, which on
Win32 came out as SERVER_ROOT\cgi-bin\basic.pl. So the
patch above changes this to SERVER_ROOT/cgi-bin/basic.pl,
which agrees with the response.
Yes, but $script_file is a fs path, not URL. I'm not questioning the 
correctness of your patch, Randy, it just looks like you are workaround a 
problem that's coming from $r->filename. Is it possible that it may return the 
\ paths as well?

Further to this, I think most people on Win32 (and probably
all non-Unices) are used to using '/' as a directory
separator when inside a web environment (eg, in constructing
urls). So I would think that SERVER_ROOT/cgi-bin/basic.pl
is the correct cross-platform value ...
However (I hate bringing this up :(, on Win32 there's
problems with sometimes the dos short path name being
used and then compared with the long path name
(eg, MODPER~1.0 vs modperl-2.0). This in principle
is what needs to be done to get t/basic.t and t/redirect.t
to pass under ModPerl-Registry:
[...]
-my $script_file = catfile $vars->{serverroot}, 'cgi-bin', 'basic.pl';
+my $script_file = File::Spec::Unix->catfile($vars->{serverroot}, 'cgi-bin', 
'basic.pl');
This looks absolutely unintuitive and requires a comment in every place you 
use it. Therefore you are probably better off with your original patch to do 
an explicit: join "/n", ...

+$script_file = Win32::GetLongPathName($script_file)
+if Apache::TestConfig::WIN32;
Yes, it's ugly and those of us coding on unix will never remember to do that, 
leaving you with the boring cleanup job. Therefore please think of extending 
Apache::TestXXX API to have this Win32::GetLongPathName part hidden within. 
Both join "/", .. and Win32::GetLongPathName can go inside. e.g. 
catfile_normalized() and caturl_normalized()? where any post-processings like 
Win32::GetLongPathName will come from the _normalized part? I'm not sure if 
the name selection is good. Does it sound good?

__
Stas BekmanJAm_pH --> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]