1 package Variable::Magic::TestThreads;
6 use Config qw<%Config>;
8 use Variable::Magic qw<VMG_THREADSAFE>;
10 use VPIT::TestHelpers;
14 Test::More::diag($_) for @_;
20 skip_all 'This Variable::Magic isn\'t thread safe' unless VMG_THREADSAFE;
22 my $force = $ENV{PERL_VARIABLE_MAGIC_TEST_THREADS} ? 1 : !1;
23 skip_all 'This perl wasn\'t built to support threads'
24 unless $Config{useithreads};
25 skip_all 'perl 5.13.4 required to test thread safety'
26 unless $force or "$]" >= 5.013_004;
28 my $desc = 'required to test thread safety';
29 load_or_skip('threads', $force ? '0' : '1.67', [ ], $desc);
30 load_or_skip('threads::shared', $force ? '0' : '1.14', [ ], $desc);
37 while (my ($name, $code) = each %exports) {
39 *{$pkg.'::'.$name} = $code;
47 local $SIG{__WARN__} = sub { push @diag, "Thread creation warning: @_" };
50 push @diag, "Thread creation error: $@" if $@;
52 return $thread ? $thread : ();