Re: resolving Apache::Test vs. Apache::test collision

2003-06-17 Thread Stas Bekman
David Wheeler wrote:
On Monday, June 16, 2003, at 02:42  AM, Stas Bekman wrote:
OK, here is the patch that nukes Apache/test.pm. Please test it on 
case-insensitive systems (if you don't have Apache/test.pm, please add 
it just to test). Once you confirm that it works, I release 
Apache::Test 1.03, so we can go ahead with the new libapreq release.

Applied to CVS copy.
If this is what you mean, it should work:
mercury% perl Makefile.PL
generating script t/TEST
Makefile.PL has found old copies of Apache/test.pm which will
be removed to prevent collisions with Apache::Test.
CPAN authors are advised to either use Apache::testold or port their
test suite to Apache::Test which works with both mod_perl generations.
unlink /usr/local/lib/perl5/site_perl/5.8.0/darwin/Apache/test.pm
!!! Failed to delete 
/usr/local/lib/perl5/site_perl/5.8.0/darwin/Apache/test.pm, please make 
sure to delete 
/usr/local/lib/perl5/site_perl/5.8.0/darwin/Apache/test.pm at 
Makefile.PL line 106.
Checking if your kit is complete...
Looks good
Writing Makefile for Apache::Test

So I deleted /usr/local/lib/perl5/site_perl/5.8.0/darwin/Apache/test.pm 
and all is well.
Any idea why has it failed to delete the file? I've copied the code from 
forceunlink sub in MakeMaker (which is called on UNINST=1), it changes the 
mode to 0666 and then attempts to delete the file.

Gonna try to carve out some time this week to port 
MasonX::ApacheHandler::WithCallbacks to Apache::Test :-)
Cool!
__
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


Re: resolving Apache::Test vs. Apache::test collision

2003-06-17 Thread David Wheeler
On Monday, June 16, 2003, at 08:02  PM, Stas Bekman wrote:
Any idea why has it failed to delete the file? I've copied the code 
from forceunlink sub in MakeMaker (which is called on UNINST=1), it 
changes the mode to 0666 and then attempts to delete the file.
Because I ran it as a non-root user.
David
--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED]  ICQ: 15726394
http://kineticode.com/ Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]


Re: resolving Apache::Test vs. Apache::test collision

2003-06-17 Thread Stas Bekman
Stas Bekman wrote:
David Wheeler wrote:
On Monday, June 16, 2003, at 08:02  PM, Stas Bekman wrote:
Any idea why has it failed to delete the file? I've copied the code 
from forceunlink sub in MakeMaker (which is called on UNINST=1), it 
changes the mode to 0666 and then attempts to delete the file.

Because I ran it as a non-root user.

This makes sense :) so it doesn't fit the idiom:
% perl Makefile.PL
% make
% make test
% su
% make install
in that case we need to override the 'make install' target to delete the 
files. instead of doind that during 'perl Makefile.PL'.
David, please test this patch. This version performs the cleanup only during 
'make install'. what I'm not sure about is whether it handles correctly some 
weird paths when creating the packlist. I think it should work, since nothing 
is passed via shell, but goes perl-2-perl.

Index: Makefile.PL
===
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Makefile.PL,v
retrieving revision 1.8
diff -u -r1.8 Makefile.PL
--- Makefile.PL 29 Apr 2003 06:37:47 -  1.8
+++ Makefile.PL 17 Jun 2003 02:51:17 -
@@ -1,5 +1,7 @@
 use 5.005;
+use strict;
+
 use ExtUtils::MakeMaker;
 use Symbol;
@@ -7,10 +9,14 @@
 my $VERSION;
+use File::Spec::Functions qw(catfile catdir);
+
 use Apache::Test5005compat;
 use Apache::TestMM qw(test); #enable 'make test'
+my $cleanup_packlist = .mypacklist;
+
 Apache::TestMM::filter_args();
 my @scripts = qw(t/TEST);
@@ -21,6 +27,8 @@
 set_version();
+nuke_Apache__test();
+
 WriteMakefile(
 NAME  = 'Apache::Test',
 VERSION   = $VERSION,
@@ -59,3 +67,74 @@
 return $string;
 }
+
+# on Case-Insensitive systems Apache/Test.pm can't coexist with
+# Apache/test.pm, since Apache::test is now deprecated (was renamed to
+# Apache/testold.pm in mod_perl 1.28, we need to find and remove any
+# occurrences of this file. CPAN authors should
+# s/Apache::test/Apache::testold/ and can either require mod_perl 1.28
+# which already carries it or simply bundle it. The best option is to
+# port the test suite to use Apache::Test which works with both
+# mod_perl generations.
+#
+# we could have done this cleanup only for case-insensitive systems,
+# but I feel that doing it for all systems, will speedup the
+# transitions from Apache::test to either Apache::Test or
+# Apache::testold.
+#
+sub nuke_Apache__test {
+
+my @convicts = ();
+foreach (@INC) {
+my $dir = catdir $_, Apache;
+next unless -d $dir;
+opendir DIR, $dir or die Cannot opendir $dir: $!\n;
+my @matches = grep /^test.pm$/, readdir DIR;
+closedir DIR;
+push @convicts, map { catfile $dir, $_ } @matches if @matches;
+}
+
+if (@convicts) {
+print EOI;
+!!! Makefile.PL has found old copies of Apache/test.pm which will
+be removed during 'make install' to prevent collisions with Apache::Test:
+
[EMAIL PROTECTED] \n, @convicts]}
+
+CPAN authors are advised to either use Apache::testold or port their
+test suite to Apache::Test which works with both mod_perl generations.
+EOI
+}
+
+open PACKLIST, $cleanup_packlist
+or die Can't open $cleanup_packlist: $!;
+print PACKLIST join , map $_\n, @convicts;
+close PACKLIST;
+}
+
+sub MY::install {
+my $self = shift;
+
+my $string = $self-MM::install(@_);
+add_dep(\$string, pure_install = 'nuke_Apache__test');
+
+$string;
+}
+
+sub MY::top_targets {
+my $self = shift;
+my $string = $self-MY::top_targets;
+
+$string .= EOF;
+
+nuke_Apache__test:
+\t\$(PERLRUN) -MExtUtils::Install -e 'uninstall($cleanup_packlist, 1, 0)'
+EOF
+
+$string;
+}
+
+sub add_dep {
+my($string, $targ, $add) = @_;
+$$string =~ s/($targ\s+::)/$1 $add/;
+}


Perl Testing

2003-06-17 Thread David Wheeler
Hi All,
I'm porting MasonX::CallbackHandler from Apache::test to Apache::Test. 
My Makefile.PL does this:

use Apache::TestMM qw(test clean);
use Apache::TestRunPerl;
Apache::TestMM::filter_args();
Apache::TestRunPerl-generate_script();
This is nice, because it creates t/TEST for me. But I've noticed a 
couple of issues that might be relevant to other folks porting from 
Apache::test:

1. The documentation is pretty lacking. Granted, it was bad in 
Apache::test, too, but I sure would like to see some decent pod in each 
of the important Apache::Test* modules.

2. The tests are being run from t/, rather then from the root of the 
module distribution directory. IIRC, Perl itself runs all of its tests 
from t/, but all modules by default run them from the module 
distribution root. Can this be fixed/changed?

3. Those of us porting from Apache::test typically have a special 
configuration file (now nicely able to be t/lib/extra.conf.in -- 
thanks!) and loads up the libraries we want to test. However, Apache 
isn't being started during `make test` with Cuse blib. Now, since 
tests run from t, even it it did Cuse blib, it wouldn't work. So I 
had to add this code to my extra.conf.in:

Perl
  use File::Spec::Functions qw(catdir);
  use lib catdir '@ServerRoot@', '..', 'blib';
  use lib catdir '@ServerRoot@', '..', 'lib';
/Perl
Could this, too, be fixed? Perhaps just for Perl modules?
TIA for your help/answers/corrections to my observations.
Regards,
David
--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED]  ICQ: 15726394
http://kineticode.com/ Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]


Re: Perl Testing

2003-06-17 Thread Geoffrey Young

1. The documentation is pretty lacking. Granted, it was bad in 
Apache::test, too, but I sure would like to see some decent pod in each 
of the important Apache::Test* modules.
agreed.  resources you may find useful (if you haven't seen them already):
http://www.perl.com/pub/a/2003/05/22/testing.html
http://perl.apache.org/docs/general/testing/testing.html
there is also some good information in the README
http://search.cpan.org/src/STAS/Apache-Test-1.01/README

3. Those of us porting from Apache::test typically have a special 
configuration file (now nicely able to be t/lib/extra.conf.in -- 
thanks!) and loads up the libraries we want to test. However, Apache 
isn't being started during `make test` with Cuse blib. Now, since 
tests run from t, even it it did Cuse blib, it wouldn't work. So I had 
to add this code to my extra.conf.in:

Perl
  use File::Spec::Functions qw(catdir);
  use lib catdir '@ServerRoot@', '..', 'blib';
  use lib catdir '@ServerRoot@', '..', 'lib';
/Perl
for the most part, Apache-Test does the right thing.  the only exception I've noticed is 
for modules that use XS or otherwise need to be preloaded.  the solution for this is to to 
use t/conf/extra.last.conf.in in place of t/conf/extra.conf.in.  this allows Apache-Test 
to set the proper blib (via PerlRequre) before including modules from your configuration. 
 even if you don't use XS, this may solve your problem.

you can also extend libraries, etc, via t/conf/modperl_extra.pl
HTH
--Geoff


Re: GET() w/o redirection

2003-06-17 Thread David Wheeler
On Tuesday, June 17, 2003, at 05:46  PM, David Wheeler wrote:
Apache::TestRequest::user_agent( requests_redirectable = 0 );
However, it still seems to redirect. If someone could tell me how I 
might get Apache::TestRequest to pay attention to the LWP::UserAgent 
settings I want it to use, I would greatly appreciate it.
I finally figured out that this works:
  $Apache::TestRequest::RedirectOK = 0;
Again, more docs would be welcome.
Thanks,
David
--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED]  ICQ: 15726394
http://kineticode.com/ Yahoo!: dew7e
   Jabber: [EMAIL PROTECTED]
Kineticode. Setting knowledge in motion.[sm]