httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: Apache-Test and Cwd
Date Wed, 21 Jan 2004 07:20:18 GMT
David Wheeler wrote:
> Hi All,
> 
> A while ago, I enquired about the Cwd that Apache::Test uses, and asked 
> if something could be added to make it different. This is because a lot 
> of existing test modules (such as Test::POD) expect tests to be run from 
> the distribution package root. Apache::Test is fairly unique (outside of 
> Perl itself) in running tests from inside t/. Geoff and I have discussed 
> this problem in the past, and I know that Geoff and Stas have discussed 
> it, too, but wanted to get an update on where things stand on this.

Does the patch below solve the problem?

> Also, has Apache::Test been ported to work with Module::Build yet? 
> Module::Build doesn't use a Makefile, so I wouldn't expect 
> Apache::Test's magic to work with Module::Build, so I wasn't sure if 
> anyone had addressed this yet.

Not yet. It should be trivial for someone who knows Module::Build, since all 
you need is to port two tiny 'test' and 'clean' MM targets from 
Apache/TestMM.pm. Patches are welcome. I'd suggest to call it Apache::TestMB.

Index: lib/Apache/TestHarness.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestHarness.pm,v
retrieving revision 1.12
diff -u -r1.12 TestHarness.pm
--- lib/Apache/TestHarness.pm   12 Sep 2003 02:20:27 -0000      1.12
+++ lib/Apache/TestHarness.pm   21 Jan 2004 07:15:32 -0000
@@ -10,12 +10,6 @@
  use File::Find qw(finddepth);
  use File::Basename qw(dirname);

-sub chdir_t {
-    chdir 't' if -d 't';
-#Apache::TestConfig->new takes care of @INC
-#    inc_fixup();
-}
-
  sub inc_fixup {
      # use blib
      unshift @INC, map "blib/$_", qw(lib arch);
@@ -101,14 +95,14 @@
      my $args = shift;
      my @tests = ();

-    chdir_t();
+    my $base = -d 't' ? catdir('t', '.') : '.';

      my $ts = $args->{tests} || [];

      if (@$ts) {
         for (@$ts) {
             if (-d $_) {
-               push(@tests, sort <$_/*.t>);
+               push(@tests, sort <$base/$_/*.t>);
             }
             else {
                 $_ .= ".t" unless /\.t$/;
@@ -118,7 +112,7 @@
      }
      else {
          if ($args->{tdirs}) {
-            push @tests, map { sort <$_/*.t> } @{ $args->{tdirs} };
+            push @tests, map { sort <$base/$_/*.t> } @{ $args->{tdirs} };
          }
          else {
              finddepth(sub {
@@ -127,7 +121,7 @@
                            my $dotslash = catfile '.', "";
                            $t =~ s:^\Q$dotslash::;
                            push @tests, $t
-                      }, '.');
+                      }, $base);
              @tests = sort @tests;
          }
      }

__________________________________________________________________
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


Mime
View raw message