ceac08671688a6b6a6af05243ced57acea27ff5f
[p5sagit/Devel-GlobalDestruction-XS.git] / t / 02_thread.t
1 use Config;
2 BEGIN {
3   unless ($Config{useithreads}) {
4     print "1..0 # SKIP your perl does not support ithreads\n";
5     exit 0;
6   }
7 }
8
9 BEGIN {
10   unless (eval { require threads }) {
11     print "1..0 # SKIP threads.pm not installed\n";
12     exit 0;
13   }
14 }
15
16 use threads;
17 use threads::shared;
18
19 our $had_error :shared;
20 END { $? = $had_error||0 }
21
22 use strict;
23 use warnings;
24
25 # load it before spawning a thread, that's the whole point
26 require Devel::GlobalDestruction::XS;
27
28 sub do_test {
29
30   # just die so we don't need to deal with testcount skew
31   unless ( ($_[0]||'') eq 'arg' ) {
32     $had_error++;
33     die "Argument passing failed!";
34   }
35
36   delete $INC{'t/01_basic.t'};
37   do 't/01_basic.t';
38
39   1;
40 }
41
42 threads->create('do_test', 'arg')->join
43   or $had_error++;