You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2001/10/18 07:31:53 UTC

[patch] Re: Apache-Test breakage

Doug MacEachern wrote:


>>I think the break in the middle of config is important to fix, right?
> 
> yes.  the problem right now is if die() is thrown, files have been
> generated but the Apache::TestConfig object is not committed to
> t/conf/apache_test_config.pm.  so t/TEST -clean does not know about those
> generated files.  either a DESTROY or __DIE__ handler could probably be
> used to solve the problem.

__DIE__ is a mess to use and DESTROY cannot be easily used unless 
Apache::TestConfig is subclassed. I think the following is quite clean 
solution. I've tested it with breaking the configure by requiring all 
.pm files (if you remember the breakage I had while developing 
APACHE_TEST_CONFIGURE functionality)

So it works when you run ./t/TEST, but when you run 'make test', for 
some reason Makefile doesn't abort on exit from test_clean target, no 
matter if I put exit -1, 0 or 1, and proceeds with run_tests target. 
Does that have anything to do with the installed __DIE__ sighandler?

I suggest to review the code and get rid of the __DIE__ sighandler all 
together and instead wrap the relevant pieces of code in eval block. Are 
there any exception handling modules bundled in the core?

In any case I think this patch can be committed without relation to the 
__DIE__ issue.

-- Index: Apache-Test/lib/Apache/TestRun.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.59
diff -u -r1.59 TestRun.pm
--- Apache-Test/lib/Apache/TestRun.pm	2001/10/17 02:56:24	1.59
+++ Apache-Test/lib/Apache/TestRun.pm	2001/10/18 05:14:11
@@ -483,7 +483,16 @@
          $self->opt_clean(1);
      }

-    $self->configure;
+    # if configure() fails for some reason before it has flushed the
+    # config to a file, save it so -clean will be able to clean
+    eval { $self->configure; };
+    if ($@) {
+        error "configure() has failed:\n$@";
+        warning "forcing Apache::TestConfig object save";
+        $self->{test_config}->save;
+        warning "run 't/TEST -clean' to clean up before continuing";
+        exit;
+    }

      if ($self->{opts}->{configure}) {
          warning "reconfiguration done";



_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Re: [patch] Re: Apache-Test breakage

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

> On Thu, 18 Oct 2001, Stas Bekman wrote:
>  
> 
>>So it works when you run ./t/TEST, but when you run 'make test', for 
>>some reason Makefile doesn't abort on exit from test_clean target, no 
>>matter if I put exit -1, 0 or 1, and proceeds with run_tests target. 
>>Does that have anything to do with the installed __DIE__ sighandler?
>>
> 
> probably, since __DIE__ will stop the server.  where did you put the
> exit(1) call?  i think it should work in the __DIE__ handler.


the exit call is in the $@ handling code:

+    eval { $self->configure; };
+    if ($@) {
+        error "configure() has failed:\n$@";
+        warning "forcing Apache::TestConfig object save";
+        $self->{test_config}->save;
+        warning "run 't/TEST -clean' to clean up before continuing";
+        exit;

         ^^^^^^^

+    }


Am I correct to say that if Makefile has:

C: A B

and A's return status is not 0, make will abort? I know that I've 
committed exit; but I've tried 1 and -1 without any effect. Any ideas 
why this happens? If you want an easy way to simulate breakage just do this:

Index: Apache-Test/lib/Apache/TestConfigPerl.pm
===================================================================
RCS file: 
/home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.38
diff -u -r1.38 TestConfigPerl.pm
--- Apache-Test/lib/Apache/TestConfigPerl.pm    2001/10/18 04:18:16     1.38
+++ Apache-Test/lib/Apache/TestConfigPerl.pm    2001/10/19 02:14:56
@@ -347,6 +347,7 @@
      if (open $fh, $file) {
          my $content = <$fh>;
          close $fh;
+        require $file;
          if ($content =~ /APACHE_TEST_CONFIGURE/m) {
              eval { require $file };
              warn $@ if $@;


_____________________________________________________________________
Stas Bekman             JAm_pH      --   Just Another mod_perl Hacker
http://stason.org/      mod_perl Guide   http://perl.apache.org/guide
mailto:stas@stason.org  http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/


Re: [patch] Re: Apache-Test breakage

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 18 Oct 2001, Stas Bekman wrote:
 
> So it works when you run ./t/TEST, but when you run 'make test', for 
> some reason Makefile doesn't abort on exit from test_clean target, no 
> matter if I put exit -1, 0 or 1, and proceeds with run_tests target. 
> Does that have anything to do with the installed __DIE__ sighandler?

probably, since __DIE__ will stop the server.  where did you put the
exit(1) call?  i think it should work in the __DIE__ handler.
 
> I suggest to review the code and get rid of the __DIE__ sighandler all 
> together and instead wrap the relevant pieces of code in eval block. Are 
> there any exception handling modules bundled in the core?

if you can switch to eval {} that would be fine.
 
> In any case I think this patch can be committed without relation to the 
> __DIE__ issue.

looks good, +1