perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Moyer <f...@redhotpenguin.com>
Subject Re: Fwd: svn commit: r1022689 - in /perl/Apache-Test/trunk: Changes MANIFEST Makefile.PL lib/Apache/TestConfig.pm lib/Apache/TestRun.pm
Date Fri, 15 Oct 2010 16:36:42 GMT
On Thu, Oct 14, 2010 at 2:25 PM, Ryan Gies <ryan@livesite.net> wrote:
> Cannot create make file directly.  (Q: Is this suppose to work?)

Forking this thread despite my other answers.  Can you post 'perldoc
-l Apache2::Build'?

I think your environment may not have Apache2::Build in your @INC.  I
just reviewed the Makefile.PL for Apache::Test and it doesn't look in
the mod_perl src lib, so if you try to build without mod_perl
installed you get that error.  I removed my module and was able to
repeat the error.

phred@pooky ~/dev/svn/modperl/mod_perl-2.0/Apache-Test $ rm
/Users/phred/dev/perl-5.12.2/lib/site_perl/5.12.2/darwin-2level/Apache2/Build.pm
override r--r--r--  phred/phred for
/Users/phred/dev/perl-5.12.2/lib/site_perl/5.12.2/darwin-2level/Apache2/Build.pm?
y

phred@pooky ~/dev/svn/modperl/mod_perl-2.0/Apache-Test $ Can't locate
Apache2/Build.pm in @INC (@INC contains: lib
/Users/phred/dev/perl-5.12.2/lib/site_perl/5.12.2/darwin-2level
/Users/phred/dev/perl-5.12.2/lib/site_perl/5.12.2
/Users/phred/dev/perl-5.12.2/lib/5.12.2/darwin-2level
/Users/phred/dev/perl-5.12.2/lib/5.12.2 .) at lib/Apache/TestConfig.pm
line 34.
BEGIN failed--compilation aborted at lib/Apache/TestConfig.pm line 35.
Compilation failed in require at lib/Apache/TestMM.pm line 22.
BEGIN failed--compilation aborted at lib/Apache/TestMM.pm line 22.
Compilation failed in require at Makefile.PL line 17.
BEGIN failed--compilation aborted at Makefile.PL line 17.

>
> Steps
> -----
>
> svn checkout https://svn.apache.org/repos/asf/perl/modperl/trunk/
> mod_perl-2.0
> cd mod_perl-2.0/Apache-Test/
> perl Makefile.PL
>
> Result
> ------
>
> Can't locate Apache2/Build.pm in @INC (@INC contains: lib /code/src/lib/perl
> /usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi
> /usr/local/lib/perl5/site_perl/5.10.0
> /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl
> /usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/perl5/5.10.0
> /usr/lib/perl5/site_perl .) at lib/Apache/TestConfig.pm line 34.
> BEGIN failed--compilation aborted at lib/Apache/TestConfig.pm line 35.
> Compilation failed in require at lib/Apache/TestMM.pm line 22.
> BEGIN failed--compilation aborted at lib/Apache/TestMM.pm line 22.
> Compilation failed in require at Makefile.PL line 17.
> BEGIN failed--compilation aborted at Makefile.PL line 17.
>
>
>
> On 10/14/2010 04:19 PM, Fred Moyer wrote:
>>
>> FYI - just committed this major revision.  If you have an active
>> Apache::Test trunk checkout, please update and run the tests.
>>
>> The goal here is to make Apache::Test easier to use, and bring the
>> overall quality up to a point where people feel confident using it.
>>
>>
>> ---------- Forwarded message ----------
>> From:<phred@apache.org>
>> Date: Thu, Oct 14, 2010 at 1:17 PM
>> Subject: svn commit: r1022689 - in /perl/Apache-Test/trunk: Changes
>> MANIFEST Makefile.PL lib/Apache/TestConfig.pm lib/Apache/TestRun.pm
>> To: test-commits@perl.apache.org
>>
>>
>> Author: phred
>> Date: Thu Oct 14 20:17:26 2010
>> New Revision: 1022689
>>
>> URL: http://svn.apache.org/viewvc?rev=1022689&view=rev
>> Log:
>> Remove the interactive configuration.
>> Remove the custom configuration option, instead relying on PATH and ENV
>> variables to configure Apache::Test based on runtime settings.
>>
>> Modified:
>>    perl/Apache-Test/trunk/Changes
>>    perl/Apache-Test/trunk/MANIFEST
>>    perl/Apache-Test/trunk/Makefile.PL
>>    perl/Apache-Test/trunk/lib/Apache/TestConfig.pm
>>    perl/Apache-Test/trunk/lib/Apache/TestRun.pm
>>
>> Modified: perl/Apache-Test/trunk/Changes
>> URL:
>> http://svn.apache.org/viewvc/perl/Apache-Test/trunk/Changes?rev=1022689&r1=1022688&r2=1022689&view=diff
>>
>> ==============================================================================
>> --- perl/Apache-Test/trunk/Changes (original)
>> +++ perl/Apache-Test/trunk/Changes Thu Oct 14 20:17:26 2010
>> @@ -8,6 +8,10 @@ Changes - Apache::Test change logfile
>>
>>  =item 1.34-dev
>>
>> +Remove the custom config feature, and instead use inline directives,
>> +ENV vars, and look for apxs et al in PATH.
>> +[Fred Moyer]
>> +
>>  Prevent reconfiguration when t/TEST is called with -run-tests only.
>>  (rev 1004278) [Torsten Foertsch]
>>
>>
>> Modified: perl/Apache-Test/trunk/MANIFEST
>> URL:
>> http://svn.apache.org/viewvc/perl/Apache-Test/trunk/MANIFEST?rev=1022689&r1=1022688&r2=1022689&view=diff
>>
>> ==============================================================================
>> --- perl/Apache-Test/trunk/MANIFEST (original)
>> +++ perl/Apache-Test/trunk/MANIFEST Thu Oct 14 20:17:26 2010
>> @@ -42,15 +42,33 @@ lib/Apache/TestSort.pm
>>  lib/Apache/TestTrace.pm
>>  lib/Apache/TestUtil.pm
>>  lib/Bundle/ApacheTest.pm
>> -t/TEST.PL
>> +t/alltest/01bang.t
>> +t/alltest/all.t
>> +t/alltest2/01bang.t
>> +t/alltest2/all.t
>>  t/bad_coding.t
>> +t/cgi-bin/cookies.pl
>>  t/cgi-bin/cookies.pl.PL
>> +t/cgi-bin/next_available_port.pl
>>  t/cgi-bin/next_available_port.pl.PL
>>  t/conf/extra.conf.in
>> +t/conf/modperl_extra.pl.in
>>  t/cookies.t
>> +t/htdocs/index.html
>> +t/log_watch.t
>> +t/more/01testpm.t
>> +t/more/02testmore.t
>> +t/more/03testpm.t
>> +t/more/04testmore.t
>> +t/more/all.t
>>  t/next_available_port.t
>>  t/ping.t
>>  t/redirect.t
>>  t/request.t
>> +t/response/TestMore/testmorepm.pm
>> +t/response/TestMore/testpm.pm
>> +t/TEST.PL
>> +
>>
>>  META.yml                                 Module meta-data (added by
>> MakeMaker)
>> +
>>
>> Modified: perl/Apache-Test/trunk/Makefile.PL
>> URL:
>> http://svn.apache.org/viewvc/perl/Apache-Test/trunk/Makefile.PL?rev=1022689&r1=1022688&r2=1022689&view=diff
>>
>> ==============================================================================
>> --- perl/Apache-Test/trunk/Makefile.PL (original)
>> +++ perl/Apache-Test/trunk/Makefile.PL Thu Oct 14 20:17:26 2010
>> @@ -19,6 +19,7 @@ use Apache::TestRun;
>>  use Apache::TestTrace;
>>  use Apache::TestReport;
>>  use Apache::TestConfig ();
>> +use Apache::TestRunPerl;
>>
>>  my $VERSION;
>>  set_version();
>> @@ -35,6 +36,17 @@ finddepth(sub {
>>     push @scripts, "$File::Find::dir/$1";
>>  }, '.');
>>
>> +my $has_mp;
>> +eval { require mod_perl2 };
>> +if ($@) {
>> +    eval { require mod_perl };
>> +    if (!$@) {
>> +        $has_mp = 1;
>> +    }
>> +} else {
>> +    $has_mp = 2;
>> +}
>> +
>>  for (@scripts) {
>>     Apache::TestMM::generate_script($_);
>>  }
>> @@ -47,12 +59,10 @@ if (TOP_LEVEL) {
>>     add_Apache__test_target();
>>  }
>>
>> -Apache::TestConfig::custom_config_file_stub_write();
>> -
>>  my @clean_files =
>> -    qw(lib/Apache/TestConfigData.pm
>> -       .mypacklist
>> +    qw(.mypacklist
>>        t/TEST
>> +       t/REPORT
>>        Makefile.old
>>       );
>>
>>
>> Modified: perl/Apache-Test/trunk/lib/Apache/TestConfig.pm
>> URL:
>> http://svn.apache.org/viewvc/perl/Apache-Test/trunk/lib/Apache/TestConfig.pm?rev=1022689&r1=1022688&r2=1022689&view=diff
>>
>> ==============================================================================
>> --- perl/Apache-Test/trunk/lib/Apache/TestConfig.pm (original)
>> +++ perl/Apache-Test/trunk/lib/Apache/TestConfig.pm Thu Oct 14 20:17:26
>> 2010
>> @@ -38,8 +38,6 @@ use constant IS_APACHE_TEST_BUILD =>
>>     grep { -e "$_/lib/Apache/TestConfig.pm" }
>>          qw(Apache-Test . .. ../Apache-Test);
>>
>> -use constant CUSTOM_CONFIG_FILE =>  'Apache/TestConfigData.pm';
>> -
>>  use lib ();
>>  use File::Copy ();
>>  use File::Find qw(finddepth);
>> @@ -59,18 +57,6 @@ use Apache::TestRun ();
>>
>>  use vars qw(%Usage);
>>
>> -# variables stored in $Apache::TestConfigData::vars
>> -my @data_vars_must = qw(httpd apxs);
>> -my @data_vars_opt  = qw(user group port);
>> -# mapping from $Apache::TestConfigData::vars to $ENV settings
>> -my %vars_to_env = (
>> -    httpd =>  'APACHE_TEST_HTTPD',
>> -    apxs  =>  'APACHE_TEST_APXS',
>> -    user  =>  'APACHE_TEST_USER',
>> -    group =>  'APACHE_TEST_GROUP',
>> -    port  =>  'APACHE_TEST_PORT',
>> -);
>> -
>>  %Usage = (
>>    top_dir         =>  'top-level directory (default is $PWD)',
>>    t_dir           =>  'the t/ test directory (default is $top_dir/t)',
>> @@ -181,10 +167,6 @@ sub modperl_build_config {
>>
>>     my $server = ref $self ? $self->server : new_test_server();
>>
>> -    # we don't want to get mp2 preconfigured data in order to be able
>> -    # to get the interactive tests running.
>> -    return undef if $ENV{APACHE_TEST_INTERACTIVE_CONFIG_TEST};
>> -
>>     # we can't do this if we're using httpd 1.3.X
>>     # even if mod_perl2 is installed on the box
>>     # similarly, we shouldn't be loading mp2 if we're not
>> @@ -195,6 +177,7 @@ sub modperl_build_config {
>>         eval {
>>             require Apache2::Build;
>>         } or return;
>> +
>>         return Apache2::Build->build_config;
>>     }
>>
>> @@ -264,10 +247,6 @@ sub new {
>>         }
>>     }
>>
>> -    # custom config options from Apache::TestConfigData
>> -    # again, this should force reconfiguration
>> -    custom_config_add_conf_opts($args);
>> -
>>     my $self = bless {
>>         clean =>  {},
>>         vhosts =>  {},
>> @@ -298,12 +277,13 @@ sub new {
>>     #help to find libmodperl.so
>>     unless ($vars->{src_dir}) {
>>         my $src_dir = catfile $vars->{top_dir}, qw(.. src modules perl);
>> -       if (-d $src_dir) {
>> -           $vars->{src_dir} = $src_dir;
>> -       } else {
>> -           $src_dir = catfile $vars->{top_dir}, qw(src modules perl);
>> -           $vars->{src_dir} = $src_dir if -d $src_dir;
>> -       }
>> +
>> +        if (-d $src_dir) {
>> +               $vars->{src_dir} = $src_dir;
>> +       } else {
>> +               $src_dir = catfile $vars->{top_dir}, qw(src modules perl);
>> +               $vars->{src_dir} = $src_dir if -d $src_dir;
>> +       }
>>     }
>>
>>     $vars->{t_dir}        ||= catfile $vars->{top_dir}, 't';
>> @@ -399,29 +379,18 @@ sub httpd_config {
>>                 "bug report";
>>         }
>>
>> -        if ($ENV{APACHE_TEST_NO_STICKY_PREFERENCES}) {
>> -            error "You specified APACHE_TEST_NO_STICKY_PREFERENCES=1 " .
>> -                "in which case you must explicitly specify -httpd " .
>> -                "and/or -apxs options";
>> -            Apache::TestRun::exit_perl(0);
>> -        }
>> -
>>         $self->clean(1);
>> -        # this method restarts the whole program via exec
>> -        # so it never returns
>> -        $self->custom_config_first_time($self->{vars});
>> +
>> +        error "You must explicitly specify -httpd and/or -apxs options, "
>> .
>> +            "or set \$ENV{APACHE_TEST_HTTPD} and \$ENV{APACHE_TEST_APXS},
>> " .
>> +            "or set your \$PATH to include the httpd and apxs binaries.";
>> +        Apache::TestRun::exit_perl(1);
>> +
>>     }
>>     else {
>>         debug "Using httpd: $vars->{httpd}";
>>     }
>>
>> -    # if we have gotten that far we know at least about the location
>> -    # of httpd and or apxs, so let's save it if we haven't saved any
>> -    # custom configs yet
>> -    unless (custom_config_exists()) {
>> -        $self->custom_config_save($self->{vars});
>> -    }
>> -
>>     $self->inherit_config; #see TestConfigParse.pm
>>     $self->configure_httpd_eapi; #must come after inherit_config
>>
>> @@ -434,7 +403,7 @@ sub httpd_config {
>>
>>     $self->{server}->post_config;
>>
>> -    $self;
>> +    return $self;
>>  }
>>
>>  sub default_module {
>> @@ -694,7 +663,7 @@ sub default_user {
>>         }
>>     }
>>
>> -    $user;
>> +    return $user;
>>  }
>>
>>  sub default_serveradmin {
>> @@ -711,7 +680,18 @@ sub default_apxs {
>>         return $build_config->{MP_APXS};
>>     }
>>
>> -    $ENV{APACHE_TEST_APXS};
>> +    if ($ENV{APACHE_TEST_APXS}) {
>> +        return $ENV{APACHE_TEST_APXS};
>> +    }
>> +
>> +    # look in PATH as a last resort
>> +    if (my $apxs = which('apxs')) {
>> +        return $apxs;
>> +    } elsif ($apxs = which('apxs2')) {
>> +        return $apxs;
>> +    }
>> +
>> +    return;
>>  }
>>
>>  sub default_httpd {
>> @@ -737,7 +717,22 @@ sub default_httpd {
>>         }
>>     }
>>
>> -    $ENV{APACHE_TEST_HTTPD};
>> +    if ($ENV{APACHE_TEST_HTTPD}) {
>> +        return $ENV{APACHE_TEST_HTTPD};
>> +    }
>> +
>> +    # look in PATH as a last resort
>> +    if (my $httpd = which('httpd')) {
>> +        return $httpd;
>> +    } elsif ($httpd = which('httpd2')) {
>> +        return $httpd;
>> +    } elsif ($httpd = which('apache')) {
>> +        return $httpd;
>> +    } elsif ($httpd = which('apache2')) {
>> +        return $httpd;
>> +    }
>> +
>> +    return;
>>  }
>>
>>  my $localhost;
>> @@ -1952,520 +1947,6 @@ sub shell_ready {
>>     return qq["$arg"];
>>  }
>>
>> -### Permanent custom configuration functions ###
>> -
>> -# determine which configuration file Apache/TestConfigData.pm to use
>> -# (as there could be several). The order searched is:
>> -# 1) $ENV{HOME}/.apache-test/
>> -# 2) in @INC
>> -my $custom_config_path;
>> -sub custom_config_path {
>> -
>> -    return $custom_config_path if $custom_config_path;
>> -
>> -    my @inc  = ();
>> -
>> -    # XXX $ENV{HOME} isn't propagated in mod_perl
>> -    push @inc, catdir $ENV{HOME}, '.apache-test' if $ENV{HOME};
>> -
>> -    push @inc, @INC;
>> -
>> -    for (@inc) {
>> -        my $candidate = File::Spec->rel2abs(catfile $_,
>> CUSTOM_CONFIG_FILE);
>> -        next unless -e $candidate;
>> -        # launder for -T
>> -        ($candidate) = $candidate =~ /^(.*)/;
>> -        return $custom_config_path = $candidate;
>> -    }
>> -
>> -    return '';
>> -}
>> -
>> -# tries to nuke all occurences of custom config
>> -# used by things outside the A-T test suite
>> -sub custom_config_nuke {
>> -    my $cwd = fastcwd();
>> -
>> -    # 1) create a fake empty (blib/)?lib/Apache/TestConfigData.pm
>> -    # (don't delete it since it may mess up with MakeMaker)
>> -    my $path = catfile $cwd, "lib",
>> Apache::TestConfig::CUSTOM_CONFIG_FILE;
>> -    # overwrite the empty stub
>> -    Apache::TestConfig::custom_config_write($path, '') if -e $path;
>> -
>> -    $path = catfile $cwd, "blib", "lib",
>> -        Apache::TestConfig::CUSTOM_CONFIG_FILE;
>> -    if (-e $path) {
>> -        my $mode = (stat _)[2];
>> -        my $mode_new = $mode | 0200;
>> -        chmod $mode_new, $path;
>> -        debug  "emptying $path";
>> -        Apache::TestConfig::custom_config_write($path, '');
>> -        chmod $mode, $path;
>> -    }
>> -
>> -    # 2) go through @INC = ~/.apache-test and nuke any occurences of
>> -    #    CUSTOM_CONFIG_FILE
>> -    my @inc  = ();
>> -
>> -    push @inc, catdir $ENV{HOME}, '.apache-test' if $ENV{HOME};
>> -
>> -    push @inc, @INC;
>> -
>> -    for (@inc) {
>> -        my $victim = File::Spec->rel2abs(catfile $_, CUSTOM_CONFIG_FILE);
>> -        next unless -e $victim;
>> -        debug "unlinking $victim";
>> -        unlink $victim;
>> -    }
>> -}
>> -
>> -sub custom_config_exists {
>> -    # try to load custom config if it wasn't loaded yet (there are
>> -    # many entry points to this API)
>> -    custom_config_load();
>> -
>> -    # it's enough to check whether we have a custom
>> -    # config for 'httpd' or 'apxs'.
>> -    my $httpd = $Apache::TestConfigData::vars->{httpd} || '';
>> -    return 1 if $httpd&&  -e $httpd&&  -x _;
>> -
>> -    my $apxs = $Apache::TestConfigData::vars->{apxs} || '';
>> -    return 1 if $apxs&&  -e $apxs&&  -x _;
>> -
>> -    return 0;
>> -}
>> -
>> -# to be used only from Apache-Test/Makefile.PL to write the custom
>> -# configuration module so it'll be copied to blib during 'make' and
>> -# updated to use custom config data during 'make test' and then
>> -# installed system-wide via 'make install'
>> -#
>> -# it gets written only if the custom configuration didn't exist
>> -# already
>> -sub custom_config_file_stub_write {
>> -
>> -    return if custom_config_exists();
>> -
>> -    # 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. but
>> -    # remember that $FindBin::Bin is the location of top-level
>> -    # 'Makefile.PL'
>> -    require FindBin; # load it only for this particular use
>> -    my $path = catfile $FindBin::Bin, "lib",
>> -        Apache::TestConfig::CUSTOM_CONFIG_FILE;
>> -
>> -    # write an empty stub
>> -    Apache::TestConfig::custom_config_write($path, '');
>> -}
>> -
>> -sub custom_config_save {
>> -    my $self = shift;
>> -    my $conf_opts = shift;
>> -
>> -    if ($ENV{APACHE_TEST_NO_STICKY_PREFERENCES}) {
>> -        debug "APACHE_TEST_NO_STICKY_PREFERENCES=1 =>  " .
>> -            "skipping save of custom config data";
>> -        return;
>> -    }
>> -
>> -    my $vars = $self->{vars};
>> -    my $config_dump = '';
>> -
>> -    # minimum httpd and/or apxs needs to be set
>> -    return 0 unless $vars->{httpd} or
>> $Apache::TestConfigData::vars->{httpd}
>> -        or          $vars->{apxs}  or
>> $Apache::TestConfigData::vars->{apxs};
>> -
>> -    # it doesn't matter how these vars were set (httpd may or may not
>> -    # get set using the path to apxs, w/o an explicit -httpd value)
>> -    for (@data_vars_must) {
>> -        next unless my $var = $vars->{$_} || $conf_opts->{$_};
>> -        $config_dump .= qq{    '$_' =>  '$var',\n};
>> -    }
>> -
>> -    # save these vars only if they were explicitly set via command line
>> -    # options. For example if someone builds A-T as user 'foo', then
>> -    # installs it as root and we save it, all users will now try to
>> -    # configure under that user 'foo' which won't quite work.
>> -    for (@data_vars_opt) {
>> -        next unless my $var = $conf_opts->{$_};
>> -        $config_dump .= qq{    '$_' =>  '$var',\n};
>> -    }
>> -
>> -    if (IS_APACHE_TEST_BUILD) {
>> -        my $path = catfile $vars->{top_dir}, 'lib', CUSTOM_CONFIG_FILE;
>> -        # if it doesn't exist, then we already have a global config file
>> -        # if it does, then we have need to update it and its blib/ copy
>> -        if (-e $path and custom_config_path_is_writable($path)) {
>> -            custom_config_write($path, $config_dump);
>> -            # also update blib/lib, since usually that's the one that
>> -            # appears in @INC when t/TEST is run. and it won't be
>> -            # synced with blib/ unless 'make' was run
>> -            my $blib_path = catfile $vars->{top_dir},
>> -                'blib', 'lib', CUSTOM_CONFIG_FILE;
>> -            if (-e $blib_path and
>> custom_config_path_is_writable($blib_path)) {
>> -                custom_config_write($blib_path, $config_dump);
>> -            }
>> -            return 1;
>> -        }
>> -    }
>> -
>> -    my $path;
>> -    if ($path = custom_config_path() ) {
>> -        # do nothing, the config file already exists (global)
>> -        debug "Found custom config '$path'";
>> -    }
>> -    elsif (File::Spec->file_name_is_absolute(__FILE__)) {
>> -        # next try a global location, as if it was configured before
>> -        # Apache::Test's 'make install' (install in the same dir as
>> -        # Apache/TestRun.pm)
>> -        # if the filename is not absolute that means that we are still
>> -        # in Apache-Test build (could just test for IS_APACHE_TEST_BUILD)
>> -        my $base = dirname dirname __FILE__;
>> -        $path = catdir $base, CUSTOM_CONFIG_FILE;
>> -    }
>> -
>> -    # check whether we can write to the directory of the chosen path
>> -    # (e.g. root-owned directory)
>> -    if ($path and custom_config_path_is_writable($path)) {
>> -        custom_config_write($path, $config_dump);
>> -        return 1;
>> -    }
>> -    # if we have no writable path yet, try to use ~
>> -    elsif ($ENV{HOME}) {
>> -        $path = catfile $ENV{HOME}, '.apache-test', CUSTOM_CONFIG_FILE;
>> -        if ($path and custom_config_path_is_writable($path)) {
>> -            custom_config_write($path, $config_dump);
>> -            return 1;
>> -        }
>> -    }
>> -
>> -    # XXX: should we croak since we failed to write config
>> -    error "Failed to find a config file to save the custom " .
>> -        "configuration in";
>> -    return 0;
>> -}
>> -
>> -sub custom_config_path_is_writable {
>> -    my $path = shift;
>> -
>> -    return 0 unless $path;
>> -
>> -    my $file_created    = '';
>> -    my $top_dir_created = '';
>> -    # first make sure that the file is writable if it exists
>> -    # already (it might be non-writable if installed via EU::MM or in
>> -    # blib/)
>> -    if (-e $path) {
>> -        my $mode = (stat _)[2];
>> -        $mode |= 0200;
>> -        chmod $mode, $path; # it's ok if we fail
>> -        # keep it writable if we have changed it from not being one
>> -        # so that custom_config_save will be able to just overwrite it
>> -    }
>> -    else {
>> -        my $dir = dirname $path;
>> -        if ($dir and !-e $dir) {
>> -            my @dirs = File::Path::mkpath($dir, 0, 0755);
>> -            # the top level dir to nuke on cleanup if it was created
>> -            $top_dir_created = shift @dirs if @dirs;
>> -        }
>> -        # not really create yet, but will be in the moment
>> -        $file_created = 1;
>> -    }
>> -
>> -    # try to open for append (even though it may not exist
>> -    my $fh = Symbol::gensym;
>> -    if (open $fh, ">>$path") {
>> -        close $fh;
>> -        # cleanup if we just created the file
>> -        unlink $path if $file_created;
>> -        File::Path::rmtree([$top_dir_created], 0, 0) if $top_dir_created;
>> -        return 1;
>> -    }
>> -
>> -    return 0;
>> -}
>> -
>> -sub custom_config_write {
>> -    my($path, $config_dump) = @_;
>> -
>> -    my $pkg =<<  "EOC";
>> -package Apache::TestConfigData;
>> -
>> -use strict;
>> -use warnings;
>> -
>> -\$Apache::TestConfigData::vars = {
>> -$config_dump
>> -};
>> -
>> -1;
>> -
>> -=head1 NAME
>> -
>> -Apache::TestConfigData - Configuration file for Apache::Test
>> -
>> -=cut
>> -EOC
>> -
>> -    debug "Writing custom config $path";
>> -    my $dir = dirname $path;
>> -    File::Path::mkpath($dir, 0, 0755) unless -e $dir;
>> -    my $fh = Symbol::gensym;
>> -    open $fh, ">$path" or die "Cannot open $path: $!";
>> -    print $fh $pkg;
>> -    close $fh;
>> -}
>> -
>> -sub custom_config_add_conf_opts {
>> -    my $args = shift;
>> -
>> -    return unless $Apache::TestConfigData::vars and
>> -        keys %$Apache::TestConfigData::vars;
>> -
>> -    debug "overlaying custom config data";
>> -
>> -    # the logic is quite complicated with 'httpd' and 'apxs', since
>> -    # one is enough to run the test suite, and we need to avoid the
>> -    # situation where both are saved in custom config but only one
>> -    # (let's say httpd) is overriden by the command line /env var and
>> -    # a hell may break loose if we take that overriden httpd value and
>> -    # also use apxs from custom config which could point to a different
>> -    # server. So if there is an override of apxs or httpd, do not use
>> -    # the custom config for apxs or httpd.
>> -    my $vars_must_overriden = grep {
>> -        $ENV{ $vars_to_env{$_} } || $args->{$_}
>> -    } @data_vars_must;
>> -
>> -    # mod_perl 2.0 build always knows the right httpd location (and
>> -    # optionally apxs)
>> -    $vars_must_overriden++ if IS_MOD_PERL_2_BUILD();
>> -
>> -    unless ($vars_must_overriden) {
>> -        for (@data_vars_must) {
>> -            next unless $Apache::TestConfigData::vars->{$_};
>> -            $args->{$_} = $Apache::TestConfigData::vars->{$_};
>> -        }
>> -    }
>> -
>> -    for (@data_vars_opt) {
>> -        next unless $Apache::TestConfigData::vars->{$_};
>> -        # env vars override custom config
>> -        my $env_value = $ENV{ $vars_to_env{$_} };
>> -        next unless defined $env_value and length $env_value;
>> -        $args->{$_} ||= $Apache::TestConfigData::vars->{$_};
>> -    }
>> -}
>> -
>> -my $custom_config_loaded = 0;
>> -sub custom_config_load {
>> -
>> -    if ($ENV{APACHE_TEST_NO_STICKY_PREFERENCES}) {
>> -        debug "APACHE_TEST_NO_STICKY_PREFERENCES=1 =>  " .
>> -            "skipping load of custom config data";
>> -        return;
>> -    }
>> -
>> -    if ($ENV{APACHE_TEST_INTERACTIVE_CONFIG_TEST}) {
>> -        debug "APACHE_TEST_INTERACTIVE_CONFIG_TEST=1 =>  " .
>> -            "skipping load of custom config data";
>> -        return;
>> -    }
>> -
>> -    return if $custom_config_loaded;
>> -
>> -    if (my $custom_config_path = custom_config_path()) {
>> -        debug "loading custom config data from: '$custom_config_path'";
>> -        $custom_config_loaded++;
>> -        require $custom_config_path;
>> -    }
>> -    else {
>> -        debug "no custom config data was loaded";
>> -    }
>> -}
>> -
>> -sub custom_config_first_time {
>> -    my $self = shift;
>> -    my $conf_opts = shift;
>> -
>> -    # we can't prompt when STDIN is not attached to tty, unless we
>> -    # were told that's it OK via env var (in which case some program
>> -    # will feed the interactive prompts
>> -    unless (-t STDIN || $ENV{APACHE_TEST_INTERACTIVE_PROMPT_OK}) {
>> -        error "STDIN is not attached to tty, skip interactive config";
>> -        Apache::TestRun::skip_test_suite();
>> -    }
>> -
>> -    my $vars = $self->{vars};
>> -
>> -    print qq[
>> -
>> -We are now going to configure the Apache-Test framework.
>> -This configuration process needs to be done only once.
>> -
>> -];
>> -
>> -    print qq[
>> -
>> -First we need to know where the 'httpd' executable is located.
>> -If you have more than one Apache server is installed, make sure
>> -you supply the path to the one you are going to use for testing.
>> -You can always override this setting at run time via the '-httpd'
>> -option. For example:
>> -
>> -  % t/TEST -httpd /path/to/alternative/httpd
>> -
>> -or via the environment variable APACHE_TEST_HTTPD. For example:
>> -
>> -  % APACHE_TEST_HTTPD=/path/to/alternative/httpd t/TEST
>> -
>> -If for some reason you want to skip the test suite, type: skip
>> -];
>> -
>> -    {
>> -        my %choices = ();
>> -        my @tries = qw(httpd httpd2);
>> -        # Win32 uses Apache not apache
>> -        push @tries, WIN32 ? qw(Apache) : qw(apache);
>> -        for (grep defined $_,
>> -             map({ catfile $vars->{$_}, $vars->{target} } qw(sbindir
>> bindir)),
>> -             $self->default_httpd, which($vars->{target}),
>> -             $ENV{APACHE}, $ENV{APACHE2},
>> -             $ENV{APACHE_TEST_HTTPD}, $ENV{APACHE_TEST_HTTPD2},
>> -             map {which($_)} @tries) {
>> -            $choices{$_}++ if -e $_&&  -x _;
>> -        }
>> -        my $optional = 0;
>> -        my $wanted = 'httpd';
>> -        $vars->{$wanted} =
>> -            _custom_config_prompt_path($wanted, \%choices, $optional);
>> -    }
>> -
>> -    print qq[
>> -
>> -Next we need to know where the 'apxs' script is located. This script
>> -provides a lot of information about the apache installation, and makes
>> -it easier to find things. However it's not available on all platforms,
>> -therefore it's optional.
>> -
>> -If you don't have it installed it's not a problem. Just press Enter.
>> -
>> -Notice that if you have Apache 2.x installed that script could be
>> -called as 'apxs2'.
>> -
>> -If you have more than one Apache server is installed, make sure you
>> -supply the path to the apxs script you are going to use for testing.
>> -You can always override this setting at run time via the '-apxs'
>> -option. For example:
>> -
>> -  % t/TEST -apxs /path/to/alternative/apxs
>> -
>> -or via the environment variable APACHE_TEST_APXS. For example:
>> -
>> -  % APACHE_TEST_APXS=/path/to/alternative/apxs t/TEST
>> -
>> -];
>> -    {
>> -        my %choices = ();
>> -        for (grep defined $_,
>> -             map({ catfile $vars->{$_}, 'apxs' } qw(sbindir bindir)),
>> -             $self->default_apxs,
>> -             $ENV{APXS},  $ENV{APACHE_TEST_APXS},  which('apxs'),
>> -             $ENV{APXS2}, $ENV{APACHE_TEST_APXS2}, which('apxs2')) {
>> -            $choices{$_}++ if -e $_&&  -x _;
>> -        }
>> -        my $optional = 1;
>> -        my $wanted = 'apxs';
>> -        $vars->{$wanted} =
>> -            _custom_config_prompt_path($wanted, \%choices, $optional);
>> -    }
>> -
>> -    $self->custom_config_save($conf_opts);
>> -
>> -    # we probably could reconfigure on the fly ($self->configure), but
>> -    # the problem is various cached data which won't be refreshed. so
>> -    # the simplest is just to restart the run from scratch
>> -    Apache::TestRun::rerun($vars);
>> -}
>> -
>> -sub _custom_config_prompt_path {
>> -    my($wanted, $rh_choices, $optional) = @_;
>> -
>> -    my $ans;
>> -    my $default = '';
>> -    my $optional_str = $optional ? " (optional)" : '';
>> -    my $prompt =
>> -        "\nPlease provide a full path to$optional_str '$wanted'
>> executable";
>> -
>> -    my @choices = ();
>> -    if (%$rh_choices) {
>> -        $prompt .= " or choose from the following options:\n\n";
>> -        my $c = 0;
>> -        for (sort keys %$rh_choices) {
>> -            $c++;
>> -            $prompt .= "    [$c] $_\n";
>> -            push @choices, $_;
>> -        }
>> -        $prompt .= " \n";
>> -        $default = 1; # a wild guess
>> -    }
>> -    else {
>> -        $prompt .= ":\n\n";
>> -    }
>> -
>> -    my $i = 0;
>> -    while (1) {
>> -
>> -        # prevent infinite loops in smoke tests, only give the user
>> -        # five chances to specify httpd or apxs before giving up
>> -        if ($i++ == 5) {
>> -
>> -            Apache::TestRun::skip_test_suite('y');
>> -            return;
>> -        }
>> -
>> -        $ans = ExtUtils::MakeMaker::prompt($prompt, $default);
>> -
>> -        # strip leading/closing spaces
>> -        $ans =~ s/^\s*|\s*$//g;
>> -
>> -        # convert the item number to the path
>> -        if ($ans =~ /^(\d+)$/) {
>> -            if ($1>  0 and $choices[$1-1]) {
>> -                $ans = $choices[$1-1];
>> -            }
>> -            else {
>> -                warn "The choice '$ans' doesn't exist\n";
>> -                next;
>> -            }
>> -        }
>> -
>> -        if ($optional) {
>> -            return '' unless $ans;
>> -        }
>> -
>> -        # stop the test suite without an error (so automatic tools
>> -        # like CPAN.pm will be able to continue)
>> -        if (lc($ans) eq 'skip'&&  !$optional) {
>> -            Apache::TestRun::skip_test_suite();
>> -            next; # in case they change their mind
>> -        }
>> -
>> -        unless (File::Spec->file_name_is_absolute($ans)) {
>> -            warn "The path '$ans' is not an absolute path. " .
>> -                "Please specify an absolute path\n";
>> -            next;
>> -        }
>> -
>> -        warn("'$ans' doesn't exist.\n"),     next unless -e $ans;
>> -        warn("'$ans' is not a file.\n"),     next unless -f _;
>> -        warn("'$ans' is not executable.\n"), next unless -x _;
>> -
>> -        return $ans;
>> -    }
>> -}
>>
>>  1;
>>
>> @@ -2605,13 +2086,6 @@ configuration phase (C<t/TEST -config>,
>>  automatically unshift the I<project/lib>  directory into C<@INC>, via
>>  the autogenerated I<t/conf/modperl_inc.pl>  file.
>>
>> -=head2 APACHE_TEST_INTERACTIVE_PROMPT_OK
>> -
>> -Normally interactive prompts aren't run when STDIN is not attached to
>> -a tty. But sometimes there is a program that can answer the prompts
>> -(e.g. when testing A-T itself). If this variable is true the
>> -interactive config won't be skipped (if needed).
>> -
>>
>>  =head1 Special Placeholders
>>
>>
>> Modified: perl/Apache-Test/trunk/lib/Apache/TestRun.pm
>> URL:
>> http://svn.apache.org/viewvc/perl/Apache-Test/trunk/lib/Apache/TestRun.pm?rev=1022689&r1=1022688&r2=1022689&view=diff
>>
>> ==============================================================================
>> --- perl/Apache-Test/trunk/lib/Apache/TestRun.pm (original)
>> +++ perl/Apache-Test/trunk/lib/Apache/TestRun.pm Thu Oct 14 20:17:26 2010
>> @@ -89,7 +89,6 @@ my %usage = (
>>    'proxy'           =>  'proxy requests (default proxy is localhost)',
>>    'trace=T'         =>  'change tracing default to: warning, notice, ' .
>>                         'info, debug, ...',
>> -   'save'            =>  'save test paramaters into
>> Apache::TestConfigData',
>>    'one-process'     =>  'run the server in single process mode',
>>    (map { $_, "\U$_\E url" } @request_opts),
>>  );
>> @@ -506,13 +505,6 @@ sub configure {
>>     $test_config->generate_httpd_conf;
>>     $test_config->save;
>>
>> -    # custom config save if
>> -    # 1) requested to save
>> -    # 2) no saved config yet
>> -    if ($self->{opts}->{save} or
>> -        !Apache::TestConfig::custom_config_exists()) {
>> -        $test_config->custom_config_save($self->{conf_opts});
>> -    }
>>  }
>>
>>  sub try_exit_opts {
>> @@ -685,9 +677,6 @@ sub run {
>>
>>     $self->getopts(\@argv);
>>
>> -    # must be called after getopts so the tracing will be set right
>> -    Apache::TestConfig::custom_config_load();
>> -
>>     $self->pre_configure();
>>
>>     # can't setup the httpd-specific parts of the config object yet
>> @@ -1146,44 +1135,6 @@ sub exit_shell {
>>     CORE::exit $_[0];
>>  }
>>
>> -# successfully abort the test suite execution (to allow automatic
>> -# tools like CPAN.pm, to continue with installation).
>> -#
>> -# if a true value is passed, quit right away
>> -# otherwise ask the user, if they may want to change their mind which
>> -# will return them back to where they left
>> -sub skip_test_suite {
>> -    my $no_doubt = shift;
>> -
>> -    # we can't prompt when STDIN is not attached to tty, unless we
>> -    # were told that's it OK via env var (in which case some program
>> -    # will feed the interactive prompts).  Also skip the prompt if the
>> -    # automated testing environment variable is set.
>> -    unless (-t STDIN || $ENV{APACHE_TEST_INTERACTIVE_PROMPT_OK}
>> -                     || !$ENV{AUTOMATED_TESTING} ) {
>> -        $no_doubt = 1;
>> -    }
>> -
>> -    print qq[
>> -
>> -Running the test suite is important to make sure that the module that
>> -you are about to install works on your system. If you choose not to
>> -run the test suite and you have a problem using this module, make sure
>> -to return and run this test suite before reporting any problems to the
>> -developers of this module.
>> -
>> -];
>> -    unless ($no_doubt) {
>> -        my $default = 'No';
>> -        my $prompt = 'Skip the test suite?';
>> -        my $ans = ExtUtils::MakeMaker::prompt($prompt, $default);
>> -        return if lc($ans) =~ /no/;
>> -    }
>> -
>> -    error "Skipping the test suite execution, while returning success
>> status";
>> -    exit_perl 1;
>> -}
>> -
>>  1;
>>
>>  __END__
>> @@ -1270,153 +1221,4 @@ Don't forget to run the super class' c<p
>>
>>  META: to be completed
>>
>> -
>> -
>> -=head1 Persistent Custom Configuration
>> -
>> -When C<Apache::Test>  is first installed or used, it will save the
>> -values of C<httpd>, C<apxs>, C<port>, C<user>, and C<group>, if set,
>> -to a configuration file C<Apache::TestConfigData>.  This information
>> -will then be used in setting these options for subsequent uses of
>> -C<Apache-Test>  unless temprorarily overridden, either by setting the
>> -appropriate environment variable (C<APACHE_TEST_HTTPD>,
>> -C<APACHE_TEST_APXS>, C<APACHE_TEST_PORT>, C<APACHE_TEST_USER>, and
>> -C<APACHE_TEST_GROUP>) or by giving the relevant option (C<-httpd>,
>> -C<-apxs>, C<-port>, C<-user>, and C<-group>) when the C<TEST>  script
>> -is run.
>> -
>> -To avoid either using previous persistent configurations or saving
>> -current configurations, set the C<APACHE_TEST_NO_STICKY_PREFERENCES>
>> -environment variable to a true value.
>> -
>> -Finally it's possible to permanently override the previously saved
>> -options by passing C<L<-save|/Saving_Custom_Configuration_Options>>.
>> -
>> -Here is the algorithm of how and when options are saved for the first
>> -time and when they are used. We will use a few variables to simplify
>> -the pseudo-code/pseudo-chart flow:
>> -
>> -C<$config_exists>  - custom configuration has already been saved, to
>> -get this setting run C<custom_config_exists()>, which tests whether
>> -either C<apxs>  or C<httpd>  values are set. It doesn't check for other
>> -values, since all we need is C<apxs>  or C<httpd>  to get the test suite
>> -running. custom_config_exists() checks in the following order
>> -F<lib/Apache/TestConfigData.pm>  (if during Apache-Test build) ,
>> -F<~/.apache-test/Apache/TestConfigData.pm>  and
>> -F<Apache/TestConfigData.pm>  in the perl's libraries.
>> -
>> -C<$config_overriden>  - that means that we have either C<apxs>  or
>> -C<httpd>  values provided by user, via env vars or command line options.
>> -
>> -=over
>> -
>> -=item 1 Building Apache-Test or modperl-2.0 (or any other project that
>> -bundles Apache-Test).
>> -
>> -  1) perl Apache-Test/Makefile.PL
>> -  (for bundles top-level Makefile.PL will run this as well)
>> -
>> -  if $config_exists
>> -      do nothing
>> -  else
>> -      create lib/Apache/TestConfigData.pm w/ empty config: {}
>> -
>> -  2) make
>> -
>> -  3) make test
>> -
>> -  if $config_exists
>> -      if $config_overriden
>> -          override saved options (for those that were overriden)
>> -      else
>> -          use saved options
>> -  else
>> -      if $config_overriden
>> -          save them in lib/Apache/TestConfigData.pm
>> -          (which will be installed on 'make install')
>> -      else
>> -          - run interactive prompt for C<httpd>  and optionally for
>> C<apxs>
>> -          - save the custom config in lib/Apache/TestConfigData.pm
>> -          - restart the currently run program
>> -
>> -  modperl-2.0 is a special case in (3). it always overrides 'httpd'
>> -  and 'apxs' settings. Other settings like 'port', can be used from
>> -  the saved config.
>> -
>> -  4) make install
>> -
>> -     if $config_exists only in lib/Apache/TestConfigData.pm
>> -        it will be installed system-wide
>> -     else
>> -        nothing changes (since lib/Apache/TestConfigData.pm won't exist)
>> -
>> -=item 2 Testing 3rd party modules (after Apache-Test was installed)
>> -
>> -Notice that the following situation is quite possible:
>> -
>> -  cd Apache-Test
>> -  perl Makefile.PL&&  make install
>> -
>> -so that Apache-Test was installed but no custom configuration saved
>> -(since its C<make test>  wasn't run). In which case the interactive
>> -configuration should kick in (unless config options were passed) and
>> -in any case saved once configured.
>> -
>> -C<$custom_config_path>  - perl's F<Apache/TestConfigData.pm>  (at the
>> -same location as F<Apache/TestConfig.pm>) if that area is writable by
>> -that user (e.g. perl's lib is not owned by 'root'). If not, in
>> -F<~/.apache-test/Apache/TestConfigData.pm>.
>> -
>> -  1) perl Apache-Test/Makefile.PL
>> -  2) make
>> -  3) make test
>> -
>> -  if $config_exists
>> -      if $config_overriden
>> -          override saved options (for those that were overriden)
>> -      else
>> -          use saved options
>> -  else
>> -      if $config_overriden
>> -          save them in $custom_config_path
>> -      else
>> -          - run interactive prompt for C<httpd>  and optionally for
>> C<apxs>
>> -          - save the custom config in $custom_config_path
>> -          - restart the currently run program
>> -
>> -  4) make install
>> -
>> -=back
>> -
>> -
>> -
>> -=head2 Saving Custom Configuration Options
>> -
>> -If you want to override the existing custom configurations options to
>> -C<Apache::TestConfigData>, use the C<-save>  flag when running C<TEST>.
>> -
>> -If you are running C<Apache::Test>  as a user who does not have
>> -permission to alter the system C<Apache::TestConfigData>, you can
>> -place your own private configuration file F<TestConfigData.pm>  under
>> -C<$ENV{HOME}/.apache-test/Apache/>, which C<Apache::Test>  will use, if
>> -present. An example of such a configuration file is
>> -
>> -  # file $ENV{HOME}/.apache-test/Apache/TestConfigData.pm
>> -  package Apache::TestConfigData;
>> -  use strict;
>> -  use warnings;
>> -  use vars qw($vars);
>> -
>> -  $vars = {
>> -      'group' =>  'me',
>> -      'user' =>  'myself',
>> -      'port' =>  '8529',
>> -      'httpd' =>  '/usr/local/apache/bin/httpd',
>> -
>> -  };
>> -  1;
>> -
>> -
>> -
>> -
>>  =cut
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
>> For additional commands, e-mail: dev-help@perl.apache.org
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message