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