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