From: Peter Rabbitson Date: Wed, 7 Aug 2013 07:09:19 +0000 (+0200) Subject: Make sure we can load each DBICTest::Schema result individually X-Git-Tag: v0.08260~159 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=79061be1316b4ac2aa25e60ef51dd8ffbd4e9132;p=dbsrgits%2FDBIx-Class.git Make sure we can load each DBICTest::Schema result individually This will ensure tests always fail if some sort of circular load order issue is encountered, and we won't have to wait for a particular random loading sequence to blow up the tests --- diff --git a/t/02_standalone_test_classes.t b/t/02_standalone_test_classes.t new file mode 100644 index 0000000..55df0df --- /dev/null +++ b/t/02_standalone_test_classes.t @@ -0,0 +1,36 @@ +use warnings; +use strict; + +use Test::More; +use File::Find; + +use lib 't/lib'; + +find({ + wanted => sub { + + return unless ( -f $_ and $_ =~ /\.pm$/ ); + + my $pid = fork(); + if (! defined $pid) { + die "fork failed: $!" + } + elsif (!$pid) { + if (my @offenders = grep { $_ =~ /(^|\/)DBI/ } keys %INC) { + die "Wtf - DBI* modules present in %INC: @offenders"; + } + + local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /\bdeprecated\b/i }; + require( ($_ =~ /(.+)/)[0] ); # untaint + exit 0; + } + + is ( waitpid($pid, 0), $pid, "Fork $pid terminated sucessfully"); + my $ex = $? >> 8; + is ( $ex, 0, "Loading $_ ($pid) exitted with $ex" ); + }, + + no_chdir => 1, +}, 't/lib/DBICTest/Schema/'); + +done_testing;