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 2001/08/27 10:54:38 UTC
Re: [patch] adding more checks (fwd)
ok, this one is not wrapped
---------- Forwarded message ----------
Date: Sun, 26 Aug 2001 23:23:56 +0800 (SGT)
From: Stas Bekman <st...@stason.org>
To: Doug MacEachern <do...@covalent.net>
Cc: modperl-2.0 dev-list <de...@perl.apache.org>
Subject: Re: [patch] adding more checks
please try this patch. it exposes the problem with messed up setup.
it adds the test for perlrequire and APACHE_TEST_CONFIGURE functionality.
this is just a first scatch.
Index: Apache-Test/lib/Apache/TestConfigPerl.pm
===================================================================
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.19
diff -u -r1.19 TestConfigPerl.pm
--- Apache-Test/lib/Apache/TestConfigPerl.pm 2001/08/11 20:40:05
1.19
+++ Apache-Test/lib/Apache/TestConfigPerl.pm 2001/08/26 15:18:53
@@ -243,14 +243,21 @@
finddepth(sub {
return unless /\.pm$/;
my @args;
-
+
my $pm = $_;
- my $module = catfile $File::Find::dir, $pm;
- $self->add_module_config($module, \@args);
- $module = abs2rel $module, $dir;
+ my $file = catfile $File::Find::dir, $pm;
+ $self->add_module_config($file, \@args);
+ my $module = abs2rel $file, $dir;
$module =~ s,\.pm$,,;
$module = join '::', splitdir $module;
+ require $file;
+ my $configure_sub = \&{$module."::APACHE_TEST_CONFIGURE"};
+ if ($configure_sub) {
+ eval {$self->$configure_sub};
+ warn $@ if $@;
+ }
+
my($base, $sub) =
map { s/^test//i; $_ } split '::', $module;
--- /dev/null Sat Apr 14 19:06:21 2001
+++ t/directive/perlrequire.t Sun Aug 26 23:00:57 2001
@@ -0,0 +1,31 @@
+# this test tests PerlRequire configuration directive
+########################################################################
+
+use strict;
+use warnings FATAL => 'all';
+
+use Apache::Test;
+use Apache::TestRequest ();
+use Apache::TestConfig ();
+
+my %checks =
+ (
+ 'default' => 'Loaded by Parent',
+ 'TestDirective::perlrequire' => 'Loaded by Virtual Host',
+ );
+
+plan tests => scalar keys %checks;
+
+for my $module (sort keys %checks) {
+ local $Apache::TestRequest::Module = $module;
+ $Apache::TestRequest::Module ||= $module; #-w
+
+ my $config = Apache::TestConfig->thaw;
+ my $hostport = Apache::TestRequest::hostport($config);
+ print "connecting to $hostport\n";
+
+ my $res = $config->http_raw_get("/TestDirective::perlrequire",undef) || '';
+ print "expecting: $checks{$module}\n";
+ print "getting : $res\n";
+ ok $res eq $checks{$module};
+}
--- /dev/null Sat Apr 14 19:06:21 2001
+++ t/response/TestDirective/perlrequire.pm Sun Aug 26 23:00:44 2001
@@ -0,0 +1,42 @@
+package TestDirective::perlrequire;
+
+use strict;
+use warnings FATAL => 'all';
+
+sub handler {
+ my $r = shift;
+
+ $r->content_type('text/plain');
+ $r->puts($PerlRequireTest::MAGIC || '');
+
+ 0;# Apache::OK;
+}
+
+sub APACHE_TEST_CONFIGURE{
+ my $self = shift;
+ print STDERR "called! @_";
+}
+
+1;
+__END__
+PerlSwitches -Mlib=@serverroot@/lib/parent
+PerlRequire "PerlRequireTest.pm"
+
+<VirtualHost TestDirective::perlrequire>
+
+ PerlOptions +Parent
+ PerlSwitches -Mlib=@serverroot@
+ PerlSwitches -Mblib=@serverroot@
+ PerlSwitches -Mlib=@serverroot@/hooks
+ PerlSwitches -Mlib=@serverroot@/response
+ PerlRequire conf/modperl_extra.pl
+
+ PerlSwitches -Mlib=@serverroot@/lib/vh
+ PerlRequire "PerlRequireTest.pm"
+
+ #PerlRequire conf/require_test.pl
+ <Location /TestDirective::perlrequire>
+ SetHandler modperl
+ PerlResponseHandler TestDirective::perlrequire
+ </Location>
+</VirtualHost>
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] adding more checks (fwd)
Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 28 Aug 2001, Stas Bekman wrote:
oh, i understand the problem now. httpd.conf, etc. are generated, but if
something dies, t/conf/apache_test_config.pm is never written. next time
through, httpd.conf, etc. are not overwritten. i think the solution would
be to have a $SIG{__DIE__} handler that either makes sure
apache_test_config.pm is written or runs clean() before bailing out.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] adding more checks (fwd)
Posted by Stas Bekman <st...@stason.org>.
On Mon, 27 Aug 2001, Doug MacEachern wrote:
> i didn't try the patch, but i think i just hit the same problem. can you
> test if its fixed now?
partially,
the thaw problem is not there anymore, but the configuration won't proceed
because, there will be a left-over t/conf/httpd.conf and even ./t/TEST
-clean won't clean it up. Just apply my patch and run 'make test' you will
see.
I still have to go to ./t/conf and manually delete files.
May be we need to specify a target consisting of all files that are
required for the configuration to be reused, and if at least one of them
is not there, force reconfiguration?
In fact the only patch you need to reproduce the problem is:
Index: Apache-Test/lib/Apache/TestConfigPerl.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.20
diff -u -r1.20 TestConfigPerl.pm
--- Apache-Test/lib/Apache/TestConfigPerl.pm 2001/08/27 17:13:26 1.20
+++ Apache-Test/lib/Apache/TestConfigPerl.pm 2001/08/28 15:21:51
@@ -245,11 +245,13 @@
my @args;
my $pm = $_;
- my $module = catfile $File::Find::dir, $pm;
- $self->add_module_config($module, \@args);
- $module = abs2rel $module, $dir;
+ my $file = catfile $File::Find::dir, $pm;
+ $self->add_module_config($file, \@args);
+ my $module = abs2rel $file, $dir;
$module =~ s,\.pm$,,;
$module = join '::', splitdir $module;
+
+ require $file;
my($base, $sub) =
map { s/^test//i; $_ } split '::', $module;
require() fails and messes up the configuration files, turning the tree
un-buildable.
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [patch] adding more checks (fwd)
Posted by Doug MacEachern <do...@covalent.net>.
i didn't try the patch, but i think i just hit the same problem. can you
test if its fixed now?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org