perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject resolving Apache::Test vs. Apache::test collision
Date Tue, 06 May 2003 00:01:00 GMT
We have a problem with using the Apache::Test name, more correctly we have a 
problem with using the Apache/ filename. On platforms with 
case-insentive filesystems (winFU, Mac OS X) if mod_perl 1.x is installed, 
there is Apache/ (notice the lower case 't'). So when you say 'use 
Apache::Test' it loads Apache::test. Boom, nothing works.

There are several routes we can take to resolve this problem:

1. rename Apache::Test to something else. David Wheeler has proposed to use 
Apache::Tester (or even swap the sides: Test::Apache).

2. add a new package Apache::TestLoad which will deal with loading the right 
Apache::Test package, by replacing 'require Apache::Test' with search for 
'Apache/' in @INC and doing do $file; on the full path. That solves the 
problem, of loading the right file but you will have to replace all instances 
of 'use Apache::Test;' with 'use Apache::TestLoad;', but still using the 
functions from Apache::Test. Since they are all imported by default, this is 
not a big issue. It's just confusing that use 'Apache::TestLoad'.

So the first solution is probably the cleanest in the long run, there will be 
some mess while moving things to a new name, but since I don't think many 
developers are using this package yet, it won't be as bad as it could be at a 
later stage.

The second solution allows to keep things as they are on CPAN, cvs rep, etc, 
but s/use Apache::Test;/use Apache::TestLoad;/

To me the first solution is favorite for the users of the module, the second 
one for its maintainers.

Now please help to make the right choice, and if of course you have other 
ideas, let us know.

And the patch for the second solution:

find t -type f -exec perl -pi -e 's/use Apache::Test;/use Apache::TestLoad;/' 
{} \;

Index: lib/Apache/
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/,v
retrieving revision 1.25
diff -u -r1.25
--- lib/Apache/	1 May 2003 06:22:35 -0000	1.25
+++ lib/Apache/	5 May 2003 00:01:44 -0000
@@ -4,6 +4,7 @@
   use warnings FATAL => 'all';

   use Config;
+use Apache::TestLoad ();
   use Apache::TestConfig ();
   use Apache::TestTrace;

--- /dev/null	1970-01-01 10:00:00.000000000 +1000
+++ lib/Apache/	2003-05-05 09:50:29.000000000 +1000
@@ -0,0 +1,57 @@
+package Apache::TestLoad;
+use strict;
+use warnings FATAL => 'all';
+use File::Spec::Functions qw(catfile catdir);
+require Apache::Test;
+unless (defined $Apache::Test::VERSION) {
+    foreach (@INC) {
+        my $dir = catdir $_, "Apache";
+        next unless -d $dir;
+        opendir DIR, $dir or die "Cannot opendir $dir: $!\n";
+        my @matches = grep /^$/, readdir DIR;
+        closedir DIR;
+        next unless @matches;
+        my $file = catfile $dir, $matches[0];
+        do $file;
+        last;
+    }
+die "Still can't find Apache::Test"
+    unless defined defined $Apache::Test::VERSION;
+sub import {
+    my $package = shift;
+    unshift @_, 'Apache::Test';
+    goto &{Apache::Test->can('import')};
+=head1 NAME
+Apache::TestLoad - Load the correct Apache::Test
+=head1 SYNOPSIS
+  use Apache::TestLoad;
+If you want to use C<Apache::Test>, you should load
+C<Apache::TestLoad> instead. This is a workaround because some case
+insensitive filesystems may load I<Apache/> instead of
+I<Apache/> where mod_perl 1.0 is installed.
+Luckily we can manually walk the @INC dirs and force to load

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->


Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message