Commit | Line | Data |
79061be1 |
1 | use warnings; |
2 | use strict; |
3 | |
da9346a0 |
4 | BEGIN { delete $ENV{DBICTEST_VERSION_WARNS_INDISCRIMINATELY} } |
5 | |
db9c0386 |
6 | use DBIx::Class::_Util 'sigwarn_silencer'; |
7 | use if DBIx::Class::_ENV_::BROKEN_FORK, 'threads'; |
8 | |
79061be1 |
9 | use Test::More; |
10 | use File::Find; |
db9c0386 |
11 | use Time::HiRes 'sleep'; |
79061be1 |
12 | |
052a832c |
13 | |
79061be1 |
14 | use lib 't/lib'; |
15 | |
db9c0386 |
16 | my $worker = sub { |
17 | my $fn = shift; |
18 | |
841efcb3 |
19 | if (my @offenders = grep { $_ !~ m{DBIx/Class/(?:_Util|Carp)\.pm} } grep { $_ =~ /(^|\/)DBI/ } keys %INC) { |
db9c0386 |
20 | die "Wtf - DBI* modules present in %INC: @offenders"; |
21 | } |
22 | |
23 | local $SIG{__WARN__} = sigwarn_silencer( qr/\bdeprecated\b/i ); |
24 | require( ( $fn =~ m| t/lib/ (.+) |x )[0] ); # untaint and strip lib-part (. is unavailable under -T) |
25 | |
26 | return 42; |
27 | }; |
28 | |
29 | |
79061be1 |
30 | find({ |
31 | wanted => sub { |
32 | |
33 | return unless ( -f $_ and $_ =~ /\.pm$/ ); |
34 | |
db9c0386 |
35 | if (DBIx::Class::_ENV_::BROKEN_FORK) { |
36 | # older perls crash if threads are spawned way too quickly, sleep for 100 msecs |
37 | my $t = threads->create(sub { $worker->($_) }); |
38 | sleep 0.1; |
39 | is ($t->join, 42, "Thread loading $_ did not finish successfully") |
40 | || diag ($t->can('error') ? $t->error : 'threads.pm too old to retrieve the error :(' ); |
79061be1 |
41 | } |
db9c0386 |
42 | else { |
43 | my $pid = fork(); |
44 | if (! defined $pid) { |
45 | die "fork failed: $!" |
46 | } |
47 | elsif (!$pid) { |
48 | $worker->($_); |
49 | exit 0; |
79061be1 |
50 | } |
51 | |
db9c0386 |
52 | is ( waitpid($pid, 0), $pid, "Fork $pid terminated sucessfully"); |
53 | my $ex = $? >> 8; |
54 | is ( $ex, 0, "Loading $_ ($pid) exitted with $ex" ); |
79061be1 |
55 | } |
79061be1 |
56 | }, |
57 | |
58 | no_chdir => 1, |
59 | }, 't/lib/DBICTest/Schema/'); |
60 | |
61 | done_testing; |