1package Test2::API; 2use strict; 3use warnings; 4 5use Test2::Util qw/USE_THREADS/; 6 7BEGIN { 8 $ENV{TEST_ACTIVE} ||= 1; 9 $ENV{TEST2_ACTIVE} = 1; 10} 11 12our $VERSION = '1.302162'; 13 14 15my $INST; 16my $ENDING = 0; 17sub test2_set_is_end { ($ENDING) = @_ ? @_ : (1) } 18sub test2_get_is_end { $ENDING } 19 20use Test2::API::Instance(\$INST); 21 22# Set the exit status 23END { 24 test2_set_is_end(); # See gh #16 25 $INST->set_exit(); 26} 27 28sub CLONE { 29 my $init = test2_init_done(); 30 my $load = test2_load_done(); 31 32 return if $init && $load; 33 34 require Carp; 35 Carp::croak "Test2 must be fully loaded before you start a new thread!\n"; 36} 37 38# See gh #16 39{ 40 no warnings; 41 INIT { eval 'END { test2_set_is_end() }; 1' or die $@ } 42} 43 44BEGIN { 45 no warnings 'once'; 46 if($] ge '5.014' || $ENV{T2_CHECK_DEPTH} || $Test2::API::DO_DEPTH_CHECK) { 47 *DO_DEPTH_CHECK = sub() { 1 }; 48 } 49 else { 50 *DO_DEPTH_CHECK = sub() { 0 }; 51 } 52} 53 54use Test2::EventFacet::Trace(); 55use Test2::Util::Trace(); # Legacy 56 57use Test2::Hub::Subtest(); 58use Test2::Hub::Interceptor(); 59use Test2::Hub::Interceptor::Terminator(); 60 61use Test2::Event::Ok(); 62use Test2::Event::Diag(); 63use Test2::Event::Note(); 64use Test2::Event::Plan(); 65use Test2::Event::Bail(); 66use Test2::Event::Exception(); 67use Test2::Event::Waiting(); 68use Test2::Event::Skip(); 69use Test2::Event::Subtest(); 70 71use Carp qw/carp croak confess/; 72use Scalar::Util qw/blessed weaken/; 73use Test2::Util qw/get_tid clone_io pkg_to_file gen_uid/; 74 75our @EXPORT_OK = qw{ 76 context release 77 context_do 78 no_context 79 intercept intercept_deep 80 run_subtest 81 82 test2_init_done 83 test2_load_done 84 test2_load 85 test2_start_preload 86 test2_stop_preload 87 test2_in_preload 88 89 test2_set_is_end 90 test2_get_is_end 91 92 test2_pid 93 test2_tid 94 test2_stack 95 test2_no_wait 96 test2_ipc_wait_enable 97 test2_ipc_wait_disable 98 test2_ipc_wait_enabled 99 100 test2_add_uuid_via 101 102 test2_add_callback_testing_done 103 104 test2_add_callback_context_aquire 105 test2_add_callback_context_acquire 106 test2_add_callback_context_init 107 test2_add_callback_context_release 108 test2_add_callback_exit 109 test2_add_callback_post_load 110 test2_add_callback_pre_subtest 111 test2_list_context_aquire_callbacks 112 test2_list_context_acquire_callbacks 113 test2_list_context_init_callbacks 114 test2_list_context_release_callbacks 115 test2_list_exit_callbacks 116 test2_list_post_load_callbacks 117 test2_list_pre_subtest_callbacks 118 119 test2_ipc 120 test2_has_ipc 121 test2_ipc_disable 122 test2_ipc_disabled 123 test2_ipc_drivers 124 test2_ipc_add_driver 125 test2_ipc_polling 126 test2_ipc_disable_polling 127 test2_ipc_enable_polling 128 test2_ipc_get_pending 129 test2_ipc_set_pending 130 test2_ipc_get_timeout 131 test2_ipc_set_timeout 132 133 test2_formatter 134 test2_formatters 135 test2_formatter_add 136 test2_formatter_set 137 138 test2_stdout 139 test2_stderr 140 test2_reset_io 141}; 142BEGIN { require Exporter; our @ISA = qw(Exporter) } 143 144my $STACK = $INST->stack; 145my $CONTEXTS = $INST->contexts; 146my $INIT_CBS = $INST->context_init_callbacks; 147my $ACQUIRE_CBS = $INST->context_acquire_callbacks; 148 149my $STDOUT = clone_io(\*STDOUT); 150my $STDERR = clone_io(\*STDERR); 151sub test2_stdout { $STDOUT ||= clone_io(\*STDOUT) } 152sub test2_stderr { $STDERR ||= clone_io(\*STDERR) } 153 154sub test2_post_preload_reset { 155 test2_reset_io(); 156 $INST->post_preload_reset; 157} 158 159sub test2_reset_io { 160 $STDOUT = clone_io(\*STDOUT); 161 $STDERR = clone_io(\*STDERR); 162} 163 164sub test2_init_done { $INST->finalized } 165sub test2_load_done { $INST->loaded } 166 167sub test2_load { $INST->load } 168sub test2_start_preload { $ENV{T2_IN_PRELOAD} = 1; $INST->start_preload } 169sub test2_stop_preload { $ENV{T2_IN_PRELOAD} = 0; $INST->stop_preload } 170sub test2_in_preload { $INST->preload } 171 172sub test2_pid { $INST->pid } 173sub test2_tid { $INST->tid } 174sub test2_stack { $INST->stack } 175sub test2_ipc_wait_enable { $INST->set_no_wait(0) } 176sub test2_ipc_wait_disable { $INST->set_no_wait(1) } 177sub test2_ipc_wait_enabled { !$INST->no_wait } 178 179sub test2_no_wait { 180 $INST->set_no_wait(@_) if @_; 181 $INST->no_wait; 182} 183 184sub test2_add_callback_testing_done { 185 my $cb = shift; 186 187 test2_add_callback_post_load(sub { 188 my $stack = test2_stack(); 189 $stack->top; # Insure we have a hub 190 my ($hub) = Test2::API::test2_stack->all; 191 192 $hub->set_active(1); 193 194 $hub->follow_up($cb); 195 }); 196 197 return; 198} 199 200sub test2_add_callback_context_acquire { $INST->add_context_acquire_callback(@_) } 201sub test2_add_callback_context_aquire { $INST->add_context_acquire_callback(@_) } 202sub test2_add_callback_context_init { $INST->add_context_init_callback(@_) } 203sub test2_add_callback_context_release { $INST->add_context_release_callback(@_) } 204sub test2_add_callback_exit { $INST->add_exit_callback(@_) } 205sub test2_add_callback_post_load { $INST->add_post_load_callback(@_) } 206sub test2_add_callback_pre_subtest { $INST->add_pre_subtest_callback(@_) } 207sub test2_list_context_aquire_callbacks { @{$INST->context_acquire_callbacks} } 208sub test2_list_context_acquire_callbacks { @{$INST->context_acquire_callbacks} } 209sub test2_list_context_init_callbacks { @{$INST->context_init_callbacks} } 210sub test2_list_context_release_callbacks { @{$INST->context_release_callbacks} } 211sub test2_list_exit_callbacks { @{$INST->exit_callbacks} } 212sub test2_list_post_load_callbacks { @{$INST->post_load_callbacks} } 213sub test2_list_pre_subtest_callbacks { @{$INST->pre_subtest_callbacks} } 214 215sub test2_add_uuid_via { 216 $INST->set_add_uuid_via(@_) if @_; 217 $INST->add_uuid_via(); 218} 219 220sub test2_ipc { $INST->ipc } 221sub test2_has_ipc { $INST->has_ipc } 222sub test2_ipc_disable { $INST->ipc_disable } 223sub test2_ipc_disabled { $INST->ipc_disabled } 224sub test2_ipc_add_driver { $INST->add_ipc_driver(@_) } 225sub test2_ipc_drivers { @{$INST->ipc_drivers} } 226sub test2_ipc_polling { $INST->ipc_polling } 227sub test2_ipc_enable_polling { $INST->enable_ipc_polling } 228sub test2_ipc_disable_polling { $INST->disable_ipc_polling } 229sub test2_ipc_get_pending { $INST->get_ipc_pending } 230sub test2_ipc_set_pending { $INST->set_ipc_pending(@_) } 231sub test2_ipc_set_timeout { $INST->set_ipc_timeout(@_) } 232sub test2_ipc_get_timeout { $INST->ipc_timeout() } 233sub test2_ipc_enable_shm { 0 } 234 235sub test2_formatter { 236 if ($ENV{T2_FORMATTER} && $ENV{T2_FORMATTER} =~ m/^(\+)?(.*)$/) { 237 my $formatter = $1 ? $2 : "Test2::Formatter::$2"; 238 my $file = pkg_to_file($formatter); 239 require $file; 240 return $formatter; 241 } 242 243 return $INST->formatter; 244} 245 246sub test2_formatters { @{$INST->formatters} } 247sub test2_formatter_add { $INST->add_formatter(@_) } 248sub test2_formatter_set { 249 my ($formatter) = @_; 250 croak "No formatter specified" unless $formatter; 251 croak "Global Formatter already set" if $INST->formatter_set; 252 $INST->set_formatter($formatter); 253} 254 255# Private, for use in Test2::API::Context 256sub _contexts_ref { $INST->contexts } 257sub _context_acquire_callbacks_ref { $INST->context_acquire_callbacks } 258sub _context_init_callbacks_ref { $INST->context_init_callbacks } 259sub _context_release_callbacks_ref { $INST->context_release_callbacks } 260sub _add_uuid_via_ref { \($INST->{Test2::API::Instance::ADD_UUID_VIA()}) } 261 262# Private, for use in Test2::IPC 263sub _set_ipc { $INST->set_ipc(@_) } 264 265sub context_do(&;@) { 266 my $code = shift; 267 my @args = @_; 268 269 my $ctx = context(level => 1); 270 271 my $want = wantarray; 272 273 my @out; 274 my $ok = eval { 275 $want ? @out = $code->($ctx, @args) : 276 defined($want) ? $out[0] = $code->($ctx, @args) : 277 $code->($ctx, @args) ; 278 1; 279 }; 280 my $err = $@; 281 282 $ctx->release; 283 284 die $err unless $ok; 285 286 return @out if $want; 287 return $out[0] if defined $want; 288 return; 289} 290 291sub no_context(&;$) { 292 my ($code, $hid) = @_; 293 $hid ||= $STACK->top->hid; 294 295 my $ctx = $CONTEXTS->{$hid}; 296 delete $CONTEXTS->{$hid}; 297 my $ok = eval { $code->(); 1 }; 298 my $err = $@; 299 300 $CONTEXTS->{$hid} = $ctx; 301 weaken($CONTEXTS->{$hid}); 302 303 die $err unless $ok; 304 305 return; 306}; 307 308my $UUID_VIA = _add_uuid_via_ref(); 309sub context { 310 # We need to grab these before anything else to ensure they are not 311 # changed. 312 my ($errno, $eval_error, $child_error, $extended_error) = (0 + $!, $@, $?, $^E); 313 314 my %params = (level => 0, wrapped => 0, @_); 315 316 # If something is getting a context then the sync system needs to be 317 # considered loaded... 318 $INST->load unless $INST->{loaded}; 319 320 croak "context() called, but return value is ignored" 321 unless defined wantarray; 322 323 my $stack = $params{stack} || $STACK; 324 my $hub = $params{hub} || (@$stack ? $stack->[-1] : $stack->top); 325 my $hid = $hub->{hid}; 326 my $current = $CONTEXTS->{$hid}; 327 328 $_->(\%params) for @$ACQUIRE_CBS; 329 map $_->(\%params), @{$hub->{_context_acquire}} if $hub->{_context_acquire}; 330 331 # This is for https://github.com/Test-More/test-more/issues/16 332 # and https://rt.perl.org/Public/Bug/Display.html?id=127774 333 my $phase = ${^GLOBAL_PHASE} || 'NA'; 334 my $end_phase = $ENDING || $phase eq 'END' || $phase eq 'DESTRUCT'; 335 336 my $level = 1 + $params{level}; 337 my ($pkg, $file, $line, $sub) = $end_phase ? caller(0) : caller($level); 338 unless ($pkg || $end_phase) { 339 confess "Could not find context at depth $level" unless $params{fudge}; 340 ($pkg, $file, $line, $sub) = caller(--$level) while ($level >= 0 && !$pkg); 341 } 342 343 my $depth = $level; 344 $depth++ while DO_DEPTH_CHECK && !$end_phase && (!$current || $depth <= $current->{_depth} + $params{wrapped}) && caller($depth + 1); 345 $depth -= $params{wrapped}; 346 my $depth_ok = !DO_DEPTH_CHECK || $end_phase || !$current || $current->{_depth} < $depth; 347 348 if ($current && $params{on_release} && $depth_ok) { 349 $current->{_on_release} ||= []; 350 push @{$current->{_on_release}} => $params{on_release}; 351 } 352 353 # I know this is ugly.... 354 ($!, $@, $?, $^E) = ($errno, $eval_error, $child_error, $extended_error) and return bless( 355 { 356 %$current, 357 _is_canon => undef, 358 errno => $errno, 359 eval_error => $eval_error, 360 child_error => $child_error, 361 _is_spawn => [$pkg, $file, $line, $sub], 362 }, 363 'Test2::API::Context' 364 ) if $current && $depth_ok; 365 366 # Handle error condition of bad level 367 if ($current) { 368 unless (${$current->{_aborted}}) { 369 _canon_error($current, [$pkg, $file, $line, $sub, $depth]) 370 unless $current->{_is_canon}; 371 372 _depth_error($current, [$pkg, $file, $line, $sub, $depth]) 373 unless $depth_ok; 374 } 375 376 $current->release if $current->{_is_canon}; 377 378 delete $CONTEXTS->{$hid}; 379 } 380 381 # Directly bless the object here, calling new is a noticeable performance 382 # hit with how often this needs to be called. 383 my $trace = bless( 384 { 385 frame => [$pkg, $file, $line, $sub], 386 pid => $$, 387 tid => get_tid(), 388 cid => gen_uid(), 389 hid => $hid, 390 nested => $hub->{nested}, 391 buffered => $hub->{buffered}, 392 393 $$UUID_VIA ? ( 394 huuid => $hub->{uuid}, 395 uuid => ${$UUID_VIA}->('context'), 396 ) : (), 397 }, 398 'Test2::EventFacet::Trace' 399 ); 400 401 # Directly bless the object here, calling new is a noticeable performance 402 # hit with how often this needs to be called. 403 my $aborted = 0; 404 $current = bless( 405 { 406 _aborted => \$aborted, 407 stack => $stack, 408 hub => $hub, 409 trace => $trace, 410 _is_canon => 1, 411 _depth => $depth, 412 errno => $errno, 413 eval_error => $eval_error, 414 child_error => $child_error, 415 $params{on_release} ? (_on_release => [$params{on_release}]) : (), 416 }, 417 'Test2::API::Context' 418 ); 419 420 $CONTEXTS->{$hid} = $current; 421 weaken($CONTEXTS->{$hid}); 422 423 $_->($current) for @$INIT_CBS; 424 map $_->($current), @{$hub->{_context_init}} if $hub->{_context_init}; 425 426 $params{on_init}->($current) if $params{on_init}; 427 428 ($!, $@, $?, $^E) = ($errno, $eval_error, $child_error, $extended_error); 429 430 return $current; 431} 432 433sub _depth_error { 434 _existing_error(@_, <<" EOT"); 435context() was called to retrieve an existing context, however the existing 436context was created in a stack frame at the same, or deeper level. This usually 437means that a tool failed to release the context when it was finished. 438 EOT 439} 440 441sub _canon_error { 442 _existing_error(@_, <<" EOT"); 443context() was called to retrieve an existing context, however the existing 444context has an invalid internal state (!_canon_count). This should not normally 445happen unless something is mucking about with internals... 446 EOT 447} 448 449sub _existing_error { 450 my ($ctx, $details, $msg) = @_; 451 my ($pkg, $file, $line, $sub, $depth) = @$details; 452 453 my $oldframe = $ctx->{trace}->frame; 454 my $olddepth = $ctx->{_depth}; 455 456 # Older versions of Carp do not export longmess() function, so it needs to be called with package name 457 my $mess = Carp::longmess(); 458 459 warn <<" EOT"; 460$msg 461Old context details: 462 File: $oldframe->[1] 463 Line: $oldframe->[2] 464 Tool: $oldframe->[3] 465 Depth: $olddepth 466 467New context details: 468 File: $file 469 Line: $line 470 Tool: $sub 471 Depth: $depth 472 473Trace: $mess 474 475Removing the old context and creating a new one... 476 EOT 477} 478 479sub release($;$) { 480 $_[0]->release; 481 return $_[1]; 482} 483 484sub intercept(&) { 485 my $code = shift; 486 my $ctx = context(); 487 488 my $events = _intercept($code, deep => 0); 489 490 $ctx->release; 491 492 return $events; 493} 494 495sub intercept_deep(&) { 496 my $code = shift; 497 my $ctx = context(); 498 499 my $events = _intercept($code, deep => 1); 500 501 $ctx->release; 502 503 return $events; 504} 505 506sub _intercept { 507 my $code = shift; 508 my %params = @_; 509 my $ctx = context(); 510 511 my $ipc; 512 if (my $global_ipc = test2_ipc()) { 513 my $driver = blessed($global_ipc); 514 $ipc = $driver->new; 515 } 516 517 my $hub = Test2::Hub::Interceptor->new( 518 ipc => $ipc, 519 no_ending => 1, 520 ); 521 522 my @events; 523 $hub->listen(sub { push @events => $_[1] }, inherit => $params{deep}); 524 525 $ctx->stack->top; # Make sure there is a top hub before we begin. 526 $ctx->stack->push($hub); 527 528 my ($ok, $err) = (1, undef); 529 T2_SUBTEST_WRAPPER: { 530 # Do not use 'try' cause it localizes __DIE__ 531 $ok = eval { $code->(hub => $hub, context => $ctx->snapshot); 1 }; 532 $err = $@; 533 534 # They might have done 'BEGIN { skip_all => "whatever" }' 535 if (!$ok && $err =~ m/Label not found for "last T2_SUBTEST_WRAPPER"/ || (blessed($err) && $err->isa('Test2::Hub::Interceptor::Terminator'))) { 536 $ok = 1; 537 $err = undef; 538 } 539 } 540 541 $hub->cull; 542 $ctx->stack->pop($hub); 543 544 my $trace = $ctx->trace; 545 $ctx->release; 546 547 die $err unless $ok; 548 549 $hub->finalize($trace, 1) 550 if $ok 551 && !$hub->no_ending 552 && !$hub->ended; 553 554 return \@events; 555} 556 557sub run_subtest { 558 my ($name, $code, $params, @args) = @_; 559 560 $_->($name,$code,@args) 561 for Test2::API::test2_list_pre_subtest_callbacks(); 562 563 $params = {buffered => $params} unless ref $params; 564 my $inherit_trace = delete $params->{inherit_trace}; 565 566 my $ctx = context(); 567 568 my $parent = $ctx->hub; 569 570 # If a parent is buffered then the child must be as well. 571 my $buffered = $params->{buffered} || $parent->{buffered}; 572 573 $ctx->note($name) unless $buffered; 574 575 my $stack = $ctx->stack || $STACK; 576 my $hub = $stack->new_hub( 577 class => 'Test2::Hub::Subtest', 578 %$params, 579 buffered => $buffered, 580 ); 581 582 my @events; 583 $hub->listen(sub { push @events => $_[1] }); 584 585 if ($buffered) { 586 if (my $format = $hub->format) { 587 my $hide = $format->can('hide_buffered') ? $format->hide_buffered : 1; 588 $hub->format(undef) if $hide; 589 } 590 } 591 592 if ($inherit_trace) { 593 my $orig = $code; 594 $code = sub { 595 my $base_trace = $ctx->trace; 596 my $trace = $base_trace->snapshot(nested => 1 + $base_trace->nested); 597 my $st_ctx = Test2::API::Context->new( 598 trace => $trace, 599 hub => $hub, 600 ); 601 $st_ctx->do_in_context($orig, @args); 602 }; 603 } 604 605 my ($ok, $err, $finished); 606 T2_SUBTEST_WRAPPER: { 607 # Do not use 'try' cause it localizes __DIE__ 608 $ok = eval { $code->(@args); 1 }; 609 $err = $@; 610 611 # They might have done 'BEGIN { skip_all => "whatever" }' 612 if (!$ok && $err =~ m/Label not found for "last T2_SUBTEST_WRAPPER"/ || (blessed($err) && blessed($err) eq 'Test::Builder::Exception')) { 613 $ok = undef; 614 $err = undef; 615 } 616 else { 617 $finished = 1; 618 } 619 } 620 621 if ($params->{no_fork}) { 622 if ($$ != $ctx->trace->pid) { 623 warn $ok ? "Forked inside subtest, but subtest never finished!\n" : $err; 624 exit 255; 625 } 626 627 if (get_tid() != $ctx->trace->tid) { 628 warn $ok ? "Started new thread inside subtest, but thread never finished!\n" : $err; 629 exit 255; 630 } 631 } 632 elsif (!$parent->is_local && !$parent->ipc) { 633 warn $ok ? "A new process or thread was started inside subtest, but IPC is not enabled!\n" : $err; 634 exit 255; 635 } 636 637 $stack->pop($hub); 638 639 my $trace = $ctx->trace; 640 641 my $bailed = $hub->bailed_out; 642 643 if (!$finished) { 644 if ($bailed && !$buffered) { 645 $ctx->bail($bailed->reason); 646 } 647 elsif ($bailed && $buffered) { 648 $ok = 1; 649 } 650 else { 651 my $code = $hub->exit_code; 652 $ok = !$code; 653 $err = "Subtest ended with exit code $code" if $code; 654 } 655 } 656 657 $hub->finalize($trace->snapshot(huuid => $hub->uuid, hid => $hub->hid, nested => $hub->nested, buffered => $buffered), 1) 658 if $ok 659 && !$hub->no_ending 660 && !$hub->ended; 661 662 my $pass = $ok && $hub->is_passing; 663 my $e = $ctx->build_event( 664 'Subtest', 665 pass => $pass, 666 name => $name, 667 subtest_id => $hub->id, 668 subtest_uuid => $hub->uuid, 669 buffered => $buffered, 670 subevents => \@events, 671 ); 672 673 my $plan_ok = $hub->check_plan; 674 675 $ctx->hub->send($e); 676 677 $ctx->failure_diag($e) unless $e->pass; 678 679 $ctx->diag("Caught exception in subtest: $err") unless $ok; 680 681 $ctx->diag("Bad subtest plan, expected " . $hub->plan . " but ran " . $hub->count) 682 if defined($plan_ok) && !$plan_ok; 683 684 $ctx->bail($bailed->reason) if $bailed && $buffered; 685 686 $ctx->release; 687 return $pass; 688} 689 690# There is a use-cycle between API and API/Context. Context needs to use some 691# API functions as the package is compiling. Test2::API::context() needs 692# Test2::API::Context to be loaded, but we cannot 'require' the module there as 693# it causes a very noticeable performance impact with how often context() is 694# called. 695require Test2::API::Context; 696 6971; 698 699__END__ 700 701=pod 702 703=encoding UTF-8 704 705=head1 NAME 706 707Test2::API - Primary interface for writing Test2 based testing tools. 708 709=head1 ***INTERNALS NOTE*** 710 711B<The internals of this package are subject to change at any time!> The public 712methods provided will not change in backwards-incompatible ways (once there is 713a stable release), but the underlying implementation details might. 714B<Do not break encapsulation here!> 715 716Currently the implementation is to create a single instance of the 717L<Test2::API::Instance> Object. All class methods defer to the single 718instance. There is no public access to the singleton, and that is intentional. 719The class methods provided by this package provide the only functionality 720publicly exposed. 721 722This is done primarily to avoid the problems Test::Builder had by exposing its 723singleton. We do not want anyone to replace this singleton, rebless it, or 724directly muck with its internals. If you need to do something and cannot 725because of the restrictions placed here, then please report it as an issue. If 726possible, we will create a way for you to implement your functionality without 727exposing things that should not be exposed. 728 729=head1 DESCRIPTION 730 731This package exports all the functions necessary to write and/or verify testing 732tools. Using these building blocks you can begin writing test tools very 733quickly. You are also provided with tools that help you to test the tools you 734write. 735 736=head1 SYNOPSIS 737 738=head2 WRITING A TOOL 739 740The C<context()> method is your primary interface into the Test2 framework. 741 742 package My::Ok; 743 use Test2::API qw/context/; 744 745 our @EXPORT = qw/my_ok/; 746 use base 'Exporter'; 747 748 # Just like ok() from Test::More 749 sub my_ok($;$) { 750 my ($bool, $name) = @_; 751 my $ctx = context(); # Get a context 752 $ctx->ok($bool, $name); 753 $ctx->release; # Release the context 754 return $bool; 755 } 756 757See L<Test2::API::Context> for a list of methods available on the context object. 758 759=head2 TESTING YOUR TOOLS 760 761The C<intercept { ... }> tool lets you temporarily intercept all events 762generated by the test system: 763 764 use Test2::API qw/intercept/; 765 766 use My::Ok qw/my_ok/; 767 768 my $events = intercept { 769 # These events are not displayed 770 my_ok(1, "pass"); 771 my_ok(0, "fail"); 772 }; 773 774 my_ok(@$events == 2, "got 2 events, the pass and the fail"); 775 my_ok($events->[0]->pass, "first event passed"); 776 my_ok(!$events->[1]->pass, "second event failed"); 777 778=head3 DEEP EVENT INTERCEPTION 779 780Normally C<intercept { ... }> only intercepts events sent to the main hub (as 781added by intercept itself). Nested hubs, such as those created by subtests, 782will not be intercepted. This is normally what you will still see the nested 783events by inspecting the subtest event. However there are times where you want 784to verify each event as it is sent, in that case use C<intercept_deep { ... }>. 785 786 my $events = intercept_Deep { 787 buffered_subtest foo => sub { 788 ok(1, "pass"); 789 }; 790 }; 791 792C<$events> in this case will contain 3 items: 793 794=over 4 795 796=item The event from C<ok(1, "pass")> 797 798=item The plan event for the subtest 799 800=item The subtest event itself, with the first 2 events nested inside it as children. 801 802=back 803 804This lets you see the order in which the events were sent, unlike 805C<intercept { ... }> which only lets you see events as the main hub sees them. 806 807=head2 OTHER API FUNCTIONS 808 809 use Test2::API qw{ 810 test2_init_done 811 test2_stack 812 test2_set_is_end 813 test2_get_is_end 814 test2_ipc 815 test2_formatter_set 816 test2_formatter 817 }; 818 819 my $init = test2_init_done(); 820 my $stack = test2_stack(); 821 my $ipc = test2_ipc(); 822 823 test2_formatter_set($FORMATTER) 824 my $formatter = test2_formatter(); 825 826 ... And others ... 827 828=head1 MAIN API EXPORTS 829 830All exports are optional. You must specify subs to import. 831 832 use Test2::API qw/context intercept run_subtest/; 833 834This is the list of exports that are most commonly needed. If you are simply 835writing a tool, then this is probably all you need. If you need something and 836you cannot find it here, then you can also look at L</OTHER API EXPORTS>. 837 838These exports lack the 'test2_' prefix because of how important/common they 839are. Exports in the L</OTHER API EXPORTS> section have the 'test2_' prefix to 840ensure they stand out. 841 842=head2 context(...) 843 844Usage: 845 846=over 4 847 848=item $ctx = context() 849 850=item $ctx = context(%params) 851 852=back 853 854The C<context()> function will always return the current context. If 855there is already a context active, it will be returned. If there is not an 856active context, one will be generated. When a context is generated it will 857default to using the file and line number where the currently running sub was 858called from. 859 860Please see L<Test2::API::Context/"CRITICAL DETAILS"> for important rules about 861what you can and cannot do with a context once it is obtained. 862 863B<Note> This function will throw an exception if you ignore the context object 864it returns. 865 866B<Note> On perls 5.14+ a depth check is used to insure there are no context 867leaks. This cannot be safely done on older perls due to 868L<https://rt.perl.org/Public/Bug/Display.html?id=127774> 869You can forcefully enable it either by setting C<$ENV{T2_CHECK_DEPTH} = 1> or 870C<$Test2::API::DO_DEPTH_CHECK = 1> B<BEFORE> loading L<Test2::API>. 871 872=head3 OPTIONAL PARAMETERS 873 874All parameters to C<context> are optional. 875 876=over 4 877 878=item level => $int 879 880If you must obtain a context in a sub deeper than your entry point you can use 881this to tell it how many EXTRA stack frames to look back. If this option is not 882provided the default of C<0> is used. 883 884 sub third_party_tool { 885 my $sub = shift; 886 ... # Does not obtain a context 887 $sub->(); 888 ... 889 } 890 891 third_party_tool(sub { 892 my $ctx = context(level => 1); 893 ... 894 $ctx->release; 895 }); 896 897=item wrapped => $int 898 899Use this if you need to write your own tool that wraps a call to C<context()> 900with the intent that it should return a context object. 901 902 sub my_context { 903 my %params = ( wrapped => 0, @_ ); 904 $params{wrapped}++; 905 my $ctx = context(%params); 906 ... 907 return $ctx; 908 } 909 910 sub my_tool { 911 my $ctx = my_context(); 912 ... 913 $ctx->release; 914 } 915 916If you do not do this, then tools you call that also check for a context will 917notice that the context they grabbed was created at the same stack depth, which 918will trigger protective measures that warn you and destroy the existing 919context. 920 921=item stack => $stack 922 923Normally C<context()> looks at the global hub stack. If you are maintaining 924your own L<Test2::API::Stack> instance you may pass it in to be used 925instead of the global one. 926 927=item hub => $hub 928 929Use this parameter if you want to obtain the context for a specific hub instead 930of whatever one happens to be at the top of the stack. 931 932=item on_init => sub { ... } 933 934This lets you provide a callback sub that will be called B<ONLY> if your call 935to C<context()> generated a new context. The callback B<WILL NOT> be called if 936C<context()> is returning an existing context. The only argument passed into 937the callback will be the context object itself. 938 939 sub foo { 940 my $ctx = context(on_init => sub { 'will run' }); 941 942 my $inner = sub { 943 # This callback is not run since we are getting the existing 944 # context from our parent sub. 945 my $ctx = context(on_init => sub { 'will NOT run' }); 946 $ctx->release; 947 } 948 $inner->(); 949 950 $ctx->release; 951 } 952 953=item on_release => sub { ... } 954 955This lets you provide a callback sub that will be called when the context 956instance is released. This callback will be added to the returned context even 957if an existing context is returned. If multiple calls to context add callbacks, 958then all will be called in reverse order when the context is finally released. 959 960 sub foo { 961 my $ctx = context(on_release => sub { 'will run second' }); 962 963 my $inner = sub { 964 my $ctx = context(on_release => sub { 'will run first' }); 965 966 # Neither callback runs on this release 967 $ctx->release; 968 } 969 $inner->(); 970 971 # Both callbacks run here. 972 $ctx->release; 973 } 974 975=back 976 977=head2 release($;$) 978 979Usage: 980 981=over 4 982 983=item release $ctx; 984 985=item release $ctx, ...; 986 987=back 988 989This is intended as a shortcut that lets you release your context and return a 990value in one statement. This function will get your context, and an optional 991return value. It will release your context, then return your value. Scalar 992context is always assumed. 993 994 sub tool { 995 my $ctx = context(); 996 ... 997 998 return release $ctx, 1; 999 } 1000 1001This tool is most useful when you want to return the value you get from calling 1002a function that needs to see the current context: 1003 1004 my $ctx = context(); 1005 my $out = some_tool(...); 1006 $ctx->release; 1007 return $out; 1008 1009We can combine the last 3 lines of the above like so: 1010 1011 my $ctx = context(); 1012 release $ctx, some_tool(...); 1013 1014=head2 context_do(&;@) 1015 1016Usage: 1017 1018 sub my_tool { 1019 context_do { 1020 my $ctx = shift; 1021 1022 my (@args) = @_; 1023 1024 $ctx->ok(1, "pass"); 1025 1026 ... 1027 1028 # No need to call $ctx->release, done for you on scope exit. 1029 } @_; 1030 } 1031 1032Using this inside your test tool takes care of a lot of boilerplate for you. It 1033will ensure a context is acquired. It will capture and rethrow any exception. It 1034will insure the context is released when you are done. It preserves the 1035subroutine call context (array, scalar, void). 1036 1037This is the safest way to write a test tool. The only two downsides to this are a 1038slight performance decrease, and some extra indentation in your source. If the 1039indentation is a problem for you then you can take a peek at the next section. 1040 1041=head2 no_context(&;$) 1042 1043Usage: 1044 1045=over 4 1046 1047=item no_context { ... }; 1048 1049=item no_context { ... } $hid; 1050 1051 sub my_tool(&) { 1052 my $code = shift; 1053 my $ctx = context(); 1054 ... 1055 1056 no_context { 1057 # Things in here will not see our current context, they get a new 1058 # one. 1059 1060 $code->(); 1061 }; 1062 1063 ... 1064 $ctx->release; 1065 }; 1066 1067=back 1068 1069This tool will hide a context for the provided block of code. This means any 1070tools run inside the block will get a completely new context if they acquire 1071one. The new context will be inherited by tools nested below the one that 1072acquired it. 1073 1074This will normally hide the current context for the top hub. If you need to 1075hide the context for a different hub you can pass in the optional C<$hid> 1076parameter. 1077 1078=head2 intercept(&) 1079 1080Usage: 1081 1082 my $events = intercept { 1083 ok(1, "pass"); 1084 ok(0, "fail"); 1085 ... 1086 }; 1087 1088This function takes a codeblock as its only argument, and it has a prototype. 1089It will execute the codeblock, intercepting any generated events in the 1090process. It will return an array reference with all the generated event 1091objects. All events should be subclasses of L<Test2::Event>. 1092 1093This is a very low-level subtest tool. This is useful for writing tools which 1094produce subtests. This is not intended for people simply writing tests. 1095 1096=head2 run_subtest(...) 1097 1098Usage: 1099 1100 run_subtest($NAME, \&CODE, $BUFFERED, @ARGS) 1101 1102 # or 1103 1104 run_subtest($NAME, \&CODE, \%PARAMS, @ARGS) 1105 1106This will run the provided codeblock with the args in C<@args>. This codeblock 1107will be run as a subtest. A subtest is an isolated test state that is condensed 1108into a single L<Test2::Event::Subtest> event, which contains all events 1109generated inside the subtest. 1110 1111=head3 ARGUMENTS: 1112 1113=over 4 1114 1115=item $NAME 1116 1117The name of the subtest. 1118 1119=item \&CODE 1120 1121The code to run inside the subtest. 1122 1123=item $BUFFERED or \%PARAMS 1124 1125If this is a simple scalar then it will be treated as a boolean for the 1126'buffered' setting. If this is a hash reference then it will be used as a 1127parameters hash. The param hash will be used for hub construction (with the 1128specified keys removed). 1129 1130Keys that are removed and used by run_subtest: 1131 1132=over 4 1133 1134=item 'buffered' => $bool 1135 1136Toggle buffered status. 1137 1138=item 'inherit_trace' => $bool 1139 1140Normally the subtest hub is pushed and the sub is allowed to generate its own 1141root context for the hub. When this setting is turned on a root context will be 1142created for the hub that shares the same trace as the current context. 1143 1144Set this to true if your tool is producing subtests without user-specified 1145subs. 1146 1147=item 'no_fork' => $bool 1148 1149Defaults to off. Normally forking inside a subtest will actually fork the 1150subtest, resulting in 2 final subtest events. This parameter will turn off that 1151behavior, only the original process/thread will return a final subtest event. 1152 1153=back 1154 1155=item @ARGS 1156 1157Any extra arguments you want passed into the subtest code. 1158 1159=back 1160 1161=head3 BUFFERED VS UNBUFFERED (OR STREAMED) 1162 1163Normally all events inside and outside a subtest are sent to the formatter 1164immediately by the hub. Sometimes it is desirable to hold off sending events 1165within a subtest until the subtest is complete. This usually depends on the 1166formatter being used. 1167 1168=over 4 1169 1170=item Things not effected by this flag 1171 1172In both cases events are generated and stored in an array. This array is 1173eventually used to populate the C<subevents> attribute on the 1174L<Test2::Event::Subtest> event that is generated at the end of the subtest. 1175This flag has no effect on this part, it always happens. 1176 1177At the end of the subtest, the final L<Test2::Event::Subtest> event is sent to 1178the formatter. 1179 1180=item Things that are effected by this flag 1181 1182The C<buffered> attribute of the L<Test2::Event::Subtest> event will be set to 1183the value of this flag. This means any formatter, listener, etc which looks at 1184the event will know if it was buffered. 1185 1186=item Things that are formatter dependant 1187 1188Events within a buffered subtest may or may not be sent to the formatter as 1189they happen. If a formatter fails to specify then the default is to B<NOT SEND> 1190the events as they are generated, instead the formatter can pull them from the 1191C<subevents> attribute. 1192 1193A formatter can specify by implementing the C<hide_buffered()> method. If this 1194method returns true then events generated inside a buffered subtest will not be 1195sent independently of the final subtest event. 1196 1197=back 1198 1199An example of how this is used is the L<Test2::Formatter::TAP> formatter. For 1200unbuffered subtests the events are rendered as they are generated. At the end 1201of the subtest, the final subtest event is rendered, but the C<subevents> 1202attribute is ignored. For buffered subtests the opposite occurs, the events are 1203NOT rendered as they are generated, instead the C<subevents> attribute is used 1204to render them all at once. This is useful when running subtests tests in 1205parallel, since without it the output from subtests would be interleaved 1206together. 1207 1208=head1 OTHER API EXPORTS 1209 1210Exports in this section are not commonly needed. These all have the 'test2_' 1211prefix to help ensure they stand out. You should look at the L</MAIN API 1212EXPORTS> section before looking here. This section is one where "Great power 1213comes with great responsibility". It is possible to break things badly if you 1214are not careful with these. 1215 1216All exports are optional. You need to list which ones you want at import time: 1217 1218 use Test2::API qw/test2_init_done .../; 1219 1220=head2 STATUS AND INITIALIZATION STATE 1221 1222These provide access to internal state and object instances. 1223 1224=over 4 1225 1226=item $bool = test2_init_done() 1227 1228This will return true if the stack and IPC instances have already been 1229initialized. It will return false if they have not. Init happens as late as 1230possible. It happens as soon as a tool requests the IPC instance, the 1231formatter, or the stack. 1232 1233=item $bool = test2_load_done() 1234 1235This will simply return the boolean value of the loaded flag. If Test2 has 1236finished loading this will be true, otherwise false. Loading is considered 1237complete the first time a tool requests a context. 1238 1239=item test2_set_is_end() 1240 1241=item test2_set_is_end($bool) 1242 1243This is used to toggle Test2's belief that the END phase has already started. 1244With no arguments this will set it to true. With arguments it will set it to 1245the first argument's value. 1246 1247This is used to prevent the use of C<caller()> in END blocks which can cause 1248segfaults. This is only necessary in some persistent environments that may have 1249multiple END phases. 1250 1251=item $bool = test2_get_is_end() 1252 1253Check if Test2 believes it is the END phase. 1254 1255=item $stack = test2_stack() 1256 1257This will return the global L<Test2::API::Stack> instance. If this has not 1258yet been initialized it will be initialized now. 1259 1260=item test2_ipc_disable 1261 1262Disable IPC. 1263 1264=item $bool = test2_ipc_diabled 1265 1266Check if IPC is disabled. 1267 1268=item test2_ipc_wait_enable() 1269 1270=item test2_ipc_wait_disable() 1271 1272=item $bool = test2_ipc_wait_enabled() 1273 1274These can be used to turn IPC waiting on and off, or check the current value of 1275the flag. 1276 1277Waiting is turned on by default. Waiting will cause the parent process/thread 1278to wait until all child processes and threads are finished before exiting. You 1279will almost never want to turn this off. 1280 1281=item $bool = test2_no_wait() 1282 1283=item test2_no_wait($bool) 1284 1285B<DISCOURAGED>: This is a confusing interface, it is better to use 1286C<test2_ipc_wait_enable()>, C<test2_ipc_wait_disable()> and 1287C<test2_ipc_wait_enabled()>. 1288 1289This can be used to get/set the no_wait status. Waiting is turned on by 1290default. Waiting will cause the parent process/thread to wait until all child 1291processes and threads are finished before exiting. You will almost never want 1292to turn this off. 1293 1294=item $fh = test2_stdout() 1295 1296=item $fh = test2_stderr() 1297 1298These functions return the filehandles that test output should be written to. 1299They are primarily useful when writing a custom formatter and code that turns 1300events into actual output (TAP, etc.). They will return a dupe of the original 1301filehandles that formatted output can be sent to regardless of whatever state 1302the currently running test may have left STDOUT and STDERR in. 1303 1304=item test2_reset_io() 1305 1306Re-dupe the internal filehandles returned by C<test2_stdout()> and 1307C<test2_stderr()> from the current STDOUT and STDERR. You shouldn't need to do 1308this except in very peculiar situations (for example, you're testing a new 1309formatter and you need control over where the formatter is sending its output.) 1310 1311=back 1312 1313=head2 BEHAVIOR HOOKS 1314 1315These are hooks that allow you to add custom behavior to actions taken by Test2 1316and tools built on top of it. 1317 1318=over 4 1319 1320=item test2_add_callback_exit(sub { ... }) 1321 1322This can be used to add a callback that is called after all testing is done. This 1323is too late to add additional results, the main use of this callback is to set the 1324exit code. 1325 1326 test2_add_callback_exit( 1327 sub { 1328 my ($context, $exit, \$new_exit) = @_; 1329 ... 1330 } 1331 ); 1332 1333The C<$context> passed in will be an instance of L<Test2::API::Context>. The 1334C<$exit> argument will be the original exit code before anything modified it. 1335C<$$new_exit> is a reference to the new exit code. You may modify this to 1336change the exit code. Please note that C<$$new_exit> may already be different 1337from C<$exit> 1338 1339=item test2_add_callback_post_load(sub { ... }) 1340 1341Add a callback that will be called when Test2 is finished loading. This 1342means the callback will be run once, the first time a context is obtained. 1343If Test2 has already finished loading then the callback will be run immediately. 1344 1345=item test2_add_callback_testing_done(sub { ... }) 1346 1347This adds your coderef as a follow-up to the root hub after Test2 is finished loading. 1348 1349This is essentially a helper to do the following: 1350 1351 test2_add_callback_post_load(sub { 1352 my $stack = test2_stack(); 1353 $stack->top; # Insure we have a hub 1354 my ($hub) = Test2::API::test2_stack->all; 1355 1356 $hub->set_active(1); 1357 1358 $hub->follow_up(sub { ... }); # <-- Your coderef here 1359 }); 1360 1361=item test2_add_callback_context_acquire(sub { ... }) 1362 1363Add a callback that will be called every time someone tries to acquire a 1364context. This will be called on EVERY call to C<context()>. It gets a single 1365argument, a reference to the hash of parameters being used the construct the 1366context. This is your chance to change the parameters by directly altering the 1367hash. 1368 1369 test2_add_callback_context_acquire(sub { 1370 my $params = shift; 1371 $params->{level}++; 1372 }); 1373 1374This is a very scary API function. Please do not use this unless you need to. 1375This is here for L<Test::Builder> and backwards compatibility. This has you 1376directly manipulate the hash instead of returning a new one for performance 1377reasons. 1378 1379=item test2_add_callback_context_init(sub { ... }) 1380 1381Add a callback that will be called every time a new context is created. The 1382callback will receive the newly created context as its only argument. 1383 1384=item test2_add_callback_context_release(sub { ... }) 1385 1386Add a callback that will be called every time a context is released. The 1387callback will receive the released context as its only argument. 1388 1389=item test2_add_callback_pre_subtest(sub { ... }) 1390 1391Add a callback that will be called every time a subtest is going to be 1392run. The callback will receive the subtest name, coderef, and any 1393arguments. 1394 1395=item @list = test2_list_context_acquire_callbacks() 1396 1397Return all the context acquire callback references. 1398 1399=item @list = test2_list_context_init_callbacks() 1400 1401Returns all the context init callback references. 1402 1403=item @list = test2_list_context_release_callbacks() 1404 1405Returns all the context release callback references. 1406 1407=item @list = test2_list_exit_callbacks() 1408 1409Returns all the exit callback references. 1410 1411=item @list = test2_list_post_load_callbacks() 1412 1413Returns all the post load callback references. 1414 1415=item @list = test2_list_pre_subtest_callbacks() 1416 1417Returns all the pre-subtest callback references. 1418 1419=item test2_add_uuid_via(sub { ... }) 1420 1421=item $sub = test2_add_uuid_via() 1422 1423This allows you to provide a UUID generator. If provided UUIDs will be attached 1424to all events, hubs, and contexts. This is useful for storing, tracking, and 1425linking these objects. 1426 1427The sub you provide should always return a unique identifier. Most things will 1428expect a proper UUID string, however nothing in Test2::API enforces this. 1429 1430The sub will receive exactly 1 argument, the type of thing being tagged 1431'context', 'hub', or 'event'. In the future additional things may be tagged, in 1432which case new strings will be passed in. These are purely informative, you can 1433(and usually should) ignore them. 1434 1435=back 1436 1437=head2 IPC AND CONCURRENCY 1438 1439These let you access, or specify, the IPC system internals. 1440 1441=over 4 1442 1443=item $bool = test2_has_ipc() 1444 1445Check if IPC is enabled. 1446 1447=item $ipc = test2_ipc() 1448 1449This will return the global L<Test2::IPC::Driver> instance. If this has not yet 1450been initialized it will be initialized now. 1451 1452=item test2_ipc_add_driver($DRIVER) 1453 1454Add an IPC driver to the list. This will add the driver to the start of the 1455list. 1456 1457=item @drivers = test2_ipc_drivers() 1458 1459Get the list of IPC drivers. 1460 1461=item $bool = test2_ipc_polling() 1462 1463Check if polling is enabled. 1464 1465=item test2_ipc_enable_polling() 1466 1467Turn on polling. This will cull events from other processes and threads every 1468time a context is created. 1469 1470=item test2_ipc_disable_polling() 1471 1472Turn off IPC polling. 1473 1474=item test2_ipc_enable_shm() 1475 1476Legacy, this is currently a no-op that returns 0; 1477 1478=item test2_ipc_set_pending($uniq_val) 1479 1480Tell other processes and events that an event is pending. C<$uniq_val> should 1481be a unique value no other thread/process will generate. 1482 1483B<Note:> After calling this C<test2_ipc_get_pending()> will return 1. This is 1484intentional, and not avoidable. 1485 1486=item $pending = test2_ipc_get_pending() 1487 1488This returns -1 if there is no way to check (assume yes) 1489 1490This returns 0 if there are (most likely) no pending events. 1491 1492This returns 1 if there are (likely) pending events. Upon return it will reset, 1493nothing else will be able to see that there were pending events. 1494 1495=item $timeout = test2_ipc_get_timeout() 1496 1497=item test2_ipc_set_timeout($timeout) 1498 1499Get/Set the timeout value for the IPC system. This timeout is how long the IPC 1500system will wait for child processes and threads to finish before aborting. 1501 1502The default value is C<30> seconds. 1503 1504=back 1505 1506=head2 MANAGING FORMATTERS 1507 1508These let you access, or specify, the formatters that can/should be used. 1509 1510=over 4 1511 1512=item $formatter = test2_formatter 1513 1514This will return the global formatter class. This is not an instance. By 1515default the formatter is set to L<Test2::Formatter::TAP>. 1516 1517You can override this default using the C<T2_FORMATTER> environment variable. 1518 1519Normally 'Test2::Formatter::' is prefixed to the value in the 1520environment variable: 1521 1522 $ T2_FORMATTER='TAP' perl test.t # Use the Test2::Formatter::TAP formatter 1523 $ T2_FORMATTER='Foo' perl test.t # Use the Test2::Formatter::Foo formatter 1524 1525If you want to specify a full module name you use the '+' prefix: 1526 1527 $ T2_FORMATTER='+Foo::Bar' perl test.t # Use the Foo::Bar formatter 1528 1529=item test2_formatter_set($class_or_instance) 1530 1531Set the global formatter class. This can only be set once. B<Note:> This will 1532override anything specified in the 'T2_FORMATTER' environment variable. 1533 1534=item @formatters = test2_formatters() 1535 1536Get a list of all loaded formatters. 1537 1538=item test2_formatter_add($class_or_instance) 1539 1540Add a formatter to the list. Last formatter added is used at initialization. If 1541this is called after initialization a warning will be issued. 1542 1543=back 1544 1545=head1 OTHER EXAMPLES 1546 1547See the C</Examples/> directory included in this distribution. 1548 1549=head1 SEE ALSO 1550 1551L<Test2::API::Context> - Detailed documentation of the context object. 1552 1553L<Test2::IPC> - The IPC system used for threading/fork support. 1554 1555L<Test2::Formatter> - Formatters such as TAP live here. 1556 1557L<Test2::Event> - Events live in this namespace. 1558 1559L<Test2::Hub> - All events eventually funnel through a hub. Custom hubs are how 1560C<intercept()> and C<run_subtest()> are implemented. 1561 1562=head1 MAGIC 1563 1564This package has an END block. This END block is responsible for setting the 1565exit code based on the test results. This end block also calls the callbacks that 1566can be added to this package. 1567 1568=head1 SOURCE 1569 1570The source code repository for Test2 can be found at 1571F<http://github.com/Test-More/test-more/>. 1572 1573=head1 MAINTAINERS 1574 1575=over 4 1576 1577=item Chad Granum E<lt>exodist@cpan.orgE<gt> 1578 1579=back 1580 1581=head1 AUTHORS 1582 1583=over 4 1584 1585=item Chad Granum E<lt>exodist@cpan.orgE<gt> 1586 1587=back 1588 1589=head1 COPYRIGHT 1590 1591Copyright 2019 Chad Granum E<lt>exodist@cpan.orgE<gt>. 1592 1593This program is free software; you can redistribute it and/or 1594modify it under the same terms as Perl itself. 1595 1596See F<http://dev.perl.org/licenses/> 1597 1598=cut 1599