This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade Test-Simple from version 1.302122 to 1.302133
[perl5.git] / cpan / Test-Simple / lib / Test2 / IPC.pm
index c09293a..cfee461 100644 (file)
@@ -2,7 +2,7 @@ package Test2::IPC;
 use strict;
 use warnings;
 
-our $VERSION = '1.302045';
+our $VERSION = '1.302133';
 
 
 use Test2::API::Instance;
@@ -10,10 +10,12 @@ use Test2::Util qw/get_tid/;
 use Test2::API qw{
     test2_init_done
     test2_ipc
+    test2_has_ipc
     test2_ipc_enable_polling
     test2_pid
     test2_stack
     test2_tid
+    context
 };
 
 use Carp qw/confess/;
@@ -21,9 +23,12 @@ use Carp qw/confess/;
 our @EXPORT_OK = qw/cull/;
 BEGIN { require Exporter; our @ISA = qw(Exporter) }
 
+sub unimport { Test2::API::test2_ipc_disable() }
+
 sub import {
-    goto &Exporter::import unless test2_init_done();
+    goto &Exporter::import if test2_has_ipc || !test2_init_done();
 
+    confess "IPC is disabled" if Test2::API::test2_ipc_disabled();
     confess "Cannot add IPC in a child process (" . test2_pid() . " vs $$)" if test2_pid() != $$;
     confess "Cannot add IPC in a child thread (" . test2_tid() . " vs " . get_tid() . ")"  if test2_tid() != get_tid();
 
@@ -94,6 +99,11 @@ You should C<use Test2::IPC;> as early as possible in your test file. If you
 import this module after API initialization it will attempt to retrofit IPC
 onto the existing hubs.
 
+=head2 DISABLING IT
+
+You can use C<no Test2::IPC;> to disable IPC for good. You can also use the
+T2_NO_IPC env var.
+
 =head1 EXPORTS
 
 All exports are optional.
@@ -129,7 +139,7 @@ F<http://github.com/Test-More/test-more/>.
 
 =head1 COPYRIGHT
 
-Copyright 2016 Chad Granum E<lt>exodist@cpan.orgE<gt>.
+Copyright 2018 Chad Granum E<lt>exodist@cpan.orgE<gt>.
 
 This program is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself.