You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-cvs@httpd.apache.org by ge...@apache.org on 2003/11/07 16:03:39 UTC
cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestConfigParse.pm
geoff 2003/11/07 07:03:39
Modified: perl-framework/Apache-Test/lib/Apache TestConfigParse.pm
Log:
use apxs PREFIX to resolve relative httpd.conf directives
ServerRoot is not present
Revision Changes Path
1.36 +48 -6 httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm
Index: TestConfigParse.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- TestConfigParse.pm 9 Aug 2003 02:38:44 -0000 1.35
+++ TestConfigParse.pm 7 Nov 2003 15:03:39 -0000 1.36
@@ -8,7 +8,7 @@
use Apache::TestTrace;
-use File::Spec::Functions qw(rel2abs splitdir);
+use File::Spec::Functions qw(rel2abs splitdir file_name_is_absolute);
use File::Basename qw(basename);
sub strip_quotes {
@@ -47,14 +47,56 @@
sub server_file_rel2abs {
my($self, $file, $base) = @_;
- $base ||= $self->{inherit_config}->{ServerRoot};
+ my ($serverroot, $result) = ();
- unless ($base) {
- warning "unable to resolve $file (ServerRoot not defined yet?)";
- return $file;
+ # order search sequence
+ my @tries = ([ $base,
+ 'user-supplied $base' ],
+ [ $self->{inherit_config}->{ServerRoot},
+ 'httpd.conf inherited ServerRoot' ],
+ [ $self->apxs('PREFIX'),
+ 'apxs-derived ServerRoot' ]);
+
+ if (file_name_is_absolute($file)) {
+ debug "$file is already absolute";
+ $result = $file;
}
+ else {
+ foreach my $try (@tries) {
+ next unless defined $try->[0];
+
+ if (-d $try->[0]) {
+ $serverroot = $try->[0];
+ debug "using $try->[1] to resolve $file";
+ last;
+ }
+ }
+
+ if ($serverroot) {
+ $result = rel2abs $file, $serverroot;
+ }
+ else {
+ warning "unable to resolve $file - cannot find a suitable ServerRoot";
+ warning "please specify a ServerRoot in your httpd.conf or use apxs";
+
+ # return early, skipping file test below
+ return $file;
+ }
- rel2abs $file, $base;
+ }
+
+ if (-e $result) {
+ debug "$file successfully resolved to existing file $result";
+ }
+ else {
+ warning "configuration file $result does not exist";
+
+ # fall back to relative file we started with
+ # same as older behavior which returned $file on error
+ $result = $file;
+ }
+
+ return $result;
}
sub server_file {
Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache
TestConfigParse.pm
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>
>>> actually, the 'errors' might not end up being errors at all - if the
>>> configuration script can't resolve conf/mime.types, for instance, but
>>> the EU has one in his t/conf directory everything should work out fine.
>>
>>
>>
>> if that's the case, why not having A-T look in that directory and keep
>> things under a tight control.
>
>
> yeah. but I'm not exactly sure what the proper behavior here ought to
> be, and there are lots of variables (like conf/foo.in which may not
> change into conf/foo before TestConfigParse looks for it).
>
> at any rate, I think we can delay the digging for a while - Mike's
> original problem has been addressed and we've added in a few extra
> checks and debugging, so if something like this crops up in real life it
> will be easy to address.
Certainly. We have enough real problems to tend to first ;)
__________________________________________________________________
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
Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache
TestConfigParse.pm
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>> actually, the 'errors' might not end up being errors at all - if the
>> configuration script can't resolve conf/mime.types, for instance, but
>> the EU has one in his t/conf directory everything should work out fine.
>
>
> if that's the case, why not having A-T look in that directory and keep
> things under a tight control.
yeah. but I'm not exactly sure what the proper behavior here ought to be,
and there are lots of variables (like conf/foo.in which may not change into
conf/foo before TestConfigParse looks for it).
at any rate, I think we can delay the digging for a while - Mike's original
problem has been addressed and we've added in a few extra checks and
debugging, so if something like this crops up in real life it will be easy
to address.
--Geoff
Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache
TestConfigParse.pm
Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
>
>
> Stas Bekman wrote:
>
>> geoff@apache.org wrote:
>>
>>> geoff 2003/11/07 07:03:39
>>>
>>> Modified: perl-framework/Apache-Test/lib/Apache TestConfigParse.pm
>>> Log:
>>> use apxs PREFIX to resolve relative httpd.conf directives
>>> ServerRoot is not present
>>> Revision Changes Path
>>> 1.36 +48 -6
>>> httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm
>>> Index: TestConfigParse.pm
>>
>>
>> [...]
>>
>>> + else {
>>> + warning "unable to resolve $file - cannot find a
>>> suitable ServerRoot";
>>> + warning "please specify a ServerRoot in your
>>> httpd.conf or use apxs";
>>
>>
>>
>> shouldn't this be an error message (not fatal, just s/warning/error/)
>
>
> well, I was thinking about that lots. the reason I went with warning is
> that under normal circumstances 'perl Makefile.PL' would be the one
> throwing the message, but it's really not a build-time problem.
> actually, the 'errors' might not end up being errors at all - if the
> configuration script can't resolve conf/mime.types, for instance, but
> the EU has one in his t/conf directory everything should work out fine.
if that's the case, why not having A-T look in that directory and keep things
under a tight control.
> so, given this, I thought warnings were more appropriate. but I'm
> flexible and don't feel too strongly about it.
sure, let's keep it as it is for now.
__________________________________________________________________
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
Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache
TestConfigParse.pm
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Stas Bekman wrote:
> geoff@apache.org wrote:
>
>> geoff 2003/11/07 07:03:39
>>
>> Modified: perl-framework/Apache-Test/lib/Apache TestConfigParse.pm
>> Log:
>> use apxs PREFIX to resolve relative httpd.conf directives
>> ServerRoot is not present
>> Revision Changes Path
>> 1.36 +48 -6
>> httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm
>> Index: TestConfigParse.pm
>
> [...]
>
>> + else {
>> + warning "unable to resolve $file - cannot find a
>> suitable ServerRoot";
>> + warning "please specify a ServerRoot in your httpd.conf
>> or use apxs";
>
>
> shouldn't this be an error message (not fatal, just s/warning/error/)
well, I was thinking about that lots. the reason I went with warning is
that under normal circumstances 'perl Makefile.PL' would be the one throwing
the message, but it's really not a build-time problem. actually, the
'errors' might not end up being errors at all - if the configuration script
can't resolve conf/mime.types, for instance, but the EU has one in his
t/conf directory everything should work out fine.
so, given this, I thought warnings were more appropriate. but I'm flexible
and don't feel too strongly about it.
--Geoff
Re: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache
TestConfigParse.pm
Posted by Stas Bekman <st...@stason.org>.
geoff@apache.org wrote:
> geoff 2003/11/07 07:03:39
>
> Modified: perl-framework/Apache-Test/lib/Apache TestConfigParse.pm
> Log:
> use apxs PREFIX to resolve relative httpd.conf directives
> ServerRoot is not present
>
> Revision Changes Path
> 1.36 +48 -6 httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigParse.pm
>
> Index: TestConfigParse.pm
[...]
> + else {
> + warning "unable to resolve $file - cannot find a suitable ServerRoot";
> + warning "please specify a ServerRoot in your httpd.conf or use apxs";
shouldn't this be an error message (not fatal, just s/warning/error/)
__________________________________________________________________
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