Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
a4367b26 |
3 | use Config; |
4 | BEGIN { |
5 | unless ($Config{useithreads}) { |
6 | print "1..0 # SKIP your perl does not support ithreads\n"; |
7 | exit 0; |
8 | } |
f15baf68 |
9 | |
10 | if ($INC{'Devel/Cover.pm'}) { |
11 | print "1..0 # SKIP Devel::Cover does not work with threads yet\n"; |
12 | exit 0; |
13 | } |
a4367b26 |
14 | } |
15 | use threads; |
16 | |
17 | use strict; |
18 | use warnings; |
19 | use Test::More; |
c5915b45 |
20 | use DBIx::Class::_Util 'sigwarn_silencer'; |
a4367b26 |
21 | |
9dfb034f |
22 | use DBICTest; |
23 | |
a4367b26 |
24 | plan skip_all => 'DBIC does not actively support threads before perl 5.8.5' |
750a4ad2 |
25 | if "$]" < 5.008005; |
a4367b26 |
26 | |
9dfb034f |
27 | plan skip_all => 'Potential problems on Win32 Perl < 5.14 and Variable::Magic - investigation pending' |
750a4ad2 |
28 | if $^O eq 'MSWin32' && "$]" < 5.014 && DBICTest::RunMode->is_plain; |
a4367b26 |
29 | |
30 | # README: If you set the env var to a number greater than 10, |
31 | # we will use that many children |
32 | my $num_children = $ENV{DBICTEST_THREAD_STRESS} || 1; |
33 | if($num_children !~ /^[0-9]+$/ || $num_children < 10) { |
34 | $num_children = 10; |
35 | } |
36 | |
37 | my $schema = DBICTest->init_schema(no_deploy => 1); |
38 | isa_ok ($schema, 'DBICTest::Schema'); |
39 | |
40 | my @threads; |
c5915b45 |
41 | SKIP: { |
42 | |
43 | local $SIG{__WARN__} = sigwarn_silencer( qr/Thread creation failed/i ); |
44 | |
45 | for (1.. $num_children) { |
46 | push @threads, threads->create(sub { |
47 | my $rsrc = $schema->source('Artist'); |
48 | undef $schema; |
49 | isa_ok ($rsrc->schema, 'DBICTest::Schema'); |
50 | my $s2 = $rsrc->schema->clone; |
51 | |
52 | sleep 1; # without this many tasty crashes |
53 | }) || do { |
54 | skip "EAGAIN encountered, your system is likely bogged down: skipping rest of test", 1 |
55 | if $! == Errno::EAGAIN(); |
56 | |
57 | die "Unable to start thread: $!"; |
58 | }; |
59 | } |
60 | } |
61 | |
a4367b26 |
62 | ok(1, "past spawning"); |
63 | |
64 | $_->join for @threads; |
65 | ok(1, "past joining"); |
66 | |
67 | done_testing; |