On Tue, 2 Sep 2003, Stas Bekman wrote:
Randy Kobes wrote:
[ ... ]
sub filter_args { my($args, $wanted_args) = @_; + if (HAS_CONFIG) { + for (qw(group user apxs port httpd)) { + next unless defined $Apache::MyTestConfig->{$_}; + unshift @$args, "-$_", $Apache::MyTestConfig->{$_}; + } + }
may be it's better to do it at a later stage? this just used to generate t/TEST and similar scripts. If MyConfig has changed since t/TEST was generated the changes won't affect t/TEST.
[ .. ]
Thanks, Stas. You're right about the problems with $HOME, and I'll take a more careful look at it, as well as your other comments. In the meantime, here's something that inserts the data at a later stage, and yet still can get overridden by explicit arguments to t/TEST. In this attempt, all the changes are made to Apache::TestRun.pm.
Very good, a few more comments following
=========================================================== Index: TestRun.pm
[...] > + $self->write_config() if
probably better to do that right after $self->configure is completed, as the very last thing in: Apache::TestRun::configure
Notice that it already saves the data, but we don't want most of it. See Apache::TestConfig::save, it saves the data in the local file: t/conf/apache_test_config.pm
[...]
+use Symbol qw(gensym);[...]
+ my $fh = Symbol::gensym();
then probably don't need to import it.
[...]+ my $file = catfile($dir, 'TestConfigData.pm'); + unless (open($fh, ">$file")) { + warn "Cannot open $file: $!"; + return; + } + warn "Writing $file ....\n"; + my $vars = $self->{test_config}->{vars}; + my $config_dump; + for (qw(group user apxs port httpd)) { + next unless $vars->{$_}; + $config_dump .= qq{ '$_' => } . qq{'$vars->{$_}',\n}; + } + + my $pkg = << "EOC"; +package Apache::TestConfigData; +\$Apache::TestConfigData = { +$config_dump +}; +1;
+EOC + print $fh $pkg; + close $fh; + my $test = catdir($vars->{top_dir}, 'blib/lib/Apache'); + if (-e catfile($test, 'Test.pm')) { + my $fh = Symbol::gensym(); + my $file = catfile($test, 'TestConfigData.pm'); + if (-e $file) { + unlink $file or do { + warn "Cannot unlink $file: $!"; + return;
why not a fatal error? It should normally always work, not?
+ } + } + unless (open($fh, ">$file")) { + warn "Cannot open $file: $!"; + return; + }
same here.
+ print $fh $pkg; + close $fh;
Ahm, so you write that file twice if inside the Apache-Test build dir because Makefile.PL has been run long time ago. We will have problems with MakeMaker picking this file for 'make install', so we must provide a placeholder for that file. I suppose Apache/TestConfigData.pm always needs to be in the distribution but include an empty:
$Apache::TestConfigData = {};
So now instead of trying to eval {} for the module in @_ we can simply require it, and then test whether %$Apache::TestConfigData has something in it?
__________________________________________________________________ Stas Bekman JAm_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