1 package indirect::TestThreads;
6 use Config qw<%Config>;
11 Test::Leaner::plan(skip_all => $msg);
16 Test::Leaner::diag(@_);
24 skipall 'This indirect isn\'t thread safe' unless indirect::I_THREADSAFE();
26 my $force = $ENV{PERL_INDIRECT_TEST_THREADS} ? 1 : !1;
27 skipall 'This perl wasn\'t built to support threads'
28 unless $Config{useithreads};
29 skipall 'perl 5.13.4 required to test thread safety'
30 unless $force or "$]" >= 5.013004;
32 my $t_v = $force ? '0' : '1.67';
33 my $has_threads = do {
35 eval "use threads $t_v; 1";
37 skipall "threads $t_v required to test thread safety" unless $has_threads;
39 defined and diag "Using threads $_" for $threads::VERSION;
46 while (my ($name, $code) = each %exports) {
48 *{$pkg.'::'.$name} = $code;
56 local $SIG{__WARN__} = sub { push @diag, "Thread creation warning: @_" };
59 push @diag, "Thread creation error: $@" if $@;
62 Test::Leaner::diag($_) for @diag;
64 return $thread ? $thread : ();