TEST2::MANUAL::TOOLING::PLUGIN::TOOLCOMPLETES(3pm)
π NAME π
Okay bestie, so this page is Test2::Manual::Tooling::Plugin::ToolCompletes β it's the tutorial that teaches you how to add behaviors that happen when a tool completes its work. From the Test2 manual family, no cap. π
β¨ DESCRIPTION β¨
This tutorial helps you understand how to add behaviors that occur when a tool is done with its work. That's the whole vibe. π¦
Every single tool has to acquire a context and then release it β that's just how the girlies operate. So for this tutorial, we're making use of the release hooks, the ones that get called every time a tool releases the context object. Obsessed, honestly. π
π₯ COMPLETE CODE UP FRONT π₯
Here's the whole thing, ready to slay:
package Test2::Plugin::MyPlugin;
use Test2::API qw{test2_add_callback_context_release};
sub import {
my $class = shift;
test2_add_callback_context_release(sub {
my $ctx_ref = shift;
print "Context was released\n";
});
}
1;
πΈ LINE BY LINE πΈ
use Test2::API qw{test2_add_callback_context_release};β this is what imports thetest2_add_callback_context_release()callback. Gotta have it, periodt. β¨test2_add_callback_context_release(sub { ... })andmy $ctx_ref = shiftβ okay so the coderefs fortest2_add_callback_context_release()will receive exactly 1 argument: the context that's being released. One.$ctx_refis holding it, iykyk. π«Άprint "Context was released\n"β prints a little notification whenever the context is released. It's giving β¨observabilityβ¨, we love a heads-up. π
π SEE ALSO π
Test2::Manualβ the primary index of the manual. Start there if you're lost, bestie, it's the main character.
π SOURCE π
The source code repository for Test2-Manual can be found at https://github.com/Test-More/test-more/. Go be nosy, it's encouraged. π₯
π§ MAINTAINERS π§
Chad Granum <exodist@cpan.org>
π AUTHORS π
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
Copyright 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/
Fr fr, that's the whole page β go forth and hook your own behaviors onto the release. π
Okay that's a wrap, mwah! π This was perl v5.42.3, dated 2026-11-03, and the page you just read is Test2::...ompletes(3pm) β see you in the next one, bestie! π
β¨π¦
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms