|
NAMETest2::Manual::Tooling::Plugin::TestExit - How to safely add pre-exit behaviors.DESCRIPTIONThis describes the correct/safe way to add pre-exit behaviors to tests via a custom plugin.The naive way to attempt this would be to add an "END { ... }" block. That can work, and may not cause problems.... On the other hand there are a lot of ways that can bite you. Describing all the potential problems of an END block, and how it might conflict with Test2 (Which has its own END block) is beyond the scope of this document. COMPLETE CODE UP FRONTpackage Test2::Plugin::MyPlugin; use Test2::API qw{test2_add_callback_exit}; sub import { my $class = shift; test2_add_callback_exit(sub { my ($ctx, $orig_code, $new_exit_code_ref) = @_; return if $orig_code == 42; $$new_exit_code_ref = 42; }); } 1; LINE BY LINE
SEE ALSOTest2::Manual - Primary index of the manual.SOURCEThe source code repository for Test2-Manual can be found at https://github.com/Test-More/Test2-Suite/.MAINTAINERS
AUTHORS
COPYRIGHTCopyright 2018 Chad Granum <exodist@cpan.org>.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/
Visit the GSP FreeBSD Man Page Interface. |