1Test2::Tools::AsyncSubtUessetr(3C)ontributed Perl DocumeTnetsatt2i:o:nTools::AsyncSubtest(3)
2
3
4
6 Test2::Tools::AsyncSubtest - Tools for writing async subtests.
7
9 These are tools for writing async subtests. Async subtests are subtests
10 which can be started and stashed so that they can continue to receive
11 events while other events are also being generated.
12
14 use Test2::Bundle::Extended;
15 use Test2::Tools::AsyncSubtest;
16
17 my $ast1 = async_subtest local => sub {
18 ok(1, "Inside subtest");
19 };
20
21 my $ast2 = fork_subtest child => sub {
22 ok(1, "Inside subtest in another process");
23 };
24
25 # You must call finish on the subtests you create. Finish will wait/join on
26 # any child processes and threads.
27 $ast1->finish;
28 $ast2->finish;
29
30 done_testing;
31
33 Everything is exported by default.
34
35 $ast = async_subtest $name
36 $ast = async_subtest $name => sub { ... }
37 $ast = async_subtest $name => \%hub_params, sub { ... }
38 Create an async subtest. Run the codeblock if it is provided.
39
40 $ast = fork_subtest $name => sub { ... }
41 $ast = fork_subtest $name => \%hub_params, sub { ... }
42 Create an async subtest. Run the codeblock in a forked process.
43
44 $ast = thread_subtest $name => sub { ... }
45 $ast = thread_subtest $name => \%hub_params, sub { ... }
46 ** DISCOURAGED ** Threads are fragile. Thread tests are not even
47 run unless the AUTHOR_TESTING or T2_DO_THREAD_TESTS env vars are
48 enabled.
49
50 Create an async subtest. Run the codeblock in a thread.
51
53 Async Subtests are always buffered.
54
56 The source code repository for Test2-AsyncSubtest can be found at
57 https://github.com/Test-More/Test2-Suite/.
58
60 Chad Granum <exodist@cpan.org>
61
63 Chad Granum <exodist@cpan.org>
64
66 Copyright 2018 Chad Granum <exodist7@gmail.com>.
67
68 This program is free software; you can redistribute it and/or modify it
69 under the same terms as Perl itself.
70
71 See http://dev.perl.org/licenses/
72
73
74
75perl v5.36.0 2023-03-23 Test2::Tools::AsyncSubtest(3)