Test that some code calls exit() without terminating testing
version 0.11
use Test::More tests => 4; use Test::Exit; is exit_code { exit 75; }, 75, "procmail not found"; exits_ok { exit 1; } "exiting exits"; never_exits_ok { print "Hi!"; } "not exiting doesn't exit"l exits_zero { exit 0; } "exited with success"; exits_nonzero { exit 42; } "exited with failure";
Test::Exit provides some simple tools for testing code that might call \*(C`exit()\*(C', providing you with the status code without exiting the test file.
The only criterion tested is that the supplied code does or does not call \*(C`exit()\*(C'. If the code throws an exception, the exception will be propagated and you will have to catch it yourself. \*(C`die()\*(C'ing is not exiting for the purpose of these tests.
Unlike previous versions of this module, the current version doesn't use exceptions to do its work, so even if you call \*(C`exit()\*(C' inside of an \*(C`eval\*(C', everything should work.
Runs the given code. If the code calls \*(C`exit()\*(C', then \*(C`exit_code\*(C' will return a number, which is the status that \*(C`exit()\*(C' would have exited with. If the code never calls \*(C`exit()\*(C', returns \*(C`undef\*(C'. This is the Test::Fatal-like interface. All of the other functions are wrappers for this one, retained for legacy purposes.
Tests that the supplied code calls \*(C`exit()\*(C' at some point.
Tests that the supplied code calls \*(C`exit()\*(C' with a nonzero value.
Tests that the supplied code calls \*(C`exit()\*(C' with a zero (successful) value.
Tests that the supplied code completes without calling \*(C`exit()\*(C'.
Andrew Rodland <[email protected]>
This software is copyright (c) 2013 by Andrew Rodland.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.