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.
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...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!
In reply to Use die() instead of exit() in Test::More by Tobiwan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |