stas        2004/01/30 17:12:17

  Modified:    perl-framework/Apache-Test/lib/Apache TestHarness.pm
                        TestRun.pm
               perl-framework/Apache-Test Changes
  Log:
  In order to make Apache-Test compatible with the rest of Perl testing
  frameworks, we no longer chdir into t/, but run from the root of the
  project (where t/ resides). A test needing to know where it's running
  from (e.g. to read/write files/dirs on the filesystem), should do that
  relative to the serverroot, documentroot and other server
  configuration variables, available via
  Apache::Test::vars('serverroot'), Apache::Test::vars('documentroot'),
  etc.
  
  Revision  Changes    Path
  1.13      +5 -11     
httpd-test/perl-framework/Apache-Test/lib/Apache/TestHarness.pm
  
  Index: TestHarness.pm
  ===================================================================
  RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestHarness.pm,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -u -r1.12 -r1.13
  --- TestHarness.pm    12 Sep 2003 02:20:27 -0000      1.12
  +++ TestHarness.pm    31 Jan 2004 01:12:17 -0000      1.13
  @@ -6,16 +6,10 @@
   use Test::Harness ();
   use Apache::TestSort ();
   use Apache::TestTrace;
  -use File::Spec::Functions qw(catfile);
  +use File::Spec::Functions qw(catfile catdir);
   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;
           }
       }
  
  
  
  1.144     +6 -8      
httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm
  
  Index: TestRun.pm
  ===================================================================
  RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
  retrieving revision 1.143
  retrieving revision 1.144
  diff -u -u -r1.143 -r1.144
  --- TestRun.pm        18 Jan 2004 08:34:29 -0000      1.143
  +++ TestRun.pm        31 Jan 2004 01:12:17 -0000      1.144
  @@ -125,31 +125,31 @@
       my($self) = @_;
   
       my(@tests);
  +    my $top_dir = $self->{test_config}->{vars}->{top_dir};
  +    my $t_dir = $self->{test_config}->{vars}->{t_dir};
   
       my $argv = $self->{argv};
       my @leftovers = ();
       for (@$argv) {
           my $arg = $_;
  -        #need the t/ for stat-ing, but dont want to include it in test output
  +        #need the t/ for stat-ing, but don't want to include it in test 
output
           $arg =~ [EMAIL PROTECTED](?:\./)?t/@@;
  -        my $t_dir = catfile qw(.. t);
           my $file = catfile $t_dir, $arg;
  -
           if (-d $file and $_ ne '/') {
               my @files = <$file/*.t>;
  +            my $remove = catfile $top_dir, "";
               if (@files) {
  -                my $remove = catfile $t_dir, "";
                   push @tests, map { s,^\Q$remove,,; $_ } @files;
                   next;
               }
           }
           else {
               if ($file =~ /\.t$/ and -e $file) {
  -                push @tests, "$arg";
  +                push @tests, "t/$arg";
                   next;
               }
               elsif (-e "$file.t") {
  -                push @tests, "$arg.t";
  +                push @tests, "t/$arg.t";
                   next;
               }
               elsif (/^[\d.]+$/) {
  @@ -644,8 +644,6 @@
       $self->set_env; #make sure these are always set
   
       my(@argv) = @_;
  -
  -    Apache::TestHarness->chdir_t;
   
       $self->getopts([EMAIL PROTECTED]);
   
  
  
  
  1.84      +9 -0      httpd-test/perl-framework/Apache-Test/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Changes,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -u -r1.83 -r1.84
  --- Changes   27 Jan 2004 19:40:01 -0000      1.83
  +++ Changes   31 Jan 2004 01:12:17 -0000      1.84
  @@ -8,6 +8,15 @@
   
   =item 1.08_dev
   
  +In order to make Apache-Test compatible with the rest of Perl testing
  +frameworks, we no longer chdir into t/, but run from the root of the
  +project (where t/ resides). A test needing to know where it's running
  +from (e.g. to read/write files/dirs on the filesystem), should do that
  +relative to the serverroot, documentroot and other server
  +configuration variables, available via
  +Apache::Test::vars('serverroot'), Apache::Test::vars('documentroot'),
  +etc. [Stas]
  +
   generate t/conf if it does not already exist, which
   it may not if the tests are entirely autoconfigured.
   [Geoffrey Young]
  
  
  

Reply via email to