1 package autovivification::TestThreads;
6 use Config qw<%Config>;
11 Test::Leaner::plan(skip_all => $msg);
16 Test::Leaner::diag(@_);
22 require autovivification;
24 skipall 'This autovivification isn\'t thread safe'
25 unless autovivification::A_THREADSAFE();
27 my $force = $ENV{PERL_AUTOVIVIFICATION_TEST_THREADS} ? 1 : !1;
28 skipall 'This perl wasn\'t built to support threads'
29 unless $Config{useithreads};
30 skipall 'perl 5.13.4 required to test thread safety'
31 unless $force or "$]" >= 5.013004;
33 my $t_v = $force ? '0' : '1.67';
34 my $has_threads = do {
36 eval "use threads $t_v; 1";
38 skipall "threads $t_v required to test thread safety" unless $has_threads;
40 defined and diag "Using threads $_" for $threads::VERSION;
47 while (my ($name, $code) = each %exports) {
49 *{$pkg.'::'.$name} = $code;
57 local $SIG{__WARN__} = sub { push @diag, "Thread creation warning: @_" };
60 push @diag, "Thread creation error: $@" if $@;
63 Test::Leaner::diag($_) for @diag;
65 return $thread ? $thread : ();