CINXE.COM
Test2::AsyncSubtest - Object representing an async subtest. - Perldoc Browser
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Test2::AsyncSubtest - Object representing an async subtest. - Perldoc Browser</title> <link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser"> <link rel="canonical" href="https://perldoc.perl.org/Test2::AsyncSubtest"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" /> <style> body { background: #f4f4f5; color: #020202; } .navbar-dark { background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%); background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%); background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0); background-repeat: repeat-x; } .navbar-dark .navbar-nav .nav-link, .navbar-dark .navbar-nav .nav-link:focus { color: #fff } .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 } #wrapperlicious { margin: 0 auto; font: 0.9em 'Helvetica Neue', Helvetica, sans-serif; font-weight: normal; line-height: 1.5em; margin: 0; padding: 0; } #wrapperlicious h1 { font-size: 1.5em } #wrapperlicious h2 { font-size: 1.3em } #wrapperlicious h3 { font-size: 1.1em } #wrapperlicious h4 { font-size: 0.9em } #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3, #wrapperlicious h4, #wrapperlicious dt { color: #020202; margin-top: 1em; margin-bottom: 1em; position: relative; font-weight: bold; } #wrapperlicious a { color: inherit; text-decoration: underline } #wrapperlicious #toc { text-decoration: none } #wrapperlicious a:hover { color: #2a2a2a } #wrapperlicious a img { border: 0 } #wrapperlicious :not(pre) > code { color: inherit; background-color: rgba(0, 0, 0, 0.04); border-radius: 3px; font: 0.9em Consolas, Menlo, Monaco, monospace; padding: 0.3em; } #wrapperlicious dd { margin: 0; margin-left: 2em; } #wrapperlicious dt { color: #2a2a2a; font-weight: bold; margin-left: 0.9em; } #wrapperlicious p { margin-bottom: 1em; margin-top: 1em; } #wrapperlicious li > p { margin-bottom: 0; margin-top: 0; } #wrapperlicious pre { border: 1px solid #c1c1c1; border-radius: 3px; font: 100% Consolas, Menlo, Monaco, monospace; margin-bottom: 1em; margin-top: 1em; } #wrapperlicious pre > code { display: block; background-color: #f6f6f6; font: 0.9em Consolas, Menlo, Monaco, monospace; line-height: 1.5em; text-align: left; white-space: pre; padding: 1em; } #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul { margin-bottom: 1em; margin-top: 1em; } #wrapperlicious ul { list-style-type: square; } #wrapperlicious ul ul { margin-bottom: 0px; margin-top: 0px; } #footer { font-size: 0.8em; padding-top: 0.5em; text-align: center; } #more { display: inline; font-size: 0.8em; } #perldocdiv { background-color: #fff; border: 1px solid #c1c1c1; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; margin-left: auto; margin-right: auto; padding: 3em; padding-top: 1em; max-width: 960px; } #moduleversion { float: right } #wrapperlicious .leading-notice { font-style: italic; padding-left: 1em; margin-top: 1em; margin-bottom: 1em; } #wrapperlicious .permalink { display: none; left: -0.75em; position: absolute; padding-right: 0.25em; text-decoration: none; } #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink, #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink, #wrapperlicious dt:hover .permalink { display: block; } </style> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-KVNWBNT5FB'); gtag('config', 'UA-50555-3'); </script> </head> <body> <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between"> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <a class="navbar-brand" href="/"><img src="/images/perl_camel_30.png" width="30" height="30" class="d-inline-block align-top" alt="Perl Camel Logo"> Perldoc Browser</a> <div class="collapse navbar-collapse" id="navbarNav"> <ul class="navbar-nav mr-auto"> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.39.4</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-stable"> <a class="dropdown-item" href="/Test2::AsyncSubtest">Latest</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.1/Test2::AsyncSubtest">5.40.1</a> <a class="dropdown-item" href="/5.40.0/Test2::AsyncSubtest">5.40.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.3/Test2::AsyncSubtest">5.38.3</a> <a class="dropdown-item" href="/5.38.2/Test2::AsyncSubtest">5.38.2</a> <a class="dropdown-item" href="/5.38.1/Test2::AsyncSubtest">5.38.1</a> <a class="dropdown-item" href="/5.38.0/Test2::AsyncSubtest">5.38.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.36.3/Test2::AsyncSubtest">5.36.3</a> <a class="dropdown-item" href="/5.36.2/Test2::AsyncSubtest">5.36.2</a> <a class="dropdown-item" href="/5.36.1/Test2::AsyncSubtest">5.36.1</a> <a class="dropdown-item" href="/5.36.0/Test2::AsyncSubtest">5.36.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.34.3/Test2::AsyncSubtest">5.34.3</a> <a class="dropdown-item" href="/5.34.2/Test2::AsyncSubtest">5.34.2</a> <a class="dropdown-item" href="/5.34.1/Test2::AsyncSubtest">5.34.1</a> <a class="dropdown-item" href="/5.34.0/Test2::AsyncSubtest">5.34.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.32.1/Test2::AsyncSubtest">5.32.1</a> <a class="dropdown-item" href="/5.32.0/Test2::AsyncSubtest">5.32.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.30.3/Test2::AsyncSubtest">5.30.3</a> <a class="dropdown-item" href="/5.30.2/Test2::AsyncSubtest">5.30.2</a> <a class="dropdown-item" href="/5.30.1/Test2::AsyncSubtest">5.30.1</a> <a class="dropdown-item" href="/5.30.0/Test2::AsyncSubtest">5.30.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.28.3/Test2::AsyncSubtest">5.28.3</a> <a class="dropdown-item" href="/5.28.2/Test2::AsyncSubtest">5.28.2</a> <a class="dropdown-item" href="/5.28.1/Test2::AsyncSubtest">5.28.1</a> <a class="dropdown-item" href="/5.28.0/Test2::AsyncSubtest">5.28.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.26.3/Test2::AsyncSubtest">5.26.3</a> <a class="dropdown-item" href="/5.26.2/Test2::AsyncSubtest">5.26.2</a> <a class="dropdown-item" href="/5.26.1/Test2::AsyncSubtest">5.26.1</a> <a class="dropdown-item" href="/5.26.0/Test2::AsyncSubtest">5.26.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.24.4/Test2::AsyncSubtest">5.24.4</a> <a class="dropdown-item" href="/5.24.3/Test2::AsyncSubtest">5.24.3</a> <a class="dropdown-item" href="/5.24.2/Test2::AsyncSubtest">5.24.2</a> <a class="dropdown-item" href="/5.24.1/Test2::AsyncSubtest">5.24.1</a> <a class="dropdown-item" href="/5.24.0/Test2::AsyncSubtest">5.24.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.22.4/Test2::AsyncSubtest">5.22.4</a> <a class="dropdown-item" href="/5.22.3/Test2::AsyncSubtest">5.22.3</a> <a class="dropdown-item" href="/5.22.2/Test2::AsyncSubtest">5.22.2</a> <a class="dropdown-item" href="/5.22.1/Test2::AsyncSubtest">5.22.1</a> <a class="dropdown-item" href="/5.22.0/Test2::AsyncSubtest">5.22.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.20.3/Test2::AsyncSubtest">5.20.3</a> <a class="dropdown-item" href="/5.20.2/Test2::AsyncSubtest">5.20.2</a> <a class="dropdown-item" href="/5.20.1/Test2::AsyncSubtest">5.20.1</a> <a class="dropdown-item" href="/5.20.0/Test2::AsyncSubtest">5.20.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.18.4/Test2::AsyncSubtest">5.18.4</a> <a class="dropdown-item" href="/5.18.3/Test2::AsyncSubtest">5.18.3</a> <a class="dropdown-item" href="/5.18.2/Test2::AsyncSubtest">5.18.2</a> <a class="dropdown-item" href="/5.18.1/Test2::AsyncSubtest">5.18.1</a> <a class="dropdown-item" href="/5.18.0/Test2::AsyncSubtest">5.18.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.16.3/Test2::AsyncSubtest">5.16.3</a> <a class="dropdown-item" href="/5.16.2/Test2::AsyncSubtest">5.16.2</a> <a class="dropdown-item" href="/5.16.1/Test2::AsyncSubtest">5.16.1</a> <a class="dropdown-item" href="/5.16.0/Test2::AsyncSubtest">5.16.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.14.4/Test2::AsyncSubtest">5.14.4</a> <a class="dropdown-item" href="/5.14.3/Test2::AsyncSubtest">5.14.3</a> <a class="dropdown-item" href="/5.14.2/Test2::AsyncSubtest">5.14.2</a> <a class="dropdown-item" href="/5.14.1/Test2::AsyncSubtest">5.14.1</a> <a class="dropdown-item" href="/5.14.0/Test2::AsyncSubtest">5.14.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.12.5/Test2::AsyncSubtest">5.12.5</a> <a class="dropdown-item" href="/5.12.4/Test2::AsyncSubtest">5.12.4</a> <a class="dropdown-item" href="/5.12.3/Test2::AsyncSubtest">5.12.3</a> <a class="dropdown-item" href="/5.12.2/Test2::AsyncSubtest">5.12.2</a> <a class="dropdown-item" href="/5.12.1/Test2::AsyncSubtest">5.12.1</a> <a class="dropdown-item" href="/5.12.0/Test2::AsyncSubtest">5.12.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.10.1/Test2::AsyncSubtest">5.10.1</a> <a class="dropdown-item" href="/5.10.0/Test2::AsyncSubtest">5.10.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.8.9/Test2::AsyncSubtest">5.8.9</a> <a class="dropdown-item" href="/5.8.8/Test2::AsyncSubtest">5.8.8</a> <a class="dropdown-item" href="/5.8.7/Test2::AsyncSubtest">5.8.7</a> <a class="dropdown-item" href="/5.8.6/Test2::AsyncSubtest">5.8.6</a> <a class="dropdown-item" href="/5.8.5/Test2::AsyncSubtest">5.8.5</a> <a class="dropdown-item" href="/5.8.4/Test2::AsyncSubtest">5.8.4</a> <a class="dropdown-item" href="/5.8.3/Test2::AsyncSubtest">5.8.3</a> <a class="dropdown-item" href="/5.8.2/Test2::AsyncSubtest">5.8.2</a> <a class="dropdown-item" href="/5.8.1/Test2::AsyncSubtest">5.8.1</a> <a class="dropdown-item" href="/5.8.0/Test2::AsyncSubtest">5.8.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.6.2/Test2::AsyncSubtest">5.6.2</a> <a class="dropdown-item" href="/5.6.1/Test2::AsyncSubtest">5.6.1</a> <a class="dropdown-item" href="/5.6.0/Test2::AsyncSubtest">5.6.0</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.005_04/Test2::AsyncSubtest">5.005_04</a> <a class="dropdown-item" href="/5.005_03/Test2::AsyncSubtest">5.005_03</a> <a class="dropdown-item" href="/5.005_02/Test2::AsyncSubtest">5.005_02</a> <a class="dropdown-item" href="/5.005_01/Test2::AsyncSubtest">5.005_01</a> <a class="dropdown-item" href="/5.005/Test2::AsyncSubtest">5.005</a> </div> </li> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-dev"> <a class="dropdown-item" href="/blead/Test2::AsyncSubtest">blead</a> <a class="dropdown-item" href="/5.41.10/Test2::AsyncSubtest">5.41.10</a> <a class="dropdown-item" href="/5.41.9/Test2::AsyncSubtest">5.41.9</a> <a class="dropdown-item" href="/5.41.8/Test2::AsyncSubtest">5.41.8</a> <a class="dropdown-item" href="/5.41.7/Test2::AsyncSubtest">5.41.7</a> <a class="dropdown-item" href="/5.41.6/Test2::AsyncSubtest">5.41.6</a> <a class="dropdown-item" href="/5.41.5/Test2::AsyncSubtest">5.41.5</a> <a class="dropdown-item" href="/5.41.4/Test2::AsyncSubtest">5.41.4</a> <a class="dropdown-item" href="/5.41.3/Test2::AsyncSubtest">5.41.3</a> <a class="dropdown-item" href="/5.41.2/Test2::AsyncSubtest">5.41.2</a> <a class="dropdown-item" href="/5.41.1/Test2::AsyncSubtest">5.41.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.40.1-RC1/Test2::AsyncSubtest">5.40.1-RC1</a> <a class="dropdown-item" href="/5.40.0-RC2/Test2::AsyncSubtest">5.40.0-RC2</a> <a class="dropdown-item" href="/5.40.0-RC1/Test2::AsyncSubtest">5.40.0-RC1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.39.10/Test2::AsyncSubtest">5.39.10</a> <a class="dropdown-item" href="/5.39.9/Test2::AsyncSubtest">5.39.9</a> <a class="dropdown-item" href="/5.39.8/Test2::AsyncSubtest">5.39.8</a> <a class="dropdown-item" href="/5.39.7/Test2::AsyncSubtest">5.39.7</a> <a class="dropdown-item" href="/5.39.6/Test2::AsyncSubtest">5.39.6</a> <a class="dropdown-item" href="/5.39.5/Test2::AsyncSubtest">5.39.5</a> <a class="dropdown-item active" href="/5.39.4/Test2::AsyncSubtest">5.39.4</a> <a class="dropdown-item" href="/5.39.3/Test2::AsyncSubtest">5.39.3</a> <a class="dropdown-item" href="/5.39.2/Test2::AsyncSubtest">5.39.2</a> <a class="dropdown-item" href="/5.39.1/Test2::AsyncSubtest">5.39.1</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.38.3-RC1/Test2::AsyncSubtest">5.38.3-RC1</a> </div> </li> <li class="nav-item dropdown text-nowrap"> <a class="nav-link dropdown-toggle" href="#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a> <div class="dropdown-menu" aria-labelledby="dropdownlink-nav"> <a class="dropdown-item" href="/5.39.4/perl">Perl</a> <a class="dropdown-item" href="/5.39.4/perlintro">Intro</a> <a class="dropdown-item" href="/5.39.4/perl#Tutorials">Tutorials</a> <a class="dropdown-item" href="/5.39.4/perlfaq">FAQs</a> <a class="dropdown-item" href="/5.39.4/perl#Reference-Manual">Reference</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.39.4/perlop">Operators</a> <a class="dropdown-item" href="/5.39.4/functions">Functions</a> <a class="dropdown-item" href="/5.39.4/variables">Variables</a> <a class="dropdown-item" href="/5.39.4/modules">Modules</a> <a class="dropdown-item" href="/5.39.4/perlutil">Utilities</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="/5.39.4/perldelta">Release Notes</a> <a class="dropdown-item" href="/5.39.4/perlcommunity">Community</a> <a class="dropdown-item" href="/5.39.4/perlhist">History</a> </div> </li> </ul> <ul class="navbar-nav"> <script> function set_expand (expand) { var perldocdiv = document.getElementById('perldocdiv'); var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width'); var expanded = (width == '' || width == 'none') ? true : false; if (expand === null) { expand = !expanded; } if ((expand && !expanded) || (!expand && expanded)) { perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px'); var button_classlist = document.getElementById('content-expand-button').classList; if (expand) { button_classlist.add('btn-light'); button_classlist.remove('btn-outline-light'); } else { button_classlist.add('btn-outline-light'); button_classlist.remove('btn-light'); } } return expand; } function toggle_expand () { var expand = set_expand(null); document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC'; } function read_expand () { return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', function () { if (read_expand()) { set_expand(true); } }); } else if (read_expand()) { set_expand(true); } </script> <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-4" onclick="toggle_expand()">Expand</button> </ul> <form class="form-inline" method="get" action="/5.39.4/search"> <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search" value=""> </form> </div> </nav> <div id="wrapperlicious" class="container-fluid"> <div id="perldocdiv"> <div id="links"> <a href="/5.39.4/Test2::AsyncSubtest">Test2::AsyncSubtest</a> <div id="more"> (<a href="/5.39.4/Test2::AsyncSubtest.txt">source</a>, <a href="https://metacpan.org/pod/Test2::AsyncSubtest">CPAN</a>) </div> <div id="moduleversion">version 0.000156</div> </div> <div class="leading-notice"> You are viewing the version of this documentation from Perl 5.39.4. This is a development version of Perl. </div> <h1><a id="toc">CONTENTS</a></h1> <ul> <li> <a class="text-decoration-none" href="#NAME">NAME</a> </li> <li> <a class="text-decoration-none" href="#DESCRIPTION">DESCRIPTION</a> </li> <li> <a class="text-decoration-none" href="#SYNOPSIS">SYNOPSIS</a> </li> <li> <a class="text-decoration-none" href="#CONSTRUCTION">CONSTRUCTION</a> </li> <li> <a class="text-decoration-none" href="#METHODS">METHODS</a> <ul> <li> <a class="text-decoration-none" href="#SIMPLE-ACCESSORS">SIMPLE ACCESSORS</a> </li> <li> <a class="text-decoration-none" href="#INTERFACE">INTERFACE</a> </li> </ul> </li> <li> <a class="text-decoration-none" href="#SOURCE">SOURCE</a> </li> <li> <a class="text-decoration-none" href="#MAINTAINERS">MAINTAINERS</a> </li> <li> <a class="text-decoration-none" href="#AUTHORS">AUTHORS</a> </li> <li> <a class="text-decoration-none" href="#COPYRIGHT">COPYRIGHT</a> </li> </ul> <h1 id="NAME"><a class="permalink" href="#NAME">#</a>NAME</h1> <p>Test2::AsyncSubtest - Object representing an async subtest.</p> <h1 id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">#</a>DESCRIPTION</h1> <p>Regular subtests have a limited scope, they start, events are generated, then they close and send an <a href="/5.39.4/Test2::Event::Subtest">Test2::Event::Subtest</a> event. This is a problem if you want the subtest to keep receiving events while other events are also being generated. This class implements subtests that stay open until you decide to close them.</p> <p>This is mainly useful for tools that start a subtest in one process and then spawn children. In many cases it is nice to let the parent process continue instead of waiting on the children.</p> <h1 id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">#</a>SYNOPSIS</h1> <pre><code>use Test2::AsyncSubtest; my $ast = Test2::AsyncSubtest->new(name => foo); $ast->run(sub { ok(1, "Event in parent" ); }); ok(1, "Event outside of subtest"); $ast->run_fork(sub { ok(1, "Event in child process"); }); ... $ast->finish; done_testing;</code></pre> <h1 id="CONSTRUCTION"><a class="permalink" href="#CONSTRUCTION">#</a>CONSTRUCTION</h1> <pre><code>my $ast = Test2::AsyncSubtest->new( ... );</code></pre> <dl> <dt id="name-=>-$name-(required)"><a class="permalink" href="#name-=%3E-$name-(required)">#</a><a id="name"></a><a id="name-name-required"></a>name => $name (required)</dt> <dd> <p>Name of the subtest. This construction argument is required.</p> </dd> <dt id="send_to-=>-$hub-(optional)"><a class="permalink" href="#send_to-=%3E-$hub-(optional)">#</a><a id="send_to"></a><a id="send_to-hub-optional"></a>send_to => $hub (optional)</dt> <dd> <p>Hub to which the final subtest event should be sent. This must be an instance of <a href="/5.39.4/Test2::Hub">Test2::Hub</a> or a subclass. If none is specified then the current top hub will be used.</p> </dd> <dt id="trace-=>-$trace-(optional)"><a class="permalink" href="#trace-=%3E-$trace-(optional)">#</a><a id="trace"></a><a id="trace-trace-optional"></a>trace => $trace (optional)</dt> <dd> <p>File/Line to which errors should be attributed. This must be an instance of <a href="/5.39.4/Test2::Util::Trace">Test2::Util::Trace</a>. If none is specified then the file/line where the constructor was called will be used.</p> </dd> <dt id="hub-=>-$hub-(optional)"><a class="permalink" href="#hub-=%3E-$hub-(optional)">#</a><a id="hub"></a><a id="hub-hub-optional"></a>hub => $hub (optional)</dt> <dd> <p>Use this to specify a hub the subtest should use. By default a new hub is generated. This must be an instance of <a href="/5.39.4/Test2::AsyncSubtest::Hub">Test2::AsyncSubtest::Hub</a>.</p> </dd> </dl> <h1 id="METHODS"><a class="permalink" href="#METHODS">#</a>METHODS</h1> <h2 id="SIMPLE-ACCESSORS"><a class="permalink" href="#SIMPLE-ACCESSORS">#</a><a id="SIMPLE"></a>SIMPLE ACCESSORS</h2> <dl> <dt id="$bool-=-$ast->active"><a class="permalink" href="#$bool-=-$ast-%3Eactive">#</a><a id="bool-ast-active"></a>$bool = $ast->active</dt> <dd> <p>True if the subtest is active. The subtest is active if its hub appears in the global hub stack. This is true when <code>$ast->run(...)</code> us running.</p> </dd> <dt id="$arrayref-=-$ast->children"><a class="permalink" href="#$arrayref-=-$ast-%3Echildren">#</a><a id="arrayref-ast-children"></a>$arrayref = $ast->children</dt> <dd> <p>Get an arrayref of child processes/threads. Numerical items are PIDs, blessed items are <a href="/5.39.4/threads">threads</a> instances.</p> </dd> <dt id="$arrayref-=-$ast->events"><a class="permalink" href="#$arrayref-=-$ast-%3Eevents">#</a><a id="arrayref-ast-events"></a>$arrayref = $ast->events</dt> <dd> <p>Get an arrayref of events that have been sent to the subtests hub.</p> </dd> <dt id="$bool-=-$ast->finished"><a class="permalink" href="#$bool-=-$ast-%3Efinished">#</a><a id="bool-ast-finished"></a>$bool = $ast->finished</dt> <dd> <p>True if <code>finished()</code> has already been called.</p> </dd> <dt id="$hub-=-$ast->hub"><a class="permalink" href="#$hub-=-$ast-%3Ehub">#</a><a id="hub-ast-hub"></a>$hub = $ast->hub</dt> <dd> <p>The hub created for the subtest.</p> </dd> <dt id="$int-=-$ast->id"><a class="permalink" href="#$int-=-$ast-%3Eid">#</a><a id="int-ast-id"></a>$int = $ast->id</dt> <dd> <p>Attach/Detach counter. Used internally, not useful to users.</p> </dd> <dt id="$str-=-$ast->name"><a class="permalink" href="#$str-=-$ast-%3Ename">#</a><a id="str-ast-name"></a>$str = $ast->name</dt> <dd> <p>Name of the subtest.</p> </dd> <dt id="$pid-=-$ast->pid"><a class="permalink" href="#$pid-=-$ast-%3Epid">#</a><a id="pid-ast-pid"></a>$pid = $ast->pid</dt> <dd> <p>PID in which the subtest was created.</p> </dd> <dt id="$tid-=-$ast->tid"><a class="permalink" href="#$tid-=-$ast-%3Etid">#</a><a id="tid-ast-tid"></a>$tid = $ast->tid</dt> <dd> <p>Thread ID in which the subtest was created.</p> </dd> <dt id="$hub-=-$ast->send_to"><a class="permalink" href="#$hub-=-$ast-%3Esend_to">#</a><a id="hub-ast-send_to"></a>$hub = $ast->send_to</dt> <dd> <p>Hub to which the final subtest event should be sent.</p> </dd> <dt id="$arrayref-=-$ast->stack"><a class="permalink" href="#$arrayref-=-$ast-%3Estack">#</a><a id="arrayref-ast-stack"></a>$arrayref = $ast->stack</dt> <dd> <p>Stack of async subtests at the time this one was created. This is mainly for internal use.</p> </dd> <dt id="$trace-=-$ast->trace"><a class="permalink" href="#$trace-=-$ast-%3Etrace">#</a><a id="trace-ast-trace"></a>$trace = $ast->trace</dt> <dd> <p><a href="/5.39.4/Test2::Util::Trace">Test2::Util::Trace</a> instance used for error reporting.</p> </dd> </dl> <h2 id="INTERFACE"><a class="permalink" href="#INTERFACE">#</a>INTERFACE</h2> <dl> <dt id="$ast->attach($id)"><a class="permalink" href="#$ast-%3Eattach($id)">#</a><a id="attach"></a><a id="ast-attach-id"></a>$ast->attach($id)</dt> <dd> <p>Attach a subtest in a child/process to the original.</p> <p><b>Note:</b> <code>my $id = $ast->cleave</code> must have been called in the parent process/thread before the child was started, the id it returns must be used in the call to <code>$ast->attach($id)</code></p> </dd> <dt id="$id-=-$ast->cleave"><a class="permalink" href="#$id-=-$ast-%3Ecleave">#</a><a id="id-ast-cleave"></a>$id = $ast->cleave</dt> <dd> <p>Prepare a slot for a child process/thread to attach. This must be called BEFORE the child process or thread is started. The ID returned is used by <code>attach()</code>.</p> <p>This must only be called in the original process/thread.</p> </dd> <dt id="$ctx-=-$ast->context"><a class="permalink" href="#$ctx-=-$ast-%3Econtext">#</a><a id="ctx-ast-context"></a>$ctx = $ast->context</dt> <dd> <p>Get an <a href="/5.39.4/Test2::API::Context">Test2::API::Context</a> instance that can be used to send events to the context in which the hub was created. This is not a canonical context, you should not call <code>$ctx->release</code> on it.</p> </dd> <dt id="$ast->detach"><a class="permalink" href="#$ast-%3Edetach">#</a><a id="detach"></a><a id="ast-detach"></a>$ast->detach</dt> <dd> <p>Detach from the parent in a child process/thread. This should be called just before the child exits.</p> </dd> <dt id="$ast->finish"><a class="permalink" href="#$ast-%3Efinish">#</a><a id="finish"></a><a id="ast-finish"></a>$ast->finish</dt> <dd> </dd> <dt id="$ast->finish(%options)"><a class="permalink" href="#$ast-%3Efinish(%25options)">#</a><a id="finish1"></a><a id="ast-finish-options"></a>$ast->finish(%options)</dt> <dd> <p>Finish the subtest, wait on children, and send the final subtest event.</p> <p>This must only be called in the original process/thread.</p> <p><b>Note:</b> This calls <code>$ast->wait</code>.</p> <p>These are the options:</p> <dl> <dt id="collapse-=>-1"><a class="permalink" href="#collapse-=%3E-1">#</a><a id="collapse"></a><a id="collapse-1"></a>collapse => 1</dt> <dd> <p>This intelligently allows a subtest to be empty.</p> <p>If no events bump the test count then the subtest no final plan will be added. The subtest will not be considered a failure (normally an empty subtest is a failure).</p> <p>If there are no events at all the subtest will be collapsed into an <a href="/5.39.4/Test2::Event::Ok">Test2::Event::Ok</a> event.</p> </dd> <dt id="silent-=>-1"><a class="permalink" href="#silent-=%3E-1">#</a><a id="silent"></a><a id="silent-1"></a>silent => 1</dt> <dd> <p>This will prevent finish from generating a final <a href="/5.39.4/Test2::Event::Subtest">Test2::Event::Subtest</a> event. This effectively ends the subtest without it effecting the parent subtest (or top level test).</p> </dd> <dt id="no_plan-=>-1"><a class="permalink" href="#no_plan-=%3E-1">#</a><a id="no_plan"></a><a id="no_plan-1"></a>no_plan => 1</dt> <dd> <p>This will prevent a final plan from being added to the subtest for you when none is directly specified.</p> </dd> <dt id="skip-=>-"reason""><a class="permalink" href="#skip-=%3E-%22reason%22">#</a><a id="skip"></a><a id="skip-reason"></a>skip => "reason"</dt> <dd> <p>This will issue an <a href="/5.39.4/Test2::Event::Skip">Test2::Event::Skip</a> instead of a subtest. This will throw an exception if any events have been seen, or if state implies events have occurred.</p> </dd> </dl> </dd> <dt id="$out-=-$ast->fork"><a class="permalink" href="#$out-=-$ast-%3Efork">#</a><a id="out-ast-fork"></a>$out = $ast->fork</dt> <dd> <p>This is a slightly higher level interface to fork. Running it will fork your code in-place just like <code>fork()</code>. It will return a pid in the parent, and an <a href="/5.39.4/Test2::Util::Guard">Test2::Util::Guard</a> instance in the child. An exception will be thrown if fork fails.</p> <p>It is recommended that you use <code>$ast->run_fork(sub { ... })</code> instead.</p> </dd> <dt id="$bool-=-$ast->pending"><a class="permalink" href="#$bool-=-$ast-%3Epending">#</a><a id="bool-ast-pending"></a>$bool = $ast->pending</dt> <dd> <p>True if there are child processes, threads, or subtests that depend on this one.</p> </dd> <dt id="$bool-=-$ast->ready"><a class="permalink" href="#$bool-=-$ast-%3Eready">#</a><a id="bool-ast-ready"></a>$bool = $ast->ready</dt> <dd> <p>This is essentially <code>!$ast->pending</code>.</p> </dd> <dt id="$ast->run(sub-{-...-})"><a class="permalink" href="#$ast-%3Erun(sub-%7B-...-%7D)">#</a><a id="run"></a><a id="ast-run-sub"></a>$ast->run(sub { ... })</dt> <dd> <p>Run the provided codeblock inside the subtest. This will push the subtest hub onto the stack, run the code, then pop the hub off the stack.</p> </dd> <dt id="$pid-=-$ast->run_fork(sub-{-...-})"><a class="permalink" href="#$pid-=-$ast-%3Erun_fork(sub-%7B-...-%7D)">#</a><a id="pid-ast-run_fork-sub"></a>$pid = $ast->run_fork(sub { ... })</dt> <dd> <p>Same as <code>$ast->run()</code>, except that the codeblock is run in a child process.</p> <p>You do not need to directly call <code>wait($pid)</code>, that will be done for you when <code>$ast->wait</code>, or <code>$ast->finish</code> are called.</p> </dd> <dt id="my-$thr-=-$ast->run_thread(sub-{-...-});"><a class="permalink" href="#my-$thr-=-$ast-%3Erun_thread(sub-%7B-...-%7D);">#</a><a id="my"></a><a id="my-thr-ast-run_thread-sub"></a>my $thr = $ast->run_thread(sub { ... });</dt> <dd> <p><b>** DISCOURAGED **</b> Threads cause problems. This method remains for anyone who REALLY wants it, but it is no longer supported. Tests for this functionality do not even run unless the AUTHOR_TESTING or T2_DO_THREAD_TESTS env vars are enabled.</p> <p>Same as <code>$ast->run()</code>, except that the codeblock is run in a child thread.</p> <p>You do not need to directly call <code>$thr->join</code>, that is done for you when <code>$ast->wait</code>, or <code>$ast->finish</code> are called.</p> </dd> <dt id="$passing-=-$ast->start"><a class="permalink" href="#$passing-=-$ast-%3Estart">#</a><a id="passing-ast-start"></a>$passing = $ast->start</dt> <dd> <p>Push the subtest hub onto the stack. Returns the current pass/fail status of the subtest.</p> </dd> <dt id="$ast->stop"><a class="permalink" href="#$ast-%3Estop">#</a><a id="stop"></a><a id="ast-stop"></a>$ast->stop</dt> <dd> <p>Pop the subtest hub off the stack. Returns the current pass/fail status of the subtest.</p> </dd> <dt id="$ast->wait"><a class="permalink" href="#$ast-%3Ewait">#</a><a id="wait"></a><a id="ast-wait"></a>$ast->wait</dt> <dd> <p>Wait on all threads/processes that were started using <code>$ast->fork</code>, <code>$ast->run_fork</code>, or <code>$ast->run_thread</code>.</p> </dd> </dl> <h1 id="SOURCE"><a class="permalink" href="#SOURCE">#</a>SOURCE</h1> <p>The source code repository for Test2-AsyncSubtest can be found at <i>https://github.com/Test-More/Test2-Suite/</i>.</p> <h1 id="MAINTAINERS"><a class="permalink" href="#MAINTAINERS">#</a>MAINTAINERS</h1> <dl> <dt id="Chad-Granum-<exodist@cpan.org>"><a class="permalink" href="#Chad-Granum-%3Cexodist@cpan.org%3E">#</a><a id="Chad"></a><a id="Chad-Granum-exodist-cpan.org"></a>Chad Granum <exodist@cpan.org></dt> <dd> </dd> </dl> <h1 id="AUTHORS"><a class="permalink" href="#AUTHORS">#</a>AUTHORS</h1> <dl> <dt id="Chad-Granum-<exodist@cpan.org>1"><a class="permalink" href="#Chad-Granum-%3Cexodist@cpan.org%3E1">#</a><a id="Chad1"></a><a id="Chad-Granum-exodist-cpan.org1"></a>Chad Granum <exodist@cpan.org></dt> <dd> </dd> </dl> <h1 id="COPYRIGHT"><a class="permalink" href="#COPYRIGHT">#</a>COPYRIGHT</h1> <p>Copyright 2018 Chad Granum <exodist7@gmail.com>.</p> <p>This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p> <p>See <i>http://dev.perl.org/licenses/</i></p> </div> <div id="footer"> <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p> <p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script> <script src="/js/highlight.pack.js"></script> <script>hljs.highlightAll();</script> </body> </html>