Test::Exit(3pm)
π Test::Exit β the manual page, but make it make sense π
okay bestie, gather round, because this is the User Contributed Perl Documentation entry for Test::Exit, and it's genuinely one of those modules that just gets you. No cap. π¦
β¨ NAME β¨
Test::Exit β test that some code calls exit() without terminating testing.
Like, the whole point is you wanna check that a thing exits, but you also wanna still be alive to keep running your test file. Iconic behaviour, honestly. π
πΈ VERSION πΈ
version 0.11
π SYNOPSIS π
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";
yes bestie, that straylat the end of thenever_exits_okline is exactly what the original says, and we are respectfully not touching it. character for character, periodt. π
π¦ DESCRIPTION π¦
So, Test::Exit hands you some genuinely simple little tools for testing code that might call exit(). The glow-up? You get the status code back without your test file just dying on you mid-run. π
The only criterion it tests is whether the code you gave it does β or does not β call exit(). That's it. That's the vibe check.
Now the important part, so listen up:
- If your code throws an exception, that exception gets propagated, and you're gonna have to catch it yourself. Test::Exit is not your babysitter for that. π
die()ing is not exiting, as far as these tests are concerned. Different thing entirely, bestie.- Unlike previous versions of this module, the current version doesn't use exceptions to do its work, so even if you call
exit()inside of aneval, everything should work. glow up achieved. β¨
π FUNCTIONS π
β exit_code
Runs the code you hand it. If that code calls exit(), then exit_code will return a number β and that number is the status that exit() would have exited with. If the code never calls exit(), you get undef back. π«Ά
This is the Test::Fatal-like interface. All of the other functions are just wrappers around this one, kept around for legacy purposes. So like, this is the main character. The rest are supporting cast. π
β exits_ok
Tests that the supplied code calls exit() at some point. That's the whole job. π
β exits_nonzero
Tests that the supplied code calls exit() with a nonzero value. Failure mode energy, and we're checking for it. π
β exits_zero
Tests that the supplied code calls exit() with a zero (successful) value. slay, it worked. π
β never_exits_ok
Tests that the supplied code completes without calling exit(). Just vibes, start to finish, no escaping. πΈ
π AUTHOR π
Andrew Rodland <arodland@cpan.org>
π COPYRIGHT AND LICENSE π
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.
lowkey the legal section is the most serious part of any manpage and I respect it deeply. π«Ά
okay that's the whole page bestie, and here's your cute little sign-off: this was perl v5.34.0, dated 2022-06-05, and the page is Test::Exit(3pm). mwah. πβ¨π
π¦ where this page comes from
- debian bookworm: libtest-exit-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-exit-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-exit-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-exit-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-exit-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms