Hi there,

I've to write a Test::More script and I've to send the output to an email-address. I catched the output but if any failure comes up, the Test called "exit()" and my script never reached the end.

Is there a chance to catch or to overwrite the exit() function? Or can I do some thinge, so that the Test-Module doesn't use exit()?

I try to redefine the CORE::exit-Function, but it doesnt work. I tried to define an exit()-function in EVERY package (I would wear sackcloth and ashes :) but nothing happend.

my $exit_sub = sub($) { die @_; }; sub _overwrite_exit { my $package = $_[0]; no warnings 'redefine'; no strict 'refs'; return if(*{"$package\::exit"}{CODE} && *{"$package\::exit"}{CODE} + == $exit_sub); #print "\n$package"; *{"$package\::exit"} = $exit_sub; foreach my $entry (keys %{"$package\::"}) { next if($entry !~ s/::$//); _overwrite_exit($entry); } } _overwrite_exit('main'); eval { print 123; exit(123); }; print "Test: $@"; # never reached!
Any useful ideas? I only have one sollution at the moment: create another script an call the testscript via system-call. But that has a bad taste for me...

In reply to Use die() instead of exit() in Test::More by Tobiwan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.