httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: Exiting a test script if a test fails
Date Fri, 27 Feb 2004 19:16:54 GMT
William McKee wrote:
> On Thu, Feb 26, 2004 at 04:05:02PM -0800, Stas Bekman wrote:
>>it works perfectly fine for me. You need to do that call in the *client*.
> Doh! My poor brain is still having trouble with this distinction <g>.
> The trouble is that the script I need to bail out of is a response test
> (server side). I guess I'll stick with either the die or the skip, both
> of which work fine.

What happens is that the client needs to read the output from the server and 
then flush it out to Test::Harness. But if you server side dies it won't send 
to the client the magic 'Bail out!' string. So what you could do is instead of 
die'ing, use warn, to log things into error_log and then send 'Bail out' as a 
response and return as if the handler was successful.

So, on the server side, instead of doing:

  unless ($whatever) {
    print "Bail out!";
    die "whatever";

You need to do:

    unless ($whatever) {
      print "Bail out!";
      warn "whatever";
      return Apache::OK;

and let the client print it out.

Actually, I was wrong suggesting that you need to die on the client side to 
get this working. The only reason you may want to do that, is because normally 
STDOUT is buffered and T-H won't see the magic words untill it's flushed. die 
helps to flush that immediatelly.

>>I say we come up with Apache::Test::foo and then make Test::Harness adopt 
> OK, sounds fine to me (though I'm not sure what you mean by it). Let me
> know if you need me to help with anything (like testing).

In the old days all tests were written by using explicit prints like so:

   print "1..10\n;
   print "ok 1\n";
   print "not ok 2\n";

which wasn't convenient. So with time the wrappers to do these things were 
written, making the above:

   plan tests => 10;
   ok 1;
   ok 0;

I suppose most people don't use the the bailout feature, therefore it's still 
remaining a simple print and has no wrapper to do the job. So I was suggesting 
for us to provide that wrapper and then hoping that (not Test::Harness 
as I've incorrectly suggested earlier) to adopt that wrapper for everybody to use.

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

View raw message