Revert 50e6c52e0 - the crash was most likely due to old Moo (same as dfd722ef)
[dbsrgits/DBIx-Class.git] / t / 51threadnodb.t
CommitLineData
a4367b26 1use Config;
2BEGIN {
3 unless ($Config{useithreads}) {
4 print "1..0 # SKIP your perl does not support ithreads\n";
5 exit 0;
6 }
7}
8use threads;
9
10use strict;
11use warnings;
12use Test::More;
13
14plan skip_all => 'DBIC does not actively support threads before perl 5.8.5'
15 if $] < '5.008005';
16
17use lib qw(t/lib);
18use DBICTest;
19
20# README: If you set the env var to a number greater than 10,
21# we will use that many children
22my $num_children = $ENV{DBICTEST_THREAD_STRESS} || 1;
23if($num_children !~ /^[0-9]+$/ || $num_children < 10) {
24 $num_children = 10;
25}
26
27my $schema = DBICTest->init_schema(no_deploy => 1);
28isa_ok ($schema, 'DBICTest::Schema');
29
30my @threads;
31push @threads, threads->create(sub {
32 my $rsrc = $schema->source('Artist');
33 undef $schema;
34 isa_ok ($rsrc->schema, 'DBICTest::Schema');
35 my $s2 = $rsrc->schema->clone;
36
37 sleep 1; # without this many tasty crashes
38}) for (1.. $num_children);
39ok(1, "past spawning");
40
41$_->join for @threads;
42ok(1, "past joining");
43
44done_testing;