Force xt/ tests to run on anything involving a create_distdir
[dbsrgits/DBIx-Class.git] / t / 51threadnodb.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 use threads;
9
10 use strict;
11 use warnings;
12 use Test::More;
13
14 plan skip_all => 'DBIC does not actively support threads before perl 5.8.5'
15   if $] < '5.008005';
16
17 use lib qw(t/lib);
18 use DBICTest;
19
20 # README: If you set the env var to a number greater than 10,
21 #   we will use that many children
22 my $num_children = $ENV{DBICTEST_THREAD_STRESS} || 1;
23 if($num_children !~ /^[0-9]+$/ || $num_children < 10) {
24    $num_children = 10;
25 }
26
27 my $schema = DBICTest->init_schema(no_deploy => 1);
28 isa_ok ($schema, 'DBICTest::Schema');
29
30 my @threads;
31 push @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);
39 ok(1, "past spawning");
40
41 $_->join for @threads;
42 ok(1, "past joining");
43
44 done_testing;