Skip Menu |

This queue is for tickets about the Apache-Session-Wrapper CPAN distribution.

Report information
The Basics
Id: 21552
Status: resolved
Priority: 0/
Queue: Apache-Session-Wrapper

People
Owner: Nobody in particular
Requestors: derek [...] ximbiot.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.31
Fixed in: 0.33



Subject: Tests Require module load under mod_perl 2
I had to add the following line to t/conf/extra.conf.in in order to get the tests to pass using Apache2 with mod_perl2: LoadModule apreq_module /usr/lib/apache2/modules/mod_apreq2.so Without this line in extra.conf.in, the t/apache/basic.t tests fail like so: t/apache/basic....NOK 1 # Failed test 'request succeeded' # in t/apache/basic.t at line 13. t/apache/basic....NOK 2 # Failed test 'response includes cookie' # in t/apache/basic.t at line 14. Use of uninitialized value in pattern match (m//) at t/apache/basic.t line 15. Use of uninitialized value in pattern match (m//) at t/apache/basic.t line 19. # Looks like you failed 2 tests of 4. t/apache/basic....dubious Test returned status 2 (wstat 512, 0x200) DIED. FAILED tests 1-2 Failed 2/4 tests, 50.00% okay Failed Test Stat Wstat Total Fail Failed List of Failed ------------------------------------------------------------------------------- t/apache/basic.t 2 512 4 2 50.00% 1-2 I'm not sure if this load needs to be protected to avoid causing problems with earlier versions of Apache & ModPerl. Nor am I certain that the loading of the apreq2 module shouldn't be performed automagically by Apache::Test or Apache::TestRequest, but I am not used to looking so deeply into Apache's guts. Thanks,
Subject: Re: [rt.cpan.org #21552] Tests Require module load under mod_perl 2
Date: Mon, 18 Sep 2006 14:28:55 -0500 (CDT)
To: "Derek R. Price via RT" <bug-Apache-Session-Wrapper [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
On Mon, 18 Sep 2006, Derek R. Price via RT wrote: Show quoted text
> I'm not sure if this load needs to be protected to avoid causing > problems with earlier versions of Apache & ModPerl. Nor am I certain > that the loading of the apreq2 module shouldn't be performed > automagically by Apache::Test or Apache::TestRequest, but I am not used > to looking so deeply into Apache's guts.
Yeah, this would only work with apache2, and I also run these tests against apache1. Yeesh, what a PITA. I'm not sure how to conditionally load a module based on the server version.
On Mon Sep 18 15:29:19 2006, autarch@urth.org wrote: Show quoted text
> Yeah, this would only work with apache2, and I also run these tests > against apache1. Yeesh, what a PITA.
You weren't kidding about this being a PITA. I just spent the last several hours researching this. Below is a summary of what I found. Show quoted text
> I'm not sure how to conditionally load a module based on the server > version.
<IfVersion >= 2> ... </IfVersion> Unfortunately, I can't find any easy way to get the path to the module into t/conf/extra.conf.in. It's not one of the std variables substituted by Apache::TestConfig. I'm playing with overriding Apache::TestRunPerl in t/TEST.PL. The problem is that I need the server up to extract the version before I can write the config I need to get the server up. This will take some serious bootstrapping unless I can find someplace else to extract the module path or the server version (apxs?)... hrm... maybe I can extract the module path without bringing up the server and also use IfVersion... anyhow I need to take a break. I'll come back later to see if there are any new hints here or maybe I'll have a fresh perspective. :)
On Mon Sep 18 17:50:17 2006, DPRICE wrote: Show quoted text
> <IfVersion >= 2> > ... > </IfVersion>
Well, this would have been simpler, but it turns out mod_version & IfVersion isn't available until 2.0.56. I've attached a remarkably simple patch. I figured out how to extract the server version before it's started. The patch adds a short t/TEST.PL file that overrides Apache::TestRunPerl::configure and tweaks t/conf/extra.conf.in. It should work with any version of mod_perl, but I've only tested it with mod_perl2. The only additional thing I can think that it might need is to abort with an informative error message if the mod_perl version is 2 and apreq2 cannot be found.
Index: t/TEST.PL =================================================================== RCS file: t/TEST.PL diff -N t/TEST.PL --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ t/TEST.PL 18 Sep 2006 23:49:45 -0000 @@ -0,0 +1,46 @@ +#!perl + +use strict; +use warnings FATAL => 'all'; + +use lib qw( +); + + +Apache::TestRunPerl::Custom->new->run (@ARGV); + + +# The custom module +package Apache::TestRunPerl::Custom; + +use base qw(Apache::TestRunPerl); + +use File::Spec::Functions qw(catfile); +use IO::File; + +sub configure +{ + my $self = shift; + + $self->SUPER::configure (@_); + + my $config = $self->{test_config}; + my $target_conf = catfile $config->{vars}->{t_conf}, 'apreq.conf'; + my $apreq2 = $config->find_apache_module ('mod_apreq2.so'); + my $server = $config->{server}; + + my $content_conf; + if ($apreq2 && $server->{rev} >= 2) + { + $content_conf = "LoadModule apreq_module $apreq2\n"; + } + else + { + $content_conf = ''; + } + my $fh = new IO::File (">$target_conf") + or die "Failed to open $target_conf for writing: $!"; + $fh->print ($content_conf); +} + +1; Index: t/conf/extra.conf.in =================================================================== RCS file: /cvsroot/Apache-Session-Wrapper/t/conf/extra.conf.in,v retrieving revision 1.1.1.1 diff -u -p -r1.1.1.1 extra.conf.in --- t/conf/extra.conf.in 18 Sep 2006 18:51:55 -0000 1.1.1.1 +++ t/conf/extra.conf.in 18 Sep 2006 23:49:45 -0000 @@ -1,2 +1,5 @@ # This is the location where file-based sessions are stored -PerlSetVar SessionDir @ServerRoot@/session \ No newline at end of file +PerlSetVar SessionDir @ServerRoot@/session + +# Get the apreq config for ModPerl2. +Include conf/apreq.conf
From: DROLSKY [...] cpan.org
Show quoted text
> I've attached a remarkably simple patch. I figured out how to extract > the server version before it's started. The patch adds a short > t/TEST.PL file that overrides Apache::TestRunPerl::configure and tweaks > t/conf/extra.conf.in. It should work with any version of mod_perl, but > I've only tested it with mod_perl2. > > The only additional thing I can think that it might need is to abort > with an informative error message if the mod_perl version is 2 and > apreq2 cannot be found.
Yeah, I cannot figure out _how_ to abort properly. What I'd like to do is run the tests, but not the tests that need apache. Unfortunately, it seems to abort _all_ the tests with an error message, which is no good. Gah, the Apache::Test stuff is rather under-documented, and the API is weird.
From: derek [...] ximbiot.com
On Mon Sep 25 18:10:47 2006, DROLSKY wrote: Show quoted text
> seems to abort _all_ the tests with an error message, which is no good. > > Gah, the Apache::Test stuff is rather under-documented, and the API is > weird.
t/apache/basic.t is using Test::More in conjunction with Apache::Test, which should allow this syntax, assuming you can get the results from TEST.PL into the t/apache/basic.t: SKIP: { skip $why, $how_many unless $have_some_feature; ok( foo(), $test_name ); is( foo(42), 23, $test_name ); }; I don't have time to test it just now, unfortunately.