Test2::...ompletes(3)

πŸ“¦ version 1.302214, in opensuse-leap 16.0

🌸 NAME 🌸

Okay bestie, this is the Test2::...ompletes(3) page from User Contributed Perl Documentation, and the manual it’s serving is Test2::Manual::Tooling::Plugin::ToolCompletes β€” literally how to add behaviors that occur when a tool completes work. ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

This tutorial is here to help you understand how to add behaviors that occur when a tool is done with its work. All tools need to acquire and then release a context, and for this tutorial we make use of the release hooks that are called every time a tool releases the context object. Lowkey iconic plumbing, ngl. πŸ’…

πŸŽ€ COMPLETE CODE UP FRONT πŸŽ€

Here’s the whole vibe up front, no cap:

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 imports the test2_add_callback_context_release() callback. Slay, that’s the entry point. ✨
  • test2_add_callback_context_release(sub { ... }) / my $ctx_ref = shift β€” the coderefs for test2_add_callback_context_release() will receive exactly 1 argument, the context being released. One argument. Not two. Not a secret third thing. πŸ’€
  • print "Context was released\n" β€” this prints a notification whenever the context is released. Cute little β€œit happened” moment, fr fr. 🫢

🌈 SEE ALSO 🌈

  • Test2::Manual β€” primary index of the manual. Go browse, bestie. πŸ‘‘

πŸ’– SOURCE πŸ’–

The source code repository for Test2-Manual can be found at https://github.com/Test-More/test-more/. That’s the link. Periodt. πŸ”₯

🧚 MAINTAINERS 🧚

Chad Granum <exodist@cpan.org>

⭐ AUTHORS ⭐

Chad Granum <exodist@cpan.org>

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/


Okay that’s the whole page, bestie πŸ’– β€” source/version + date check: perl v5.42.0, 2025-07-28, and the page is Test2::...ompletes(3). periodt ✨

πŸ“¦ where this page comes from