You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-cvs@httpd.apache.org by st...@apache.org on 2004/12/20 05:02:19 UTC

svn commit: r122805 - /httpd/test/trunk/perl-framework/Apache-Test/Changes /httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm /httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestRun.pm

Author: stas
Date: Sun Dec 19 20:02:17 2004
New Revision: 122805

URL: http://svn.apache.org/viewcvs?view=rev&rev=122805
Log:
add various straps to aid the new Apache-TestItSelf sub-project, which
is used to test A-T config options

Modified:
   httpd/test/trunk/perl-framework/Apache-Test/Changes
   httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm
   httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestRun.pm

Modified: httpd/test/trunk/perl-framework/Apache-Test/Changes
Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Changes?view=diff&rev=122805&p1=httpd/test/trunk/perl-framework/Apache-Test/Changes&r1=122804&p2=httpd/test/trunk/perl-framework/Apache-Test/Changes&r2=122805
==============================================================================
--- httpd/test/trunk/perl-framework/Apache-Test/Changes	(original)
+++ httpd/test/trunk/perl-framework/Apache-Test/Changes	Sun Dec 19 20:02:17 2004
@@ -8,6 +8,9 @@
   
 =item 1.18-dev
 
+add various straps to aid the new Apache-TestItSelf sub-project, which
+is used to test A-T config options [Stas]
+
 avoid entering endless loops when interactive config is used, by
 restarting the test suite with an explicit selected arguments for
 -httpd (and optionally -apxs) [Stas]

Modified: httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm
Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm?view=diff&rev=122805&p1=httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm&r1=122804&p2=httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm&r2=122805
==============================================================================
--- httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm	(original)
+++ httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestConfig.pm	Sun Dec 19 20:02:17 2004
@@ -176,6 +176,11 @@
 }
 
 sub modperl_build_config {
+
+    # 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};
+
     eval {
         require Apache::Build;
     } or return undef;
@@ -384,6 +389,9 @@
         # so it never returns
         $self->custom_config_first_time($self->{vars});
     }
+    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
@@ -1856,6 +1864,44 @@
     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;
+        error "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)
@@ -2105,6 +2151,12 @@
         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()) {
@@ -2121,8 +2173,11 @@
     my $self = shift;
     my $conf_opts = shift;
 
-    unless (-t STDIN) {
-        error "STDIN is closed, can't run interactive config";
+    # 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();
     }
 
@@ -2215,7 +2270,7 @@
     # 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();
+    Apache::TestRun::rerun($vars);
 }
 
 sub _custom_config_prompt_path {
@@ -2422,6 +2477,16 @@
 configuration phase (C<t/TEST -config>, C<Apache::Test> will
 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 AUTHOR
 

Modified: httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestRun.pm
Url: http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestRun.pm?view=diff&rev=122805&p1=httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestRun.pm&r1=122804&p2=httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestRun.pm&r2=122805
==============================================================================
--- httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestRun.pm	(original)
+++ httpd/test/trunk/perl-framework/Apache-Test/lib/Apache/TestRun.pm	Sun Dec 19 20:02:17 2004
@@ -1310,8 +1310,12 @@
 sub skip_test_suite {
     my $no_doubt = shift;
 
-    # we can't prompt when there is no STDIN;
-    $no_doubt = 1 unless -t STDIN;
+    # 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}) {
+        $no_doubt = 1;
+    }
 
     print qq[