Re: sticky preferences in Apache-Test

2004-01-18 Thread Stas Bekman
Randy Kobes wrote:
On Tue, 13 Jan 2004, Stas Bekman wrote:

Randy Kobes wrote:
I haven't worked through this yet, but I find a similar
problem ... I have two Perls, both of which have mp2
installed, but one has the CPAN Apache-Test and the other
has the cvs Apache-Test installed. In building the
cvs Apache-Test, I get the first-time dialogue with
the perl with the CPAN Apache-Test installed, but don't
get the dialogue with the perl with the cvs Apache-Test
installed. I'm a bit baffled as to why, as this occurs
even if I delete the system TestConfigData.pm.
But CPAN A-T doesn't have this feature, so you must have
installed mp2-cvs on top of it. Also check that you don't
have ~/.apache-test/.

I don't have an ~/.apache-test/, and yes, using the perl
with the CPAN A-T installed to build the cvs A-T is fine.
Where I run into problems in not seeing the configuration
dialogue is using the perl with the cvs A-T installed in
building the cvs A-T, even if I delete the installed
TestConfigData.pm.
That's the correct behavior at the moment, because you have mp2 installed. If 
mp2 is found it has Apache/BuildConfig.pm which tells A-T where httpd is. And 
A-T will save that value in the global Apache/TestConfigData.pm if it can 
write to it, or in ~/.apache-test/.'

Of course we can change that behavior, but I think it's cool as mp2 users will 
never see that interactive dialog.

__
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: sticky preferences in Apache-Test

2004-01-18 Thread Randy Kobes
On Sat, 17 Jan 2004, Stas Bekman wrote:

 Randy Kobes wrote:
[ ... ]
  I don't have an ~/.apache-test/, and yes, using the perl
  with the CPAN A-T installed to build the cvs A-T is fine.
  Where I run into problems in not seeing the configuration
  dialogue is using the perl with the cvs A-T installed in
  building the cvs A-T, even if I delete the installed
  TestConfigData.pm.

 That's the correct behavior at the moment, because you
 have mp2 installed. If mp2 is found it has
 Apache/BuildConfig.pm which tells A-T where httpd is. And
 A-T will save that value in the global
 Apache/TestConfigData.pm if it can write to it, or in
 ~/.apache-test/.'

 Of course we can change that behavior, but I think it's
 cool as mp2 users will never see that interactive dialog.

That is neat - I was just wondering where A-T was finding
this information from. I'd leave that as is - thanks.

-- 
best regards,
randy


Re: sticky preferences in Apache-Test

2004-01-18 Thread Stas Bekman
Randy Kobes wrote:
On Sat, 17 Jan 2004, Stas Bekman wrote:

Randy Kobes wrote:
[ ... ]
I don't have an ~/.apache-test/, and yes, using the perl
with the CPAN A-T installed to build the cvs A-T is fine.
Where I run into problems in not seeing the configuration
dialogue is using the perl with the cvs A-T installed in
building the cvs A-T, even if I delete the installed
TestConfigData.pm.
That's the correct behavior at the moment, because you
have mp2 installed. If mp2 is found it has
Apache/BuildConfig.pm which tells A-T where httpd is. And
A-T will save that value in the global
Apache/TestConfigData.pm if it can write to it, or in
~/.apache-test/.'
Of course we can change that behavior, but I think it's
cool as mp2 users will never see that interactive dialog.

That is neat - I was just wondering where A-T was finding
this information from. I'd leave that as is - thanks.
That feature was in A-T for about 2 years I think. I've removed it when I did 
the first iteration of custom config, but then immediately added it back, 
since it was silly to call an interactive config when you could avoid it.

__
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: sticky preferences in Apache-Test

2004-01-13 Thread Stas Bekman
Geoffrey Young wrote:
I think the patch below handles that fine for any mp2 builds.

I've done some more digging - this patch seems to be required.
How does it map on the thought from my previous email:
Let's see if we can stay without making a modperl-2.0 build special. Why? 
Because it should use the modperl-2.0 build args for any 3rd party modules A-T 
runs, if it's installed and used. So it's really the same as modperl-2.0's 
make test. 

Index: lib/Apache/TestRun.pm
===
RCS file:
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.135
diff -u -r1.135 TestRun.pm
--- lib/Apache/TestRun.pm   8 Jan 2004 04:54:06 -   1.135
+++ lib/Apache/TestRun.pm   8 Jan 2004 21:07:01 -
@@ -1291,6 +1291,11 @@
sub custom_config_load {
debug trying to load custom config data;
+if (Apache::TestConfig::IS_MOD_PERL_2_BUILD()) {
+debug modperl-2.0 build - ignore any custom config data;
+return;
+}
+
if (my $custom_config_path = custom_config_path()) {
debug loading custom config path '$custom_config_path';


--
__
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: sticky preferences in Apache-Test

2004-01-13 Thread Stas Bekman
Geoffrey Young wrote:
Stas Bekman wrote:
Geoffrey Young wrote:

I think the patch below handles that fine for any mp2 builds.

I've done some more digging - this patch seems to be required.

How does it map on the thought from my previous email:
Let's see if we can stay without making a modperl-2.0 build special.
Why? Because it should use the modperl-2.0 build args for any 3rd party
modules A-T runs, if it's installed and used. So it's really the same as
modperl-2.0's make test. 

I can't really grok what you mean here.
what I do know, however, is that my nightly builds start with 2.1 then move
to 2.0, issuing 'make realclean' between each.  for the past few nights, the
2.0 tests don't run because it's loading TestConfigData.pm from my global
@INC.  at that point, TestConfigData.pm is from the last install, which is a
2.1 install.
this seems wrong to me - I have no remedy short of removing
TestDataConfig.pm between builds - at I think it would affect users that
upgrade as well.
Are you sure that your not problem is elsewhere? I see this issue too though 
with non-mp2 build, just didn't have a chance to work on it yet.

How do you build your mp2? It should ignore the custom config already, there 
must be some glitch.

I'm going to complete the Apache manpages generation and then work on it.
__
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: sticky preferences in Apache-Test

2004-01-13 Thread Randy Kobes
On Tue, 13 Jan 2004, Stas Bekman wrote:

 Geoffrey Young wrote:
[ ... ]
  what I do know, however, is that my nightly builds start
  with 2.1 then move to 2.0, issuing 'make realclean'
  between each.  for the past few nights, the 2.0 tests
  don't run because it's loading TestConfigData.pm from my
  global @INC.  at that point, TestConfigData.pm is from
  the last install, which is a 2.1 install.
 
  this seems wrong to me - I have no remedy short of removing
  TestDataConfig.pm between builds - at I think it would affect users that
  upgrade as well.

 Are you sure that your not problem is elsewhere? I see
 this issue too though with non-mp2 build, just didn't have
 a chance to work on it yet.

 How do you build your mp2? It should ignore the custom
 config already, there must be some glitch.

I haven't worked through this yet, but I find a similar
problem ... I have two Perls, both of which have mp2
installed, but one has the CPAN Apache-Test and the other
has the cvs Apache-Test installed. In building the
cvs Apache-Test, I get the first-time dialogue with
the perl with the CPAN Apache-Test installed, but don't
get the dialogue with the perl with the cvs Apache-Test
installed. I'm a bit baffled as to why, as this occurs
even if I delete the system TestConfigData.pm.

-- 
best regards,
randy


Re: sticky preferences in Apache-Test

2004-01-13 Thread Stas Bekman
Randy Kobes wrote:
On Tue, 13 Jan 2004, Stas Bekman wrote:

Geoffrey Young wrote:
[ ... ]
what I do know, however, is that my nightly builds start
with 2.1 then move to 2.0, issuing 'make realclean'
between each.  for the past few nights, the 2.0 tests
don't run because it's loading TestConfigData.pm from my
global @INC.  at that point, TestConfigData.pm is from
the last install, which is a 2.1 install.
this seems wrong to me - I have no remedy short of removing
TestDataConfig.pm between builds - at I think it would affect users that
upgrade as well.
Are you sure that your not problem is elsewhere? I see
this issue too though with non-mp2 build, just didn't have
a chance to work on it yet.
How do you build your mp2? It should ignore the custom
config already, there must be some glitch.

I haven't worked through this yet, but I find a similar
problem ... I have two Perls, both of which have mp2
installed, but one has the CPAN Apache-Test and the other
has the cvs Apache-Test installed. In building the
cvs Apache-Test, I get the first-time dialogue with
the perl with the CPAN Apache-Test installed, but don't
get the dialogue with the perl with the cvs Apache-Test
installed. I'm a bit baffled as to why, as this occurs
even if I delete the system TestConfigData.pm.
But CPAN A-T doesn't have this feature, so you must have installed mp2-cvs on 
top of it. Also check that you don't have ~/.apache-test/.

__
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: sticky preferences in Apache-Test

2004-01-13 Thread Randy Kobes
On Tue, 13 Jan 2004, Stas Bekman wrote:

 Randy Kobes wrote:
 
  I haven't worked through this yet, but I find a similar
  problem ... I have two Perls, both of which have mp2
  installed, but one has the CPAN Apache-Test and the other
  has the cvs Apache-Test installed. In building the
  cvs Apache-Test, I get the first-time dialogue with
  the perl with the CPAN Apache-Test installed, but don't
  get the dialogue with the perl with the cvs Apache-Test
  installed. I'm a bit baffled as to why, as this occurs
  even if I delete the system TestConfigData.pm.

 But CPAN A-T doesn't have this feature, so you must have
 installed mp2-cvs on top of it. Also check that you don't
 have ~/.apache-test/.

I don't have an ~/.apache-test/, and yes, using the perl
with the CPAN A-T installed to build the cvs A-T is fine.
Where I run into problems in not seeing the configuration
dialogue is using the perl with the cvs A-T installed in
building the cvs A-T, even if I delete the installed
TestConfigData.pm.

-- 
best regards,
randy


Re: sticky preferences in Apache-Test

2004-01-09 Thread Geoffrey Young


 $ perl Makefile.PL MP_APXS=/apache/2.1/prefork/perl-5.8.2/bin/apxs
 ...
 Configuring Apache/2.1.0-dev mod_perl/1.99_13-dev Perl/v5.8.2

 $ make  make test
 ...
 using Apache/2.0.49-dev (prefork MPM)

 waiting 120 seconds for server to start: .httpd: module mod_perl.c
 is not
 compatible with this version of Apache (found 20030821, need 20020903).

this seems to have gone away - it must have been a result of some stuff left
over from a previous implementation.

--Geoff



Re: sticky preferences in Apache-Test

2004-01-09 Thread Stas Bekman
Geoffrey Young wrote:
$ perl Makefile.PL MP_APXS=/apache/2.1/prefork/perl-5.8.2/bin/apxs
...
Configuring Apache/2.1.0-dev mod_perl/1.99_13-dev Perl/v5.8.2
$ make  make test
...
using Apache/2.0.49-dev (prefork MPM)
waiting 120 seconds for server to start: .httpd: module mod_perl.c
is not
compatible with this version of Apache (found 20030821, need 20020903).

this seems to have gone away - it must have been a result of some stuff left
over from a previous implementation.
You mean it wasn't 'cvs up'ed?
Let's see if we can stay without making a modperl-2.0 build special. Why? 
Because it should use the modperl-2.0 build args for any 3rd party modules A-T 
runs, if it's installed and used. So it's really the same as modperl-2.0's 
make test.

__
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: sticky preferences in Apache-Test

2004-01-08 Thread Stas Bekman
Geoffrey Young wrote:
Geoffrey Young wrote:
committed. looking forward to hear about the odd parts. 

the first thing that strikes me is that when I build mod_perl with
MP_APXS=/foo/bin/apxs then make  make test I get the dialogue asking me to
choose httpd and apxs binaries.
I don't think we want a prompt for the mod_perl test suite - it should be
obvious that I want to use the binaries I'm building mod_perl against.

actually, it seems a bit worse than that - I'm stuck in an endless loop and
the test suite never runs.  hmph.
Yes, thank you Geoff, I've noticed that too late. And my mail server was down 
most of the day :(

I think I have fixed these problems now.
What bothers me is the call to default_httpd, which may pick a wrong server. 
So I've removed it. It is used in the interactive config, to help user to find 
the right httpd.

__
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: sticky preferences in Apache-Test

2004-01-08 Thread Geoffrey Young

 Yes, thank you Geoff, I've noticed that too late. And my mail server was
 down most of the day :(

:)

 
 I think I have fixed these problems now.
 
 What bothers me is the call to default_httpd, which may pick a wrong
 server. So I've removed it. It is used in the interactive config, to
 help user to find the right httpd.

I'm not sure if this is related, but something is still amuck for me.  it
seems that TestConfigData.pm isn't being properly cleaned up on 'make
realclean' or otherwise overwritten:

$ perl Makefile.PL MP_APXS=/apache/2.1/prefork/perl-5.8.2/bin/apxs
...
Configuring Apache/2.1.0-dev mod_perl/1.99_13-dev Perl/v5.8.2

$ make  make test
...
using Apache/2.0.49-dev (prefork MPM)

waiting 120 seconds for server to start: .httpd: module mod_perl.c is not
compatible with this version of Apache (found 20030821, need 20020903).

--Geoff



Re: sticky preferences in Apache-Test

2004-01-08 Thread Geoffrey Young

 Can you please run t/TEST -debug=trace and see which TestConfigData.pm
 is loaded? what's inside of it? May be the simple solution is not to
 load custom_config when running from inside modperl-2.0? I think that's
 the best solution.

I've already cleaned everything out for today, but I'll do that tomorrow
after my nightly builds run.

 
 The problem is that we have 4 TestConfigData.pm files. If you are inside
 modperl-2.0 or Apache-Test, you have one in lib and one in blib, the one
 in lib is created as an empty config during 'perl Makefile.PL' then it's
 copied to blib. Things gets complicated when you have a global 
 TestConfigData.pm installed and when you have ~/.apache-test one
 installed. It gets very tricky.

no doubt :)

it is possible to have a makepl_args.mod_perl2 setting whereby using saved
settings is skipped altogether?  with all the builds that we both do
nightly, that's the way I'd prefer to do at least infers from the build
enviroment at the moment.

--Geoff



Re: sticky preferences in Apache-Test

2004-01-07 Thread Stas Bekman
OK, here is a an extended version of Randy's original work to be able to save 
and reuse A-T config. I've added first time interactive configuration feature 
(similar to CPAN.pm). It took me a long time to polish it as there are so many 
possible cases on how this new feature can be used, it was pretty tricky. I 
haven't quite tested -save too. Also there could be some issues with win32, 
I'm sure Randy will post a fix. It's a pretty big patch, let me know if you 
want me to commit it and we will take it from there, making it easier to users 
to test it. We probably need to polish it somewhat.

Also notice that I did a few tweaks to mp2 source to support new A-T features. 
so you need to apply it from modperl-2.0, but you can and should test in 
Apache-Test/ as well.

I did various tests including:
1. 'make test' from Apache-Test.
   o delete blib
   o delete local lib/Apache/TestConfigData.pm
   o delete global Apache/TestConfigData.pm
1a - interactive config should kick in first time
1b - second time it should run without interactive config
1c - run 'make install',
 o delete blib
 o delete local lib/Apache/TestConfigData.pm
 'make test' should run without interactive config
1d - now remove the globally installed Apache/TestConfigData.pm,
 and run 't/TEST -httpd /path'
 interactive config shouldn't kick in
2. repeat 1 but replace 'make test' with 't/TEST'
3. 'make test' from modperl-2.0, first
   o delete local lib/Apache/TestConfigData.pm
   o delete global Apache/TestConfigData.pm
3a - interactive config shouldn't kick in first time,
 since we explicitly path -httpd behind the scenes
3b - 'make install' (which installs a custom config),
 now build mod_perl against a different httpd path, make sure
 that 'make test' uses that different httpd path and not the one
 from the custom config
4. custom config wasn't done during install of Apache-Test (e.g. rpm
   binary package).
   o delete global Apache/TestConfigData.pm
   pick some module which uses Apache-Test
4a. run 'make test' - interactive config should kick in
   make sure that it was saved in ~/.apache-test/Apache/TestConfigData.pm
   (because there is no global config)
4b. run 'make test' - interactive config should not kick in second time
5. -save option (test to be written) main issue is to avoid the situation
when 'Apache/TestConfigData.pm' was written to a root owned directory
and a non-root user is trying to -save (need to save into
~/.apache-test/Apache/TestConfigData.pm, if the custom_config_path
returns a path owned by root).
ok here it the patch:
Index: Apache-Test/Makefile.PL
===
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Makefile.PL,v
retrieving revision 1.15
diff -u -r1.15 Makefile.PL
--- Apache-Test/Makefile.PL 6 Jan 2004 19:17:59 -   1.15
+++ Apache-Test/Makefile.PL 7 Jan 2004 03:46:57 -
@@ -12,12 +12,14 @@
 use ExtUtils::MakeMaker;
 use Symbol;
+use File::Spec::Functions qw(catfile);
+use FindBin;
 use Apache::TestMM qw(test); #enable 'make test'
+use Apache::TestRun;
 my $VERSION;
-
 Apache::TestMM::filter_args();
 my @scripts = qw(t/TEST);
@@ -35,6 +37,8 @@
 add_Apache__test_target();
 }
+write_custom_config_file_stub();
+
 WriteMakefile(
 NAME  = 'Apache::Test',
 VERSION   = $VERSION,
@@ -99,3 +103,17 @@
 $string;
 };
 }
+
+# write the custom test file so it'll be copied to blib if updated
+# during 'make test' and then installed system-wide
+sub write_custom_config_file_stub {
+# It doesn't matter whether it gets written under modperl-2.0/lib
+# or Apache-Test/lib root, since Apache::TestRun uses the same
+# logic and will update that file with real config data, which
+# 'make install' will then pick and install system-wide
+my $path = catfile $FindBin::Bin, lib,
+Apache::TestRun::CUSTOM_CONFIG_FILE;
+# write an empty stub
+Apache::TestRun::custom_config_write($path, '');
+}
+
Index: Apache-Test/lib/Apache/TestConfig.pm
===
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.192
diff -u -r1.192 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm	5 Jan 2004 23:40:53 -	1.192
+++ Apache-Test/lib/Apache/TestConfig.pm	7 Jan 2004 03:46:58 -
@@ -17,6 +17,9 @@
 use constant IS_MOD_PERL_2_BUILD = IS_MOD_PERL_2 
 require Apache::Build  Apache::Build::IS_MOD_PERL_BUILD();

+use constant IS_APACHE_TEST_BUILD =
+grep { -e $_/lib/Apache/TestConfig.pm } qw(. ..);
+
 use Symbol ();
 use File::Copy ();
 use File::Find qw(finddepth);
@@ -305,20 +308,6 @@
 $vars-{target} ||= (WIN32 ? 'Apache.exe' : 'httpd');
-unless ($vars-{httpd}) {
-#sbindir should be bin/ with the default layout
-#but its eaiser to workaround apxs than fix apxs
-for my $dir (map { $vars-{$_} 

Re: sticky preferences in Apache-Test

2004-01-07 Thread Geoffrey Young

 committed. looking forward to hear about the odd parts. 

the first thing that strikes me is that when I build mod_perl with
MP_APXS=/foo/bin/apxs then make  make test I get the dialogue asking me to
choose httpd and apxs binaries.

I don't think we want a prompt for the mod_perl test suite - it should be
obvious that I want to use the binaries I'm building mod_perl against.

--Geoff



Re: sticky preferences in Apache-Test

2004-01-07 Thread Geoffrey Young


Geoffrey Young wrote:
committed. looking forward to hear about the odd parts. 
 
 
 the first thing that strikes me is that when I build mod_perl with
 MP_APXS=/foo/bin/apxs then make  make test I get the dialogue asking me to
 choose httpd and apxs binaries.
 
 I don't think we want a prompt for the mod_perl test suite - it should be
 obvious that I want to use the binaries I'm building mod_perl against.

actually, it seems a bit worse than that - I'm stuck in an endless loop and
the test suite never runs.  hmph.

--Geoff



Re: sticky preferences in Apache-Test

2003-09-25 Thread Randy Kobes
On Wed, 24 Sep 2003, Randy Kobes wrote:

 Hi,
 Below is a modified diff to allow for preferences
 to be saved to an Apache::TestConfigData for later use
 within Apache::Test. In this version, a user can create
 a $HOME/.apache-test/Apache/TestConfigData.pm to specify
 the preferences; this will be used, if it exists, before
 a system Apache::TestConfigData. The diff is applied
 against the cvs Apache-Test sources; as well, an
 empty Apache-Test/lib/Apache/TestConfigData.pm file
 should be created:
 ===
 package Apache::TestConfigData;
 use strict;
 use warnings;
 use vars qw($vars);

 $vars = {

 };
 1;

 =head1 NAME

 Apache::TestConfigData - Configuration file for Apache::Test

 =cut
 
 The intent of how this is supposed to work is in the pod
 of Apache::TestRun.

Sorry - I forgot to include the diff to Apache::TestUtil -
a complete diff appears below.

Index: lib/Apache/TestRun.pm
===
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.114
diff -u -r1.114 TestRun.pm
--- lib/Apache/TestRun.pm   12 Sep 2003 02:21:32 -  1.114
+++ lib/Apache/TestRun.pm   25 Sep 2003 06:25:56 -
@@ -10,20 +10,24 @@
 use Apache::TestRequest ();
 use Apache::TestHarness ();
 use Apache::TestTrace;
+use Apache::TestUtil qw(expand_path);

+use Cwd;
 use File::Find qw(finddepth);
-use File::Spec::Functions qw(catfile);
+use File::Spec::Functions qw(catfile catdir);
 use Getopt::Long qw(GetOptions);
+use File::Basename qw(dirname);
 use Config;

 use constant STARTUP_TIMEOUT = 300; # secs (good for extreme debug cases)
+
 use subs qw(exit_shell exit_perl);

 my %core_files  = ();
 my %original_t_perms = ();

 my @std_run  = qw(start-httpd run-tests stop-httpd);
-my @others   = qw(verbose configure clean help ssl http11);
+my @others   = qw(verbose configure clean help ssl http11 save);
 my @flag_opts= (@std_run, @others);
 my @string_opts  = qw(order trace);
 my @ostring_opts = qw(proxy ping);
@@ -55,9 +59,22 @@
'ssl' = 'run tests through ssl',
'proxy'   = 'proxy requests (default proxy is localhost)',
'trace=T' = 'change tracing default to: warning, notice, info, 
debug, ...',
+   'save'= 'save test paramaters into Apache::TestConfigData',
(map { $_, \U$_\E url } @request_opts),
 );

+# variables stored in $Apache::TestConfigData::vars
+my @data_vars = qw(httpd port user group apxs);
+# mapping from $Apache::TestConfigData::vars to $ENV settings
+my %vars_to_env = (httpd = 'APACHE',
+   user  = 'APACHE_USER',
+   group = 'APACHE_GROUP',
+   apxs  = 'APXS',
+   port  = 'APACHE_PORT',
+   );
+my $IN_APACHE_TEST = in_apache_test();
+my $CONFIG_DATA = config_data();
+
 sub fixup {
 #make sure we use an absolute path to perl
 #else Test::Harness uses the perl in our PATH
@@ -407,6 +424,8 @@
 $test_config-cmodules_configure;
 $test_config-generate_httpd_conf;
 $test_config-save;
+$self-write_config() if
+($IN_APACHE_TEST or $self-{opts}-{save});
 }

 sub try_exit_opts {
@@ -509,6 +528,10 @@

 sub new_test_config {
 my $self = shift;
+for (@data_vars) {
+next unless $Apache::TestConfigData::vars-{$_};
+$self-{conf_opts}-{$_} ||= $Apache::TestConfigData::vars-{$_};
+}
 Apache::TestConfig-new($self-{conf_opts});
 }

@@ -953,6 +976,102 @@
 CORE::exit $_[0];
 }

+# Are we building things within Apache-Test?
+sub in_apache_test {
+my $cwd =  expand_path(cwd);
+return ($cwd =~ m{Apache-Test}) ? 1 : 0;
+}
+
+# routine to determine where the configuration file
+# Apache::TestConfigData lives. The order searched is
+# 1) a path within Apache-Test, if we are building things there
+# 2) an $ENV{HOME}/.apache-test/ directory;
+# 3) somewhere in @INC, other than a path within Apache-Test.
+sub config_data {
+my $config;
+my $file = 'TestConfigData.pm';
+# XXX $ENV{HOME} isn't propagated in mod_perl
+unshift @INC, catdir($ENV{HOME}, '.apache-test') if $ENV{HOME};
+for (@INC) {
+my $candidate = catfile($_, 'Apache', $file);
+if (-e $candidate) {
+eval {require $candidate};
+next if $@;
+if (config_has_data()) {
+$config = $candidate;
+last;
+}
+}
+}
+unless ($IN_APACHE_TEST) {
+die 'Could not find a valid Apache::TestConfigData'
+unless config_has_data();
+}
+shift @INC if $ENV{HOME};
+# preferentially use environment variables
+for (@data_vars) {
+next unless my $value = $ENV{$vars_to_env{$_}};
+

sticky preferences in Apache-Test

2003-09-24 Thread Randy Kobes
Hi,
Below is a modified diff to allow for preferences
to be saved to an Apache::TestConfigData for later use
within Apache::Test. In this version, a user can create
a $HOME/.apache-test/Apache/TestConfigData.pm to specify
the preferences; this will be used, if it exists, before
a system Apache::TestConfigData. The diff is applied
against the cvs Apache-Test sources; as well, an
empty Apache-Test/lib/Apache/TestConfigData.pm file
should be created:
===
package Apache::TestConfigData;
use strict;
use warnings;
use vars qw($vars);

$vars = {

};
1;

=head1 NAME

Apache::TestConfigData - Configuration file for Apache::Test

=cut

The intent of how this is supposed to work is in the pod
of Apache::TestRun.
===
Index: lib/Apache/TestRun.pm
===
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.114
diff -u -r1.114 TestRun.pm
--- lib/Apache/TestRun.pm   12 Sep 2003 02:21:32 -  1.114
+++ lib/Apache/TestRun.pm   24 Sep 2003 21:52:08 -
@@ -10,20 +10,24 @@
 use Apache::TestRequest ();
 use Apache::TestHarness ();
 use Apache::TestTrace;
+use Apache::TestUtil qw(expand_path);

+use Cwd;
 use File::Find qw(finddepth);
-use File::Spec::Functions qw(catfile);
+use File::Spec::Functions qw(catfile catdir);
 use Getopt::Long qw(GetOptions);
+use File::Basename qw(dirname);
 use Config;

 use constant STARTUP_TIMEOUT = 300; # secs (good for extreme debug cases)
+
 use subs qw(exit_shell exit_perl);

 my %core_files  = ();
 my %original_t_perms = ();

 my @std_run  = qw(start-httpd run-tests stop-httpd);
-my @others   = qw(verbose configure clean help ssl http11);
+my @others   = qw(verbose configure clean help ssl http11 save);
 my @flag_opts= (@std_run, @others);
 my @string_opts  = qw(order trace);
 my @ostring_opts = qw(proxy ping);
@@ -55,9 +59,22 @@
'ssl' = 'run tests through ssl',
'proxy'   = 'proxy requests (default proxy is localhost)',
'trace=T' = 'change tracing default to: warning, notice, info, 
debug, ...',
+   'save'= 'save test paramaters into Apache::TestConfigData',
(map { $_, \U$_\E url } @request_opts),
 );

+# variables stored in $Apache::TestConfigData::vars
+my @data_vars = qw(httpd port user group apxs);
+# mapping from $Apache::TestConfigData::vars to $ENV settings
+my %vars_to_env = (httpd = 'APACHE',
+   user  = 'APACHE_USER',
+   group = 'APACHE_GROUP',
+   apxs  = 'APXS',
+   port  = 'APACHE_PORT',
+   );
+my $IN_APACHE_TEST = in_apache_test();
+my $CONFIG_DATA = config_data();
+
 sub fixup {
 #make sure we use an absolute path to perl
 #else Test::Harness uses the perl in our PATH
@@ -407,6 +424,8 @@
 $test_config-cmodules_configure;
 $test_config-generate_httpd_conf;
 $test_config-save;
+$self-write_config() if
+($IN_APACHE_TEST or $self-{opts}-{save});
 }

 sub try_exit_opts {
@@ -509,6 +528,10 @@

 sub new_test_config {
 my $self = shift;
+for (@data_vars) {
+next unless $Apache::TestConfigData::vars-{$_};
+$self-{conf_opts}-{$_} ||= $Apache::TestConfigData::vars-{$_};
+}
 Apache::TestConfig-new($self-{conf_opts});
 }

@@ -953,6 +976,102 @@
 CORE::exit $_[0];
 }

+# Are we building things within Apache-Test?
+sub in_apache_test {
+my $cwd =  expand_path(cwd);
+return ($cwd =~ m{Apache-Test}) ? 1 : 0;
+}
+
+# routine to determine where the configuration file
+# Apache::TestConfigData lives. The order searched is
+# 1) a path within Apache-Test, if we are building things there
+# 2) an $ENV{HOME}/.apache-test/ directory;
+# 3) somewhere in @INC, other than a path within Apache-Test.
+sub config_data {
+my $config;
+my $file = 'TestConfigData.pm';
+# XXX $ENV{HOME} isn't propagated in mod_perl
+unshift @INC, catdir($ENV{HOME}, '.apache-test') if $ENV{HOME};
+for (@INC) {
+my $candidate = catfile($_, 'Apache', $file);
+if (-e $candidate) {
+eval {require $candidate};
+next if $@;
+if (config_has_data()) {
+$config = $candidate;
+last;
+}
+}
+}
+unless ($IN_APACHE_TEST) {
+die 'Could not find a valid Apache::TestConfigData'
+unless config_has_data();
+}
+shift @INC if $ENV{HOME};
+# preferentially use environment variables
+for (@data_vars) {
+next unless my $value = $ENV{$vars_to_env{$_}};
+$Apache::TestConfigData::vars-{$_} = $value;
+}
+
+return $config;
+}
+
+sub config_has_data {
+return ($Apache::TestConfigData::vars and
+