Skip to content

Commit

Permalink
Mask warning from IPC init block.
Browse files Browse the repository at this point in the history
The init block was added to help solve some problems when using IPC. It
is not critical that it run, specially when someone does something
clever, which is the usual cause of the warning.

See https://rt.perl.org/Ticket/Display.html?id=133382
  • Loading branch information
exodist committed Jul 17, 2018
1 parent c371791 commit df089e8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@
{{$NEXT}}

- Mask warning from the recent IPC fix generated when threaded Test tools are loaded at run-time

1.302138 2018-07-11 09:29:51-07:00 America/Los_Angeles

- No changes since trial
Expand Down
9 changes: 8 additions & 1 deletion lib/Test2/IPC.pm
Expand Up @@ -19,7 +19,14 @@ use Test2::API qw{
};

# Make sure stuff is finalized before anyone tried to fork or start a new thread.
INIT { context()->release() }
{
# Avoid warnings if things are loaded at run-time
no warnings 'void';
INIT {
use warnings 'void';
context()->release();
}
}

use Carp qw/confess/;

Expand Down
22 changes: 22 additions & 0 deletions t/Legacy_And_Test2/thread_init_warning.t
@@ -0,0 +1,22 @@
use strict;
use warnings;

use Test2::Util qw/CAN_THREAD/;
BEGIN {
unless(CAN_THREAD) {
require Test::More;
Test::More->import(skip_all => "threads are not supported");
}
}

use threads;

my @warns;
{
local $SIG{__WARN__} = sub { push @warns => @_ };
require Test::More;
}

Test::More::is_deeply(\@warns, [], "No init warning");

Test::More::done_testing();

0 comments on commit df089e8

Please sign in to comment.