httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject cvs commit: httpd-test/perl-framework/Apache-Test Changes
Date Wed, 10 Mar 2004 07:03:32 GMT
stas        2004/03/09 23:03:31

  Modified:    perl-framework/Apache-Test/lib/Apache TestRun.pm
               perl-framework/Apache-Test Changes
  Log:
  make the project's test suite relocatable, handling the case where
  after Apache-Test configuration was created and not cleaned up before
  the directory was moved. This is especially important for those cases
  where users try to run 'make test' as root from /root, A-T tells them
  that they can't do that (because of the perms) and suggests to try
  again, afer moving the whole project under /tmp or similar.
  
  Revision  Changes    Path
  1.158     +55 -3     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.157
  retrieving revision 1.158
  diff -u -u -r1.157 -r1.158
  --- TestRun.pm	9 Mar 2004 20:43:53 -0000	1.157
  +++ TestRun.pm	10 Mar 2004 07:03:30 -0000	1.158
  @@ -668,6 +668,8 @@
       $self->set_ulimit;
       $self->set_env; #make sure these are always set
   
  +    $self->detect_relocation($orig_cwd);
  +
       my(@argv) = @_;
   
       $self->getopts(\@argv);
  @@ -679,9 +681,6 @@
   
       $self->{test_config} = $self->new_test_config();
   
  -    # make it easy to move the whole distro
  -    $self->refresh unless -e $self->{test_config}->{vars}->{top_dir};
  -
       $self->warn_core();
   
       $self->{server} = $self->{test_config}->server;
  @@ -725,6 +724,59 @@
       $self->run_tests;
   
       $self->stop;
  +}
  +
  +# make it easy to move the whole distro w/o running
  +# 't/TEST -clean' before moving. when moving the whole package,
  +# the old cached config will stay, so we want to nuke it only if
  +# we realize that it's no longer valid. we can't just check the
  +# existance of the saved top_dir value, since the project may have
  +# been copied and the old dir could be still there, but that's not
  +# the one that we work in
  +sub detect_relocation {
  +    my($self, $cur_top_dir) = @_;
  +
  +    my $config_file = catfile qw(t conf apache_test_config.pm);
  +    return unless -e $config_file;
  +
  +    my %inc = %INC;
  +    eval { require "$config_file" };
  +    warn($@), return if $@;
  +
  +    my $cfg = 'apache_test_config'->new;
  +    %INC = %inc; # be stealth
  +
  +    # if the top_dir from saved config doesn't match the current
  +    # top_dir, that means that the whole project was relocated to a
  +    # different directory, w/o running t/TEST -clean first (in each
  +    # directory with a test suite)
  +    my $cfg_top_dir = $cfg->{vars}->{top_dir};
  +    return unless $cfg_top_dir;
  +    return if $cfg_top_dir eq $cur_top_dir;
  +
  +    # if that's the case silently fixup the saved config to use the
  +    # new paths, and force a complete cleanup. if we don't fixup the
  +    # config files, the cleanup process won't be able to locate files
  +    # to delete and re-configuration will fail
  +    {
  +        # in place editing
  +        local @ARGV = $config_file;
  +        local $^I = "";
  +        while (<>) {
  +            s{$cfg_top_dir}{$cur_top_dir}g;
  +            print;
  +        }
  +    }
  +
  +    my $cleanup_cmd = "$^X $0 -clean";
  +    warning "cleaning up the old config";
  +    # XXX: do we care to check success?
  +    system $cleanup_cmd;
  +
  +    # XXX: I tried hard to accomplish that w/o starting a new process,
  +    # but too many things get on the way, so for now just keep it as an
  +    # external process, as it's absolutely transparent to the normal
  +    # app-run
   }
   
   my @oh = qw(jeez golly gosh darn shucks dangit rats nuts dangnabit crap);
  
  
  
  1.110     +7 -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.109
  retrieving revision 1.110
  diff -u -u -r1.109 -r1.110
  --- Changes	9 Mar 2004 20:45:01 -0000	1.109
  +++ Changes	10 Mar 2004 07:03:31 -0000	1.110
  @@ -8,6 +8,13 @@
   
   =item 1.10-dev
   
  +make the project's test suite relocatable, handling the case where
  +after Apache-Test configuration was created and not cleaned up before
  +the directory was moved. This is especially important for those cases
  +where users try to run 'make test' as root from /root, A-T tells them
  +that they can't do that (because of the perms) and suggests to try
  +again, afer moving the whole project under /tmp or similar. [Stas]
  +
   When running as 'root' make the client side drop the root permissions
   and run with the same permissions as the server side
   (e.g. nobody). This is needed in case the client side creates any
  
  
  

Mime
View raw message